@@ -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;
}
@@ -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);
@@ -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) {
@@ -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;
}
@@ -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) {
@@ -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);
}
}
@@ -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;
}
}
@@ -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]);
}
@@ -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;
}
@@ -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;
}
}
@@ -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) {
@@ -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)));
@@ -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);
@@ -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);
@@ -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;
}
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 <ehabkost@redhat.com> --- 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(-)