From patchwork Wed Apr 24 08:03:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 791509 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp700596wrq; Wed, 24 Apr 2024 01:05:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUlSQDl+e9xLb5ibpr3aOx1hgZCG1pEJjmvPTF6QCis3ov7gFAplLjg33VeB5eOwEsY6gP03sJc+bpuaNkNDlQY X-Google-Smtp-Source: AGHT+IEHZBe/w1xlg3D9cDcALJIZ1r3Tdro3BrGmyrHwzIF5cH0gofRtivk6j4hbT8jb86DtZvQC X-Received: by 2002:a05:6358:d593:b0:186:2720:2122 with SMTP id ms19-20020a056358d59300b0018627202122mr1767666rwb.2.1713945959330; Wed, 24 Apr 2024 01:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713945959; cv=none; d=google.com; s=arc-20160816; b=ZCblO43bhhDT/6v3YjTA7Af4jyi37aJkRVG1Vp/SJY4ccnbcUQhCodJj06jrmdXFDZ BhppSOJ9mM9TxvujYsTqlizU3G7Cca3TOtETbJawKu1HnhX5x2/ZWXUkBisuCUfVHZne 8b++FHeqSJ8lKSMv2mdUsSeUXr2NIzmz9Wpvw9jFNKyJZ2bJi0dY23de5wQwf+1dW+WS kvAEl25jEpqrONHhggw26oWBEtFwGkv6kKgbRoKDlb+u0DJbAK2I9UCDaYsyq30LIywF /J1jL607qJx56slup2QNfsUyRVqo+EV7ycj3auG7O97gdcOKc3P2qgn7Q0dVcs/A9S80 uxqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RzyA+8FvRc0MMftFU70dD71qqB2P/3uuYTFBQFXNu+A=; fh=pGUaj4AwlbyGMsnOdYJwwNSDodFSz8lwvV6eBoMyFw4=; b=fMjMa1WLhv/OGyb/GdFzOre+WW2OdbhSPNc+A6+pkYNkBhU8tdHdBAuZO/KVGqm5tR l/IvXhWd8m1EMbrnRphgDJDZpA4DbQK8ck6+v8TUVab16AI/o6mAr1FQIpY4r1pMSeE9 4h8y9vqIQ47TCdbtXOFLPQgiUCSgZT25/OsHMRybBukgeFl+9jcvFtMNQDnjl5Dv1P9q uO9mSc9ydXJU7RXgOyNN5bqBu0r4mvN7cILFvG5GUyXMwyDltHVn3ULpo6u5JW6hGtu1 gw7QbS6mDGIHFVa4YNF6SNmzVkBWkHUkAYil1AZOEendRrqfxALm/pZDYPPyoZd7JF0z vhzw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L3M6GV2A; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ex5-20020a05622a518500b00439890fe230si8839916qtb.442.2024.04.24.01.05.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2024 01:05:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L3M6GV2A; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzXbx-0006sa-Kv; Wed, 24 Apr 2024 04:04:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzXbX-0005t2-7Z for qemu-devel@nongnu.org; Wed, 24 Apr 2024 04:03:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzXbS-0003no-CW for qemu-devel@nongnu.org; Wed, 24 Apr 2024 04:03:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713945821; 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=RzyA+8FvRc0MMftFU70dD71qqB2P/3uuYTFBQFXNu+A=; b=L3M6GV2AX+9bp1juEnhfpqe8rZS1kYNdX2Ww3dC95dPpoqj5Nc7Bg93knxRhkxiaKQovfm 07SImKx5GBhvezjluQLjLegPpa4KgHnRcvv/xyjsEIjRMKsjhy4niTDvCOsOAfSOU52Qdi iFC3+EuZ/+xZQ7AQFFgZY2TMwb+VXy4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-183-zeBbQLcpNeC5jJiFqucZ5w-1; Wed, 24 Apr 2024 04:03:39 -0400 X-MC-Unique: zeBbQLcpNeC5jJiFqucZ5w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 319E780D0FA; Wed, 24 Apr 2024 08:03:39 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 121A93543A; Wed, 24 Apr 2024 08:03:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4499921E66A7; Wed, 24 Apr 2024 10:03:37 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 05/10] qapi: Inline and remove QERR_INVALID_PARAMETER definition Date: Wed, 24 Apr 2024 10:03:32 +0200 Message-ID: <20240424080337.2782594-6-armbru@redhat.com> In-Reply-To: <20240424080337.2782594-1-armbru@redhat.com> References: <20240424080337.2782594-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Address the comment added in commit 4629ed1e98 ("qerror: Finally unused, clean up"), from 2015: /* * These macros will go away, please don't use * in new code, and do not add new ones! */ Mechanical transformation using: $ sed -i -e "s/QERR_INVALID_PARAMETER,/\"Invalid parameter '%s'\",/" \ $(git grep -lw QERR_INVALID_PARAMETER) Manually simplify qemu_opts_create(), and remove the macro definition in include/qapi/qmp/qerror.h. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Markus Armbruster Message-ID: <20240312141343.3168265-6-armbru@redhat.com> --- include/qapi/qmp/qerror.h | 3 --- qapi/opts-visitor.c | 2 +- util/qemu-option.c | 10 +++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index e93211085a..63ab775dc5 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -17,9 +17,6 @@ * add new ones! */ -#define QERR_INVALID_PARAMETER \ - "Invalid parameter '%s'" - #define QERR_INVALID_PARAMETER_TYPE \ "Invalid parameter type for '%s', expected: %s" diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index 8f1efab8b9..3d1a28b419 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -184,7 +184,7 @@ opts_check_struct(Visitor *v, Error **errp) const QemuOpt *first; first = g_queue_peek_head(any); - error_setg(errp, QERR_INVALID_PARAMETER, first->name); + error_setg(errp, "Invalid parameter '%s'", first->name); return false; } return true; diff --git a/util/qemu-option.c b/util/qemu-option.c index eedd08929b..201f7a87f3 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -498,7 +498,7 @@ static bool opt_validate(QemuOpt *opt, Error **errp) desc = find_desc_by_name(list->desc, opt->name); if (!desc && !opts_accepts_any(list)) { - error_setg(errp, QERR_INVALID_PARAMETER, opt->name); + error_setg(errp, "Invalid parameter '%s'", opt->name); return false; } @@ -531,7 +531,7 @@ bool qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val, desc = find_desc_by_name(list->desc, name); if (!desc && !opts_accepts_any(list)) { - error_setg(errp, QERR_INVALID_PARAMETER, name); + error_setg(errp, "Invalid parameter '%s'", name); return false; } @@ -554,7 +554,7 @@ bool qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val, desc = find_desc_by_name(list->desc, name); if (!desc && !opts_accepts_any(list)) { - error_setg(errp, QERR_INVALID_PARAMETER, name); + error_setg(errp, "Invalid parameter '%s'", name); return false; } @@ -612,7 +612,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, if (list->merge_lists) { if (id) { - error_setg(errp, QERR_INVALID_PARAMETER, "id"); + error_setg(errp, "Invalid parameter 'id'"); return NULL; } opts = qemu_opts_find(list, NULL); @@ -1103,7 +1103,7 @@ bool qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp) QTAILQ_FOREACH(opt, &opts->head, next) { opt->desc = find_desc_by_name(desc, opt->name); if (!opt->desc) { - error_setg(errp, QERR_INVALID_PARAMETER, opt->name); + error_setg(errp, "Invalid parameter '%s'", opt->name); return false; }