[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 09/15] [coccinelle] Use ERR_IS_* macros
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RFC 09/15] [coccinelle] Use ERR_IS_* macros |
Date: |
Tue, 13 Jun 2017 13:53:07 -0300 |
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 != 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 == NULL)
+if (!ERR_IS_IGNORED(errp) && !ERR_IS_SET(errp))
ST
Signed-off-by: Eduardo Habkost <address@hidden>
---
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 *filename,
Error **errp)
options_obj = 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 != 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 = ii;
iic->init(ii, errp);
- if (*errp)
+ if (ERR_IS_SET(errp))
return;
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_start,
uint64_t dimm_size = 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;
}
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 = object_property_get_int(OBJECT(dev), PC_DIMM_NODE_PROP, errp);
- if (*errp) {
+ if (ERR_IS_SET(errp)) {
return;
}
if (node < 0 || node >= 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, Error
**errp)
DeviceState *dev = kid->child;
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)
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 = 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(char
const *syspath,
build_guest_fsinfo_for_device(path, fs, errp);
g_free(path);
- 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 = 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 = qdict_first(qdict); e; e = 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(CpuModelExpansionType type
/* convert it to our internal representation */
cpu_model_from_info(&s390_model, model, errp);
- if (*errp) {
+ if (ERR_IS_SET(errp)) {
return NULL;
}
@@ -474,11 +474,11 @@ CpuModelCompareInfo
*arch_query_cpu_model_comparison(CpuModelInfo *infoa,
/* 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 = g_malloc0(sizeof(*compare_info));
@@ -548,12 +548,12 @@ CpuModelBaselineInfo
*arch_query_cpu_model_baseline(CpuModelInfo *infoa,
/* 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;
}
@@ -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 = 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 */
}
- if (!*errp) {
+ if (!ERR_IS_SET(errp)) {
applied = true;
if (model) {
applied_model = *model;
@@ -759,7 +759,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp)
}
max_model = 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)
check_consistency(cpu->model);
check_compatibility(max_model, cpu->model, errp);
- if (*errp) {
+ if (ERR_IS_SET(errp)) {
return;
}
@@ -814,7 +814,7 @@ static void set_feature(Object *obj, Visitor *v, const char
*name,
}
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,
}
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);
- 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-tlscredsx509.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(QCryptoTLSCredsEndpoint endpoint,
"sanity-check", "yes",
NULL);
- 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(QCryptoTLSCredsEndpoint endpoint,
NULL
);
- 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 = errno;
- if (errp == NULL) {
+ if (ERR_IS_IGNORED(errp)) {
return;
}
- assert(*errp == NULL);
+ assert(!ERR_IS_SET(errp));
err = g_malloc0(sizeof(*err));
err->msg = g_strdup_vprintf(fmt, ap);
@@ -103,7 +103,7 @@ void error_setg_errno_internal(Error **errp,
va_list ap;
int saved_errno = errno;
- if (errp == NULL) {
+ if (ERR_IS_IGNORED(errp)) {
return;
}
@@ -127,7 +127,7 @@ void error_vprepend(Error **errp, const char *fmt, va_list
ap)
{
GString *newmsg;
- if (!errp) {
+ if (ERR_IS_IGNORED(errp)) {
return;
}
@@ -153,7 +153,7 @@ void error_append_hint(Error **errp, const char *fmt, ...)
int saved_errno = errno;
Error *err;
- if (!errp) {
+ if (ERR_IS_IGNORED(errp)) {
return;
}
err = *errp;
@@ -178,7 +178,7 @@ void error_setg_win32_internal(Error **errp,
va_list ap;
char *suffix = NULL;
- if (errp == NULL) {
+ if (ERR_IS_IGNORED(errp)) {
return;
}
--
2.11.0.259.g40922b1
- [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if errors are being ignored, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 02/15] error: New IGNORE_ERRORS macro, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 01/15] tests: Test cases for error API, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 03/15] Add qapi/error.h includes on files that will need it, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 05/15] qapi: Use IGNORE_ERRORS instead of NULL on generated code, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 06/15] test-qapi-util: Use IGNORE_ERRORS instead of NULL, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 08/15] error: New ERR_IS_* macros for checking Error** values, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 07/15] Manual changes to use IGNORE_ERRORS instead of NULL, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 10/15] test-qapi-util: Use ERR_IS_* macros, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 11/15] Manual changes to use ERR_IS_* macros, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 09/15] [coccinelle] Use ERR_IS_* macros,
Eduardo Habkost <=
- [Qemu-devel] [RFC 12/15] error: Make IGNORED_ERRORS not a NULL pointer, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 13/15] rdma: Simplify var declaration to avoid confusing Coccinelle, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 04/15] [coccinelle] Use IGNORE_ERRORS instead of NULL as errp argument, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 14/15] [coccinelle] Eliminate unnecessary local_err/error_propagate() usage, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Eduardo Habkost, 2017/06/13
- Message not available
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Eduardo Habkost, 2017/06/17
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Dr. David Alan Gilbert, 2017/06/19
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Peter Maydell, 2017/06/19
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Eduardo Habkost, 2017/06/19
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Eric Blake, 2017/06/27