From nobody Wed Nov 5 15:55:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1497373342838731.874939807161; Tue, 13 Jun 2017 10:02:22 -0700 (PDT) Received: from localhost ([::1]:44341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKpCq-0003O5-Am for importer@patchew.org; Tue, 13 Jun 2017 13:02:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKp4W-0004QG-Nb for qemu-devel@nongnu.org; Tue, 13 Jun 2017 12:53:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKp4T-0000Rg-Fm for qemu-devel@nongnu.org; Tue, 13 Jun 2017 12:53:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35194) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dKp4T-0000Rb-6h for qemu-devel@nongnu.org; Tue, 13 Jun 2017 12:53:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2920D6602; Tue, 13 Jun 2017 16:53:36 +0000 (UTC) Received: from localhost (ovpn-116-27.gru2.redhat.com [10.97.116.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BE10A3941; Tue, 13 Jun 2017 16:53:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2920D6602 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2920D6602 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Tue, 13 Jun 2017 13:53:07 -0300 Message-Id: <20170613165313.20954-10-ehabkost@redhat.com> In-Reply-To: <20170613165313.20954-1-ehabkost@redhat.com> References: <20170613165313.20954-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 13 Jun 2017 16:53:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 09/15] [coccinelle] Use ERR_IS_* macros X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Generated by the following Coccinelle patch: @@ typedef Error; idexpression Error ** errp; statement ST; @@ -if (*errp) +if (ERR_IS_SET(errp)) ST @@ typedef Error; idexpression Error ** errp; statement ST; @@ -if (!*errp) +if (!ERR_IS_SET(errp)) ST @@ typedef Error; idexpression Error ** errp; @@ -assert(!*errp) +assert(!ERR_IS_SET(errp)) @@ typedef Error; idexpression Error ** errp; @@ - assert(errp && *errp); + assert(!ERR_IS_IGNORED(errp) && ERR_IS_SET(errp)); @@ typedef Error; idexpression Error ** errp; @@ - assert(errp && !*errp); + assert(!ERR_IS_IGNORED(errp) && !ERR_IS_SET(errp)); @@ typedef Error; idexpression Error ** errp; @@ - assert(!errp || !*errp); + assert(!ERR_IS_IGNORED(errp) || !ERR_IS_SET(errp)); @@ typedef Error; idexpression Error ** errp; statement ST; @@ -if (errp) +if (!ERR_IS_IGNORED(errp)) ST @@ typedef Error; idexpression Error ** errp; statement ST; @@ -if (!errp) +if (ERR_IS_IGNORED(errp)) ST @@ typedef Error; idexpression Error ** errp; statement ST; @@ -if (errp && *errp) +if (!ERR_IS_IGNORED(errp) && ERR_IS_SET(errp)) ST @@ typedef Error; idexpression Error ** errp; statement ST; @@ -if (errp && *errp !=3D NULL) +if (!ERR_IS_IGNORED(errp) && ERR_IS_SET(errp)) ST @@ typedef Error; idexpression Error ** errp; statement ST; @@ -if (errp && !*errp) +if (!ERR_IS_IGNORED(errp) && !ERR_IS_SET(errp)) ST @@ typedef Error; idexpression Error ** errp; statement ST; @@ -if (errp && *errp =3D=3D NULL) +if (!ERR_IS_IGNORED(errp) && !ERR_IS_SET(errp)) ST Signed-off-by: Eduardo Habkost --- block.c | 2 +- hw/acpi/cpu_hotplug.c | 2 +- hw/ipmi/isa_ipmi_bt.c | 2 +- hw/mem/pc-dimm.c | 2 +- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_pci.c | 2 +- hw/s390x/event-facility.c | 2 +- net/net.c | 2 +- qapi/qobject-input-visitor.c | 2 +- qga/commands-posix.c | 2 +- target/s390x/cpu_models.c | 30 +++++++++++++++--------------- target/s390x/helper.c | 2 +- tests/test-crypto-tlscredsx509.c | 2 +- tests/test-io-channel-tls.c | 2 +- util/error.c | 12 ++++++------ 15 files changed, 34 insertions(+), 34 deletions(-) diff --git a/block.c b/block.c index ecb5be9a32..b08d95a62a 100644 --- a/block.c +++ b/block.c @@ -1383,7 +1383,7 @@ static QDict *parse_json_filename(const char *filenam= e, Error **errp) options_obj =3D qobject_from_json(filename, errp); if (!options_obj) { /* Work around qobject_from_json() lossage TODO fix that */ - if (errp && !*errp) { + if (!ERR_IS_IGNORED(errp) && !ERR_IS_SET(errp)) { error_setg(errp, "Could not parse the JSON options"); return NULL; } diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c index 5243918125..c72a748bb3 100644 --- a/hw/acpi/cpu_hotplug.c +++ b/hw/acpi/cpu_hotplug.c @@ -76,7 +76,7 @@ void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, AcpiCpuHotplug *g, DeviceState *dev, Error **= errp) { acpi_set_cpu_present_bit(g, CPU(dev), errp); - if (*errp !=3D NULL) { + if (ERR_IS_SET(errp)) { return; } acpi_send_event(DEVICE(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS); diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c index 2fcc3d2e7c..c7480f5f78 100644 --- a/hw/ipmi/isa_ipmi_bt.c +++ b/hw/ipmi/isa_ipmi_bt.c @@ -438,7 +438,7 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error= **errp) iib->bt.bmc->intf =3D ii; =20 iic->init(ii, errp); - if (*errp) + if (ERR_IS_SET(errp)) return; =20 if (iib->isairq > 0) { diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 92fb48255a..4e5e2c9339 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -316,7 +316,7 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_s= tart, uint64_t dimm_size =3D object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP, errp); - if (errp && *errp) { + if (!ERR_IS_IGNORED(errp) && ERR_IS_SET(errp)) { goto out; } =20 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e07fd88a55..af33297e0f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2983,7 +2983,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, return; } node =3D object_property_get_int(OBJECT(dev), PC_DIMM_NODE_PROP, e= rrp); - if (*errp) { + if (ERR_IS_SET(errp)) { return; } if (node < 0 || node >=3D MAX_NODES) { diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index b0c58ad3f1..5b3660b674 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1364,7 +1364,7 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector= *drc, drck->attach(drc, DEVICE(pdev), fdt, fdt_start_offset, !dev->hotplugged, errp); out: - if (*errp) { + if (ERR_IS_SET(errp)) { g_free(fdt); } } diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 2f2bf8b45d..6eac626212 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -296,7 +296,7 @@ static void sclp_events_bus_realize(BusState *bus, Erro= r **errp) DeviceState *dev =3D kid->child; =20 object_property_set_bool(OBJECT(dev), true, "realized", errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return; } } diff --git a/net/net.c b/net/net.c index b7f5459b33..5c09301692 100644 --- a/net/net.c +++ b/net/net.c @@ -1061,7 +1061,7 @@ static int net_client_init1(const void *object, bool = is_netdev, Error **errp) =20 if (net_client_init_fun[netdev->type](netdev, name, peer, errp) < 0) { /* FIXME drop when all init functions store an Error */ - if (errp && !*errp) { + if (!ERR_IS_IGNORED(errp) && !ERR_IS_SET(errp)) { error_setg(errp, QERR_DEVICE_INIT_FAILED, NetClientDriver_lookup[netdev->type]); } diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index eac40f618a..7da822b3a2 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -723,7 +723,7 @@ Visitor *qobject_input_visitor_new_str(const char *str, obj =3D qobject_from_json(str, errp); if (!obj) { /* Work around qobject_from_json() lossage TODO fix that */ - if (errp && !*errp) { + if (!ERR_IS_IGNORED(errp) && !ERR_IS_SET(errp)) { error_setg(errp, "JSON parse error"); return NULL; } diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 220a50ad7c..623a32a7d8 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1025,7 +1025,7 @@ static void build_guest_fsinfo_for_virtual_device(cha= r const *syspath, build_guest_fsinfo_for_device(path, fs, errp); g_free(path); =20 - if (*errp) { + if (ERR_IS_SET(errp)) { break; } } diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 5206a10134..4fde8f41fd 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -348,22 +348,22 @@ static void cpu_model_from_info(S390CPUModel *model, = const CpuModelInfo *info, if (qdict) { visitor =3D qobject_input_visitor_new(info->props); visit_start_struct(visitor, NULL, NULL, 0, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { object_unref(obj); return; } for (e =3D qdict_first(qdict); e; e =3D qdict_next(qdict, e)) { object_property_set(obj, visitor, e->key, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { break; } } - if (!*errp) { + if (!ERR_IS_SET(errp)) { visit_check_struct(visitor, errp); } visit_end_struct(visitor, NULL); visit_free(visitor); - if (*errp) { + if (ERR_IS_SET(errp)) { object_unref(obj); return; } @@ -434,7 +434,7 @@ CpuModelExpansionInfo *arch_query_cpu_model_expansion(C= puModelExpansionType type =20 /* convert it to our internal representation */ cpu_model_from_info(&s390_model, model, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return NULL; } =20 @@ -474,11 +474,11 @@ CpuModelCompareInfo *arch_query_cpu_model_comparison(= CpuModelInfo *infoa, =20 /* convert both models to our internal representation */ cpu_model_from_info(&modela, infoa, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return NULL; } cpu_model_from_info(&modelb, infob, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return NULL; } compare_info =3D g_malloc0(sizeof(*compare_info)); @@ -548,12 +548,12 @@ CpuModelBaselineInfo *arch_query_cpu_model_baseline(C= puModelInfo *infoa, =20 /* convert both models to our internal representation */ cpu_model_from_info(&modela, infoa, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return NULL; } =20 cpu_model_from_info(&modelb, infob, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return NULL; } =20 @@ -702,7 +702,7 @@ static S390CPUModel *get_max_cpu_model(Error **errp) S390_FEAT_MAX); add_qemu_cpu_model_features(max_model.features); } - if (!*errp) { + if (!ERR_IS_SET(errp)) { cached =3D true; return &max_model; } @@ -732,7 +732,7 @@ static inline void apply_cpu_model(const S390CPUModel *= model, Error **errp) /* FIXME TCG - use data for stdip/stfl */ } =20 - if (!*errp) { + if (!ERR_IS_SET(errp)) { applied =3D true; if (model) { applied_model =3D *model; @@ -759,7 +759,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) } =20 max_model =3D get_max_cpu_model(errp); - if (*errp) { + if (ERR_IS_SET(errp)) { error_prepend(errp, "CPU models are not available: "); return; } @@ -771,7 +771,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) =20 check_consistency(cpu->model); check_compatibility(max_model, cpu->model, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return; } =20 @@ -814,7 +814,7 @@ static void set_feature(Object *obj, Visitor *v, const = char *name, } =20 visit_type_bool(v, name, &value, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return; } if (value) { @@ -871,7 +871,7 @@ static void set_feature_group(Object *obj, Visitor *v, = const char *name, } =20 visit_type_bool(v, name, &value, errp); - if (*errp) { + if (ERR_IS_SET(errp)) { return; } if (value) { diff --git a/target/s390x/helper.c b/target/s390x/helper.c index a8d20c51fa..1408ce2b4a 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -98,7 +98,7 @@ S390CPU *cpu_s390x_create(const char *cpu_model, Error **= errp) } g_free(name); =20 - if (*errp) { + if (ERR_IS_SET(errp)) { return NULL; } return S390_CPU(CPU(object_new(typename))); diff --git a/tests/test-crypto-tlscredsx509.c b/tests/test-crypto-tlscredsx= 509.c index af2f80e89c..a14b4b1cad 100644 --- a/tests/test-crypto-tlscredsx509.c +++ b/tests/test-crypto-tlscredsx509.c @@ -54,7 +54,7 @@ static QCryptoTLSCreds *test_tls_creds_create(QCryptoTLSC= redsEndpoint endpoint, "sanity-check", "yes", NULL); =20 - if (*errp) { + if (ERR_IS_SET(errp)) { return NULL; } return QCRYPTO_TLS_CREDS(creds); diff --git a/tests/test-io-channel-tls.c b/tests/test-io-channel-tls.c index fae2906060..6509ab1045 100644 --- a/tests/test-io-channel-tls.c +++ b/tests/test-io-channel-tls.c @@ -89,7 +89,7 @@ static QCryptoTLSCreds *test_tls_creds_create(QCryptoTLSC= redsEndpoint endpoint, NULL ); =20 - if (*errp) { + if (ERR_IS_SET(errp)) { return NULL; } return QCRYPTO_TLS_CREDS(creds); diff --git a/util/error.c b/util/error.c index 020b86b9f0..a1d998646a 100644 --- a/util/error.c +++ b/util/error.c @@ -51,10 +51,10 @@ static void error_setv(Error **errp, Error *err; int saved_errno =3D errno; =20 - if (errp =3D=3D NULL) { + if (ERR_IS_IGNORED(errp)) { return; } - assert(*errp =3D=3D NULL); + assert(!ERR_IS_SET(errp)); =20 err =3D g_malloc0(sizeof(*err)); err->msg =3D g_strdup_vprintf(fmt, ap); @@ -103,7 +103,7 @@ void error_setg_errno_internal(Error **errp, va_list ap; int saved_errno =3D errno; =20 - if (errp =3D=3D NULL) { + if (ERR_IS_IGNORED(errp)) { return; } =20 @@ -127,7 +127,7 @@ void error_vprepend(Error **errp, const char *fmt, va_l= ist ap) { GString *newmsg; =20 - if (!errp) { + if (ERR_IS_IGNORED(errp)) { return; } =20 @@ -153,7 +153,7 @@ void error_append_hint(Error **errp, const char *fmt, .= ..) int saved_errno =3D errno; Error *err; =20 - if (!errp) { + if (ERR_IS_IGNORED(errp)) { return; } err =3D *errp; @@ -178,7 +178,7 @@ void error_setg_win32_internal(Error **errp, va_list ap; char *suffix =3D NULL; =20 - if (errp =3D=3D NULL) { + if (ERR_IS_IGNORED(errp)) { return; } =20 --=20 2.11.0.259.g40922b1