From nobody Sun May 19 15:29:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615481221; cv=none; d=zohomail.com; s=zohoarc; b=SvgRvcj9Y+KJJ+J1fKtitzOQRCkjYTKG3apez6CsdMew/4ldwY+Pru3i/nE3q0880b/ZSTrhzrDgr/Q+A4fMH9dbUwDL8Ff47rPz2QpG1jKzsNmIsPOd3/StFkgUE0JdKkDd4+X5M4c1EZZPtzlD18ajxtAh4rKASntEEYJ+Q9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615481221; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pIdzck0FS4uIhQQ7gWjs6alQifPqEsLke6BaZPY6Qew=; b=J+j8CMOrd9MwzLYgmZzbFt0HuSPwkjrBZdbP6wIW+BlLMDYe6rWBmCd7S5wizVdYN8EZEVKiY+jdmP+g09npJSg1PEUYON2+E7ecXAP7P6bqmaBAlkKAs2eoTvKPS7oKqVwBtDnHFEn1dyTyQOu4gifCkGOOszfr72skKlAO+HQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615481221543945.2536690979715; Thu, 11 Mar 2021 08:47:01 -0800 (PST) Received: from localhost ([::1]:34060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKOSi-0005ex-DZ for importer@patchew.org; Thu, 11 Mar 2021 11:47:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKOOv-0002Z8-Uy for qemu-devel@nongnu.org; Thu, 11 Mar 2021 11:43:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKOOu-0003QJ-Ak for qemu-devel@nongnu.org; Thu, 11 Mar 2021 11:43:05 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-76iI2DNKM9eBJvfR7aDRiQ-1; Thu, 11 Mar 2021 11:43:01 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7FCD800D55 for ; Thu, 11 Mar 2021 16:43:00 +0000 (UTC) Received: from merkur.fritz.box (ovpn-114-112.ams2.redhat.com [10.36.114.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id B24DF5D9F0; Thu, 11 Mar 2021 16:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615480983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pIdzck0FS4uIhQQ7gWjs6alQifPqEsLke6BaZPY6Qew=; b=E81lCUs57ULQ8CniQgqwlTb379VS9dFNq13nBywgHIA1Ca/TId/2PDOCs570mquZ3PxRq+ HoRc+7ZS0pmjTIlH1GrYKD4pqYoLrQDBQfFN9jtpy9Y7ICqTrC2G4gCzCZ8GaFC23WKQ3D ymE11IYM1rVxn9ZjeO3vjdBQS0Q//V4= X-MC-Unique: 76iI2DNKM9eBJvfR7aDRiQ-1 From: Kevin Wolf To: qemu-devel@nongnu.org Subject: [PATCH v2 1/3] char: Skip CLI aliases in query-chardev-backends Date: Thu, 11 Mar 2021 17:42:51 +0100 Message-Id: <20210311164253.338723-2-kwolf@redhat.com> In-Reply-To: <20210311164253.338723-1-kwolf@redhat.com> References: <20210311164253.338723-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The aliases "tty" and "parport" are only valid on the command line, QMP commands like chardev-add don't know them. query-chardev-backends should describe QMP and therefore not include them in the list of available backends. Signed-off-by: Kevin Wolf Acked-by: Paolo Bonzini Reviewed-by: Markus Armbruster --- chardev/char.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 97cafd6849..dd925cf9a4 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -547,7 +547,7 @@ static const struct ChardevAlias { }; =20 typedef struct ChadevClassFE { - void (*fn)(const char *name, void *opaque); + void (*fn)(const char *name, bool is_cli_alias, void *opaque); void *opaque; } ChadevClassFE; =20 @@ -561,11 +561,13 @@ chardev_class_foreach(ObjectClass *klass, void *opaqu= e) return; } =20 - fe->fn(object_class_get_name(klass) + 8, fe->opaque); + fe->fn(object_class_get_name(klass) + 8, false, fe->opaque); } =20 static void -chardev_name_foreach(void (*fn)(const char *name, void *opaque), void *opa= que) +chardev_name_foreach(void (*fn)(const char *name, bool is_cli_alias, + void *opaque), + void *opaque) { ChadevClassFE fe =3D { .fn =3D fn, .opaque =3D opaque }; int i; @@ -573,12 +575,12 @@ chardev_name_foreach(void (*fn)(const char *name, voi= d *opaque), void *opaque) object_class_foreach(chardev_class_foreach, TYPE_CHARDEV, false, &fe); =20 for (i =3D 0; i < (int)ARRAY_SIZE(chardev_alias_table); i++) { - fn(chardev_alias_table[i].alias, opaque); + fn(chardev_alias_table[i].alias, true, opaque); } } =20 static void -help_string_append(const char *name, void *opaque) +help_string_append(const char *name, bool is_cli_alias, void *opaque) { GString *str =3D opaque; =20 @@ -798,11 +800,16 @@ ChardevInfoList *qmp_query_chardev(Error **errp) } =20 static void -qmp_prepend_backend(const char *name, void *opaque) +qmp_prepend_backend(const char *name, bool is_cli_alias, void *opaque) { ChardevBackendInfoList **list =3D opaque; - ChardevBackendInfo *value =3D g_new0(ChardevBackendInfo, 1); + ChardevBackendInfo *value; =20 + if (is_cli_alias) { + return; + } + + value =3D g_new0(ChardevBackendInfo, 1); value->name =3D g_strdup(name); QAPI_LIST_PREPEND(*list, value); } --=20 2.29.2 From nobody Sun May 19 15:29:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615481485; cv=none; d=zohomail.com; s=zohoarc; b=MXkS78GhUPa6ybYEnoAXrI2sV44SbDWsDZJ2z5c8ROCngBM9HVtFltGYp9ON6HlScyP9dHSu1gwax1tDMy4y6ENLnHnGSATlwmYDUE1M71oPWRPFMOMcbOId3Z8dbTHszZZBhkmd5qNvnxNEiUSRb+afvb03hXgAjWJWQS2ktoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615481485; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1qY0MKBAjygJuChHuHKyLKZalvVa7pH9p5w4z80tfA4=; b=aKF0DyXGphDy39Kryipy9A0jSin2prG41tDUsDS82Gf6fWf6qdo4hx4+q5eTb8gK9//+3ErsPYi5rOsA1nDHQG+yaQzYHuyqoaaBdqhOVqNd05pnwbixKA26XaVs0C/Dk7tPtAta2ivPGg89Dw9xXUazA91kM5K4ZoC99jI2f0Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615481485726305.6972618857668; Thu, 11 Mar 2021 08:51:25 -0800 (PST) Received: from localhost ([::1]:44342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKOWy-0001xO-LU for importer@patchew.org; Thu, 11 Mar 2021 11:51:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKOOx-0002bw-5s for qemu-devel@nongnu.org; Thu, 11 Mar 2021 11:43:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKOOv-0003Qx-76 for qemu-devel@nongnu.org; Thu, 11 Mar 2021 11:43:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-hcSQWvpRMRCP3qsM3kVZHQ-1; Thu, 11 Mar 2021 11:43:02 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4DA65152 for ; Thu, 11 Mar 2021 16:43:01 +0000 (UTC) Received: from merkur.fritz.box (ovpn-114-112.ams2.redhat.com [10.36.114.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE2795D9F0; Thu, 11 Mar 2021 16:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615480984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1qY0MKBAjygJuChHuHKyLKZalvVa7pH9p5w4z80tfA4=; b=asPHWrKXdVgPFgxC64eSEi6v1j5PA+erEAlNOckZVkELgfvUzR4IpOa7y6HF9rZIvZOzHT lcOSA1//PxoCGZMWfc/dOpgsJLF76vcjQiYl+g3qgBNIXXbrEZD/azI7+W3No6EoPFfHTd doJwtRD8XY518YnoqBM0803VG5Udwvg= X-MC-Unique: hcSQWvpRMRCP3qsM3kVZHQ-1 From: Kevin Wolf To: qemu-devel@nongnu.org Subject: [PATCH v2 2/3] char: Deprecate backend aliases 'tty' and 'parport' Date: Thu, 11 Mar 2021 17:42:52 +0100 Message-Id: <20210311164253.338723-3-kwolf@redhat.com> In-Reply-To: <20210311164253.338723-1-kwolf@redhat.com> References: <20210311164253.338723-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" QAPI doesn't know the aliases 'tty' and 'parport' and there is no reason to prefer them to the real names of the backends 'serial' and 'parallel'. Signed-off-by: Kevin Wolf Acked-by: Paolo Bonzini Reviewed-by: Markus Armbruster --- docs/system/deprecated.rst | 6 ++++++ chardev/char.c | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 3e9e3a26f6..11da79ea5b 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -75,6 +75,12 @@ The ``pretty=3Don|off`` switch has no effect for HMP mon= itors, but is silently ignored. Using the switch with HMP monitors will become an error in the future. =20 +``-chardev`` backend aliases ``tty`` and ``parport`` (since 6.0) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +``tty`` and ``parport`` are aliases that will be removed. Instead, the +actual backend names ``serial`` and ``parallel`` should be used. + RISC-V ``-bios`` (since 5.1) '''''''''''''''''''''''''''' =20 diff --git a/chardev/char.c b/chardev/char.c index dd925cf9a4..7be9579dd8 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -534,9 +534,10 @@ static const ChardevClass *char_get_class(const char *= driver, Error **errp) return cc; } =20 -static const struct ChardevAlias { +static struct ChardevAlias { const char *typename; const char *alias; + bool deprecation_warning_printed; } chardev_alias_table[] =3D { #ifdef HAVE_CHARDEV_PARPORT { "parallel", "parport" }, @@ -584,6 +585,10 @@ help_string_append(const char *name, bool is_cli_alias= , void *opaque) { GString *str =3D opaque; =20 + if (is_cli_alias) { + return; + } + g_string_append_printf(str, "\n %s", name); } =20 @@ -592,6 +597,11 @@ static const char *chardev_alias_translate(const char = *name) int i; for (i =3D 0; i < (int)ARRAY_SIZE(chardev_alias_table); i++) { if (g_strcmp0(chardev_alias_table[i].alias, name) =3D=3D 0) { + if (!chardev_alias_table[i].deprecation_warning_printed) { + warn_report("The alias '%s' is deprecated, use '%s' instea= d", + name, chardev_alias_table[i].typename); + chardev_alias_table[i].deprecation_warning_printed =3D tru= e; + } return chardev_alias_table[i].typename; } } --=20 2.29.2 From nobody Sun May 19 15:29:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615481594; cv=none; d=zohomail.com; s=zohoarc; b=frEtBzBKogX8bdRTmrVMAGjKdJLPznLysvLuE/nRuarXKJSml/T4IivgcC3splzmlAFRRiTnaPKyFs6ZZ52/ML2aM0wGjEGz2M7XfNXAqKsgW2eQ2f29P2WII4V5UfEUUArHxwF7lDYOlPydtYjrjouRv95GsxX4l/lhLrL18h8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615481594; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QwFiGvOWGoqmRcBJnmrX+Q8xgVhXHyuSLKF45wdYMqo=; b=RH3kJJPMU8athy0do2KKuOggyu16PCG/uLI2YY3184tGSaHBDyVA0Fqd3cZxiQ0N9XFcJOIL6xTUQCJZUb2xrClUuzGLmBODz7W71pYoLx1yQzctozHiZvWibjK2jRu2qRA770ueZ1yKnou6DLBN892t927dbAbJgld+hKg9F68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615481594147774.5967152546839; Thu, 11 Mar 2021 08:53:14 -0800 (PST) Received: from localhost ([::1]:46920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKOYj-00041o-1G for importer@patchew.org; Thu, 11 Mar 2021 11:53:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKOOy-0002fm-N4 for qemu-devel@nongnu.org; Thu, 11 Mar 2021 11:43:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39248) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKOOw-0003RE-QY for qemu-devel@nongnu.org; Thu, 11 Mar 2021 11:43:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-541-pfAy45POPUic6c3SKyPIjg-1; Thu, 11 Mar 2021 11:43:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D21D80D6AC for ; Thu, 11 Mar 2021 16:43:03 +0000 (UTC) Received: from merkur.fritz.box (ovpn-114-112.ams2.redhat.com [10.36.114.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3894D5D9F0; Thu, 11 Mar 2021 16:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615480986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QwFiGvOWGoqmRcBJnmrX+Q8xgVhXHyuSLKF45wdYMqo=; b=eH0/HAk423L5bHP0HiqtanQVgg2qmTyR1oKtmIeuLEtZzv4O/3H3sQxQg0kzDwgZiXcABk bNnQllv7PN34Ezf5k6mWbL+oOXz0EY662V8W71/PR53ojxjx78ERdbMVPqNOkviEchdwL6 s1EThOSOYYsN6ISq+QX7baKq0uIpeOY= X-MC-Unique: pfAy45POPUic6c3SKyPIjg-1 From: Kevin Wolf To: qemu-devel@nongnu.org Subject: [PATCH v2 3/3] char: Simplify chardev_name_foreach() Date: Thu, 11 Mar 2021 17:42:53 +0100 Message-Id: <20210311164253.338723-4-kwolf@redhat.com> In-Reply-To: <20210311164253.338723-1-kwolf@redhat.com> References: <20210311164253.338723-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Both callers use callbacks that don't do anything when they are called for CLI aliases. Instead of passing the cli_alias parameter, just don't call the callbacks for aliases in the first place. Signed-off-by: Kevin Wolf Reviewed-by: Markus Armbruster --- chardev/char.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 7be9579dd8..140d6d9d36 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -548,7 +548,7 @@ static struct ChardevAlias { }; =20 typedef struct ChadevClassFE { - void (*fn)(const char *name, bool is_cli_alias, void *opaque); + void (*fn)(const char *name, void *opaque); void *opaque; } ChadevClassFE; =20 @@ -562,33 +562,23 @@ chardev_class_foreach(ObjectClass *klass, void *opaqu= e) return; } =20 - fe->fn(object_class_get_name(klass) + 8, false, fe->opaque); + fe->fn(object_class_get_name(klass) + 8, fe->opaque); } =20 static void -chardev_name_foreach(void (*fn)(const char *name, bool is_cli_alias, - void *opaque), +chardev_name_foreach(void (*fn)(const char *name, void *opaque), void *opaque) { ChadevClassFE fe =3D { .fn =3D fn, .opaque =3D opaque }; - int i; =20 object_class_foreach(chardev_class_foreach, TYPE_CHARDEV, false, &fe); - - for (i =3D 0; i < (int)ARRAY_SIZE(chardev_alias_table); i++) { - fn(chardev_alias_table[i].alias, true, opaque); - } } =20 static void -help_string_append(const char *name, bool is_cli_alias, void *opaque) +help_string_append(const char *name, void *opaque) { GString *str =3D opaque; =20 - if (is_cli_alias) { - return; - } - g_string_append_printf(str, "\n %s", name); } =20 @@ -810,15 +800,11 @@ ChardevInfoList *qmp_query_chardev(Error **errp) } =20 static void -qmp_prepend_backend(const char *name, bool is_cli_alias, void *opaque) +qmp_prepend_backend(const char *name, void *opaque) { ChardevBackendInfoList **list =3D opaque; ChardevBackendInfo *value; =20 - if (is_cli_alias) { - return; - } - value =3D g_new0(ChardevBackendInfo, 1); value->name =3D g_strdup(name); QAPI_LIST_PREPEND(*list, value); --=20 2.29.2