Avoid using !STREQ and !STRNEQ

We have macros for both positive and negative string matching.
Therefore there is no need to use !STREQ or !STRNEQ. At the same
time as we are dropping this, new syntax-check rule is
introduced to make sure we won't introduce it again.

Signed-off-by: Ishmanpreet Kaur Khera <khera.ishman@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ishmanpreet Kaur Khera 2015-10-20 21:45:12 +05:30 committed by Michal Privoznik
parent 1b4de77e85
commit 32cee5b2f0
29 changed files with 72 additions and 56 deletions

16
cfg.mk
View File

@ -1011,6 +1011,16 @@ sc_prohibit_pthread_create:
halt="avoid using 'pthread_create', use 'virThreadCreate' instead" \ halt="avoid using 'pthread_create', use 'virThreadCreate' instead" \
$(_sc_search_regexp) $(_sc_search_regexp)
sc_prohibit_not_streq:
@prohibit='! *STREQ *\(.*\)' \
halt='Use STRNEQ instead of !STREQ' \
$(_sc_search_regexp)
sc_prohibit_not_strneq:
@prohibit='! *STRNEQ *\(.*\)' \
halt='Use STREQ instead of !STRNEQ' \
$(_sc_search_regexp)
# We don't use this feature of maint.mk. # We don't use this feature of maint.mk.
prev_version_file = /dev/null prev_version_file = /dev/null
@ -1213,3 +1223,9 @@ exclude_file_name_regexp--sc_prohibit_sysconf_pagesize = \
exclude_file_name_regexp--sc_prohibit_pthread_create = \ exclude_file_name_regexp--sc_prohibit_pthread_create = \
^(cfg\.mk|src/util/virthread\.c|tests/.*)$$ ^(cfg\.mk|src/util/virthread\.c|tests/.*)$$
exclude_file_name_regexp--sc_prohibit_not_streq = \
^tests/.*\.[ch]$$
exclude_file_name_regexp--sc_prohibit_not_strneq = \
^tests/.*\.[ch]$$

View File

@ -197,7 +197,7 @@ bhyveConnectOpen(virConnectPtr conn,
if (conn->uri->server) if (conn->uri->server)
return VIR_DRV_OPEN_DECLINED; return VIR_DRV_OPEN_DECLINED;
if (!STREQ_NULLABLE(conn->uri->path, "/system")) { if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected bhyve URI path '%s', try bhyve:///system"), _("Unexpected bhyve URI path '%s', try bhyve:///system"),
conn->uri->path); conn->uri->path);

View File

@ -3042,7 +3042,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
if (!(def = virNetworkDefParseXML(ctxt))) if (!(def = virNetworkDefParseXML(ctxt)))
goto error; goto error;
if (!STREQ(name, def->name)) { if (STRNEQ(name, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Network config filename '%s'" _("Network config filename '%s'"
" does not match network name '%s'"), " does not match network name '%s'"),
@ -3152,7 +3152,7 @@ virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets,
if (!(def = virNetworkDefParseFile(configFile))) if (!(def = virNetworkDefParseFile(configFile)))
goto error; goto error;
if (!STREQ(name, def->name)) { if (STRNEQ(name, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Network config filename '%s'" _("Network config filename '%s'"
" does not match network name '%s'"), " does not match network name '%s'"),

View File

@ -3082,7 +3082,7 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
nwfilter = virNWFilterObjFindByUUID(nwfilters, def->uuid); nwfilter = virNWFilterObjFindByUUID(nwfilters, def->uuid);
if (nwfilter) { if (nwfilter) {
if (!STREQ(def->name, nwfilter->def->name)) { if (STRNEQ(def->name, nwfilter->def->name)) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
_("filter with same UUID but different name " _("filter with same UUID but different name "
"('%s') already exists"), "('%s') already exists"),

View File

@ -444,7 +444,7 @@ virNWFilterVarCombIterEntryAreUniqueEntries(virNWFilterVarCombIterEntryPtr cie,
/* should never occur to step on a NULL here */ /* should never occur to step on a NULL here */
return true; return true;
} }
if (!STREQ(virNWFilterVarValueGetNthValue(tmp, cie->curValue), if (STRNEQ(virNWFilterVarValueGetNthValue(tmp, cie->curValue),
virNWFilterVarValueGetNthValue(tmp, i))) { virNWFilterVarValueGetNthValue(tmp, i))) {
isSame = false; isSame = false;
break; break;

View File

@ -1873,7 +1873,7 @@ virStoragePoolLoadState(virStoragePoolObjListPtr pools,
if (!(def = virStoragePoolDefParseXML(ctxt))) if (!(def = virStoragePoolDefParseXML(ctxt)))
goto error; goto error;
if (!STREQ(name, def->name)) { if (STRNEQ(name, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Storage pool state file '%s' does not match " _("Storage pool state file '%s' does not match "
"pool name '%s'"), "pool name '%s'"),

View File

@ -90,7 +90,7 @@ static int lxcProcReaddir(const char *path, void *buf,
off_t offset ATTRIBUTE_UNUSED, off_t offset ATTRIBUTE_UNUSED,
struct fuse_file_info *fi ATTRIBUTE_UNUSED) struct fuse_file_info *fi ATTRIBUTE_UNUSED)
{ {
if (!STREQ(path, "/")) if (STRNEQ(path, "/"))
return -ENOENT; return -ENOENT;
filler(buf, ".", NULL, 0); filler(buf, ".", NULL, 0);
@ -103,7 +103,7 @@ static int lxcProcReaddir(const char *path, void *buf,
static int lxcProcOpen(const char *path ATTRIBUTE_UNUSED, static int lxcProcOpen(const char *path ATTRIBUTE_UNUSED,
struct fuse_file_info *fi ATTRIBUTE_UNUSED) struct fuse_file_info *fi ATTRIBUTE_UNUSED)
{ {
if (!STREQ(path, fuse_meminfo_path)) if (STRNEQ(path, fuse_meminfo_path))
return -ENOENT; return -ENOENT;
if ((fi->flags & 3) != O_RDONLY) if ((fi->flags & 3) != O_RDONLY)

View File

@ -2048,7 +2048,7 @@ openvzUpdateDevice(virDomainDefPtr vmdef,
cur = vmdef->fss[pos]; cur = vmdef->fss[pos];
/* We only allow updating the quota */ /* We only allow updating the quota */
if (!STREQ(cur->src, fs->src) if (STRNEQ(cur->src, fs->src)
|| cur->type != fs->type || cur->type != fs->type
|| cur->accessmode != fs->accessmode || cur->accessmode != fs->accessmode
|| cur->wrpolicy != fs->wrpolicy || cur->wrpolicy != fs->wrpolicy

View File

@ -3008,7 +3008,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
if (transp) if (transp)
*transp++ = 0; *transp++ = 0;
if (!STREQ(uri->scheme, scheme)) { if (STRNEQ(uri->scheme, scheme)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid transport/scheme '%s'"), uri->scheme); _("Invalid transport/scheme '%s'"), uri->scheme);
goto error; goto error;
@ -10027,7 +10027,7 @@ qemuBuildCommandLine(virConnectPtr conn,
virDomainDiskDefPtr disk = def->disks[i]; virDomainDiskDefPtr disk = def->disks[i];
if (disk->src->driverName != NULL && if (disk->src->driverName != NULL &&
!STREQ(disk->src->driverName, "qemu")) { STRNEQ(disk->src->driverName, "qemu")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported driver name '%s' for disk '%s'"), _("unsupported driver name '%s' for disk '%s'"),
disk->src->driverName, disk->src->path); disk->src->driverName, disk->src->path);
@ -12725,7 +12725,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
if (VIR_STRDUP(model, tokens[i]) < 0) if (VIR_STRDUP(model, tokens[i]) < 0)
goto cleanup; goto cleanup;
if (!STREQ(model, "qemu32") && !STREQ(model, "qemu64")) { if (STRNEQ(model, "qemu32") && STRNEQ(model, "qemu64")) {
if (!(cpu = qemuInitGuestCPU(dom))) if (!(cpu = qemuInitGuestCPU(dom)))
goto cleanup; goto cleanup;

View File

@ -1061,7 +1061,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
if (!STRPREFIX(def->os.machine, "pc-0.") && if (!STRPREFIX(def->os.machine, "pc-0.") &&
!STRPREFIX(def->os.machine, "pc-1.") && !STRPREFIX(def->os.machine, "pc-1.") &&
!STRPREFIX(def->os.machine, "pc-i440") && !STRPREFIX(def->os.machine, "pc-i440") &&
!STREQ(def->os.machine, "pc") && STRNEQ(def->os.machine, "pc") &&
!STRPREFIX(def->os.machine, "rhel")) !STRPREFIX(def->os.machine, "rhel"))
break; break;
addPCIRoot = true; addPCIRoot = true;

View File

@ -783,7 +783,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
const char *driverName = virDomainDiskGetDriver(disk); const char *driverName = virDomainDiskGetDriver(disk);
const char *src = virDomainDiskGetSource(disk); const char *src = virDomainDiskGetSource(disk);
if (driverName && !STREQ(driverName, "qemu")) { if (driverName && STRNEQ(driverName, "qemu")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported driver name '%s' for disk '%s'"), _("unsupported driver name '%s' for disk '%s'"),
driverName, src); driverName, src);

View File

@ -130,7 +130,7 @@ int
virSecurityManagerStackAddNested(virSecurityManagerPtr stack, virSecurityManagerStackAddNested(virSecurityManagerPtr stack,
virSecurityManagerPtr nested) virSecurityManagerPtr nested)
{ {
if (!STREQ("stack", stack->drv->name)) if (STRNEQ("stack", stack->drv->name))
return -1; return -1;
return virSecurityStackAddNested(stack, nested); return virSecurityStackAddNested(stack, nested);
} }

View File

@ -2061,7 +2061,7 @@ virSecuritySELinuxSecurityVerify(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
if (secdef == NULL) if (secdef == NULL)
return 0; return 0;
if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) { if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: " _("security label driver mismatch: "
"'%s' model configured for domain, but " "'%s' model configured for domain, but "
@ -2092,7 +2092,7 @@ virSecuritySELinuxSetSecurityProcessLabel(virSecurityManagerPtr mgr ATTRIBUTE_UN
return 0; return 0;
VIR_DEBUG("label=%s", secdef->label); VIR_DEBUG("label=%s", secdef->label);
if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) { if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: " _("security label driver mismatch: "
"'%s' model configured for domain, but " "'%s' model configured for domain, but "
@ -2126,7 +2126,7 @@ virSecuritySELinuxSetSecurityChildProcessLabel(virSecurityManagerPtr mgr ATTRIBU
return 0; return 0;
VIR_DEBUG("label=%s", secdef->label); VIR_DEBUG("label=%s", secdef->label);
if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) { if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: " _("security label driver mismatch: "
"'%s' model configured for domain, but " "'%s' model configured for domain, but "
@ -2155,7 +2155,7 @@ virSecuritySELinuxSetSecurityDaemonSocketLabel(virSecurityManagerPtr mgr ATTRIBU
if (!secdef || !secdef->label) if (!secdef || !secdef->label)
return 0; return 0;
if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) { if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: " _("security label driver mismatch: "
"'%s' model configured for domain, but " "'%s' model configured for domain, but "
@ -2202,7 +2202,7 @@ virSecuritySELinuxSetSecuritySocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNU
if (!secdef || !secdef->label) if (!secdef || !secdef->label)
return 0; return 0;
if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) { if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: " _("security label driver mismatch: "
"'%s' model configured for domain, but " "'%s' model configured for domain, but "
@ -2240,7 +2240,7 @@ virSecuritySELinuxClearSecuritySocketLabel(virSecurityManagerPtr mgr ATTRIBUTE_U
if (!secdef || !secdef->label) if (!secdef || !secdef->label)
return 0; return 0;
if (!STREQ(SECURITY_SELINUX_NAME, secdef->model)) { if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: " _("security label driver mismatch: "
"'%s' model configured for domain, but " "'%s' model configured for domain, but "

View File

@ -147,7 +147,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
* (lvs outputs "[$lvname_vorigin] for field "origin" if the * (lvs outputs "[$lvname_vorigin] for field "origin" if the
* lv is created with "--virtualsize"). * lv is created with "--virtualsize").
*/ */
if (groups[1] && !STREQ(groups[1], "") && (groups[1][0] != '[')) { if (groups[1] && STRNEQ(groups[1], "") && (groups[1][0] != '[')) {
if (VIR_ALLOC(vol->target.backingStore) < 0) if (VIR_ALLOC(vol->target.backingStore) < 0)
goto cleanup; goto cleanup;

View File

@ -1008,7 +1008,7 @@ virFileStripSuffix(char *str, const char *suffix)
if (len < suffixlen) if (len < suffixlen)
return 0; return 0;
if (!STREQ(str + len - suffixlen, suffix)) if (STRNEQ(str + len - suffixlen, suffix))
return 0; return 0;
str[len-suffixlen] = '\0'; str[len-suffixlen] = '\0';

View File

@ -375,7 +375,7 @@ int virSystemdTerminateMachine(const char *name,
goto cleanup; goto cleanup;
if (error.code == VIR_ERR_ERROR && if (error.code == VIR_ERR_ERROR &&
!STREQ_NULLABLE("org.freedesktop.machine1.NoSuchMachine", STRNEQ_NULLABLE("org.freedesktop.machine1.NoSuchMachine",
error.str1)) { error.str1)) {
virReportErrorObject(&error); virReportErrorObject(&error);
goto cleanup; goto cleanup;

View File

@ -300,7 +300,7 @@ vzConnectOpen(virConnectPtr conn,
return VIR_DRV_OPEN_DECLINED; return VIR_DRV_OPEN_DECLINED;
/* From this point on, the connection is for us. */ /* From this point on, the connection is for us. */
if (!STREQ_NULLABLE(conn->uri->path, "/system")) { if (STRNEQ_NULLABLE(conn->uri->path, "/system")) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected Virtuozzo URI path '%s', try vz:///system"), _("Unexpected Virtuozzo URI path '%s', try vz:///system"),
conn->uri->path); conn->uri->path);

View File

@ -2026,7 +2026,7 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr def)
} }
} else { } else {
if (def->os.nBootDevs != 0 || if (def->os.nBootDevs != 0 ||
!STREQ_NULLABLE(def->os.init, "/sbin/init") || STRNEQ_NULLABLE(def->os.init, "/sbin/init") ||
(def->os.initargv != NULL && def->os.initargv[0] != NULL)) { (def->os.initargv != NULL && def->os.initargv[0] != NULL)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",

View File

@ -2552,7 +2552,7 @@ xenDaemonDomainSetAutostart(virConnectPtr conn,
if (autonode) { if (autonode) {
const char *val = (autonode->u.s.car->kind == SEXPR_VALUE const char *val = (autonode->u.s.car->kind == SEXPR_VALUE
? autonode->u.s.car->u.value : NULL); ? autonode->u.s.car->u.value : NULL);
if (!val || (!STREQ(val, "ignore") && !STREQ(val, "start"))) { if (!val || (STRNEQ(val, "ignore") && STRNEQ(val, "start"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("unexpected value from on_xend_start")); "%s", _("unexpected value from on_xend_start"));
goto error; goto error;

View File

@ -2345,7 +2345,7 @@ xenFormatSxpr(virConnectPtr conn,
/* Only xend <= 3.0.2 wants cdrom config here */ /* Only xend <= 3.0.2 wants cdrom config here */
if (xendConfigVersion != XEND_CONFIG_VERSION_3_0_2) if (xendConfigVersion != XEND_CONFIG_VERSION_3_0_2)
break; break;
if (!STREQ(def->disks[i]->dst, "hdc") || !src) if (STRNEQ(def->disks[i]->dst, "hdc") || !src)
break; break;
virBufferEscapeSexpr(&buf, "(cdrom '%s')", src); virBufferEscapeSexpr(&buf, "(cdrom '%s')", src);

View File

@ -516,7 +516,7 @@ static int test13(const void *unused ATTRIBUTE_UNUSED)
virCommandFree(cmd); virCommandFree(cmd);
cmd = NULL; cmd = NULL;
if (!STREQ(outactual, outexpect)) { if (STRNEQ(outactual, outexpect)) {
virtTestDifference(stderr, outexpect, outactual); virtTestDifference(stderr, outexpect, outactual);
goto cleanup; goto cleanup;
} }
@ -580,15 +580,15 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
if (!jointactual) if (!jointactual)
goto cleanup; goto cleanup;
if (!STREQ(outactual, outexpect)) { if (STRNEQ(outactual, outexpect)) {
virtTestDifference(stderr, outexpect, outactual); virtTestDifference(stderr, outexpect, outactual);
goto cleanup; goto cleanup;
} }
if (!STREQ(erractual, errexpect)) { if (STRNEQ(erractual, errexpect)) {
virtTestDifference(stderr, errexpect, erractual); virtTestDifference(stderr, errexpect, erractual);
goto cleanup; goto cleanup;
} }
if (!STREQ(jointactual, jointexpect)) { if (STRNEQ(jointactual, jointexpect)) {
virtTestDifference(stderr, jointexpect, jointactual); virtTestDifference(stderr, jointexpect, jointactual);
goto cleanup; goto cleanup;
} }
@ -666,7 +666,7 @@ static int test16(const void *unused ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
} }
if (!STREQ(outactual, outexpect)) { if (STRNEQ(outactual, outexpect)) {
virtTestDifference(stderr, outexpect, outactual); virtTestDifference(stderr, outexpect, outactual);
goto cleanup; goto cleanup;
} }

View File

@ -282,7 +282,7 @@ testSELinuxCheckLabels(testSELinuxFile *files, size_t nfiles)
return -1; return -1;
} }
} }
if (!STREQ_NULLABLE(files[i].context, ctx)) { if (STRNEQ_NULLABLE(files[i].context, ctx)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"File %s context '%s' did not match epected '%s'", "File %s context '%s' did not match epected '%s'",
files[i].file, ctx, files[i].context); files[i].file, ctx, files[i].context);

View File

@ -60,7 +60,7 @@ static int testAuthLookup(const void *args)
if (data->expect) { if (data->expect) {
if (!actual || if (!actual ||
!STREQ(actual, data->expect)) { STRNEQ(actual, data->expect)) {
VIR_WARN("Expected value '%s' for '%s' '%s' '%s', but got '%s'", VIR_WARN("Expected value '%s' for '%s' '%s' '%s', but got '%s'",
data->expect, data->hostname, data->expect, data->hostname,
data->service, data->credname, data->service, data->credname,

View File

@ -355,7 +355,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str) if (!str)
goto error; goto error;
if (!STREQ(str, "")) if (STRNEQ(str, ""))
goto error; goto error;
VIR_FREE(str); VIR_FREE(str);
@ -365,7 +365,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str) if (!str)
goto error; goto error;
if (!STREQ(str, "0")) if (STRNEQ(str, "0"))
goto error; goto error;
VIR_FREE(str); VIR_FREE(str);
@ -376,7 +376,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str) if (!str)
goto error; goto error;
if (!STREQ(str, "0,4-5")) if (STRNEQ(str, "0,4-5"))
goto error; goto error;
VIR_FREE(str); VIR_FREE(str);
@ -386,7 +386,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str) if (!str)
goto error; goto error;
if (!STREQ(str, "0,4-6")) if (STRNEQ(str, "0,4-6"))
goto error; goto error;
VIR_FREE(str); VIR_FREE(str);
@ -399,7 +399,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str) if (!str)
goto error; goto error;
if (!STREQ(str, "0,4-6,13-16")) if (STRNEQ(str, "0,4-6,13-16"))
goto error; goto error;
VIR_FREE(str); VIR_FREE(str);
@ -410,7 +410,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
if (!str) if (!str)
goto error; goto error;
if (!STREQ(str, "0,4-6,13-16,62-63")) if (STRNEQ(str, "0,4-6,13-16,62-63"))
goto error; goto error;

View File

@ -662,7 +662,7 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
} }
for (i = 0; i < EXPECTED_NCPUS; i++) { for (i = 0; i < EXPECTED_NCPUS; i++) {
if (!STREQ(params[i].field, VIR_DOMAIN_CPU_STATS_CPUTIME)) { if (STRNEQ(params[i].field, VIR_DOMAIN_CPU_STATS_CPUTIME)) {
fprintf(stderr, fprintf(stderr,
"Wrong parameter name value from virCgroupGetPercpuStats at %zu (is: %s)\n", "Wrong parameter name value from virCgroupGetPercpuStats at %zu (is: %s)\n",
i, params[i].field); i, params[i].field);

View File

@ -70,17 +70,17 @@ static int testParse(const void *args ATTRIBUTE_UNUSED)
VIR_DEBUG("Missing Value 'Foo.three'"); VIR_DEBUG("Missing Value 'Foo.three'");
goto cleanup; goto cleanup;
} }
if (!STREQ(virKeyFileGetValueString(kf, "Foo", "one"), if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "one"),
"The first entry is here")) { "The first entry is here")) {
VIR_DEBUG("Wrong value for 'Foo.one'"); VIR_DEBUG("Wrong value for 'Foo.one'");
goto cleanup; goto cleanup;
} }
if (!STREQ(virKeyFileGetValueString(kf, "Foo", "two"), if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "two"),
"The second entry")) { "The second entry")) {
VIR_DEBUG("Wrong value for 'Foo.one'"); VIR_DEBUG("Wrong value for 'Foo.one'");
goto cleanup; goto cleanup;
} }
if (!STREQ(virKeyFileGetValueString(kf, "Foo", "three"), if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "three"),
"The third entry")) { "The third entry")) {
VIR_DEBUG("Wrong value for 'Foo.one'"); VIR_DEBUG("Wrong value for 'Foo.one'");
goto cleanup; goto cleanup;
@ -94,7 +94,7 @@ static int testParse(const void *args ATTRIBUTE_UNUSED)
VIR_DEBUG("Missing Value 'Bar.one'"); VIR_DEBUG("Missing Value 'Bar.one'");
goto cleanup; goto cleanup;
} }
if (!STREQ(virKeyFileGetValueString(kf, "Bar", "one"), if (STRNEQ(virKeyFileGetValueString(kf, "Bar", "one"),
"The first entry in second group")) { "The first entry in second group")) {
VIR_DEBUG("Wrong value for 'Bar.one'"); VIR_DEBUG("Wrong value for 'Bar.one'");
goto cleanup; goto cleanup;

View File

@ -406,7 +406,7 @@ static int testSocketSSH(const void *opaque)
} }
buf[rv] = '\0'; buf[rv] = '\0';
if (!STREQ(buf, data->expectOut)) { if (STRNEQ(buf, data->expectOut)) {
virtTestDifference(stderr, data->expectOut, buf); virtTestDifference(stderr, data->expectOut, buf);
goto cleanup; goto cleanup;
} }

View File

@ -188,7 +188,7 @@ testTypedParamsGetStringList(const void *opaque ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
continue; continue;
} }
if (!STREQLEN(strings[i], "bar", 3)) if (STRNEQLEN(strings[i], "bar", 3))
goto cleanup; goto cleanup;
if (strings[i][3] != l++) if (strings[i][3] != l++)
goto cleanup; goto cleanup;

View File

@ -58,13 +58,13 @@ static int testURIParse(const void *args)
if (!(uri = virURIParse(data->uri))) if (!(uri = virURIParse(data->uri)))
goto cleanup; goto cleanup;
if (!STREQ(uri->scheme, data->scheme)) { if (STRNEQ(uri->scheme, data->scheme)) {
VIR_DEBUG("Expected scheme '%s', actual '%s'", VIR_DEBUG("Expected scheme '%s', actual '%s'",
data->scheme, uri->scheme); data->scheme, uri->scheme);
goto cleanup; goto cleanup;
} }
if (!STREQ(uri->server, data->server)) { if (STRNEQ(uri->server, data->server)) {
VIR_DEBUG("Expected server '%s', actual '%s'", VIR_DEBUG("Expected server '%s', actual '%s'",
data->server, uri->server); data->server, uri->server);
goto cleanup; goto cleanup;
@ -76,31 +76,31 @@ static int testURIParse(const void *args)
goto cleanup; goto cleanup;
} }
if (!STREQ_NULLABLE(uri->path, data->path)) { if (STRNEQ_NULLABLE(uri->path, data->path)) {
VIR_DEBUG("Expected path '%s', actual '%s'", VIR_DEBUG("Expected path '%s', actual '%s'",
data->path, uri->path); data->path, uri->path);
goto cleanup; goto cleanup;
} }
if (!STREQ_NULLABLE(uri->query, data->query)) { if (STRNEQ_NULLABLE(uri->query, data->query)) {
VIR_DEBUG("Expected query '%s', actual '%s'", VIR_DEBUG("Expected query '%s', actual '%s'",
data->query, uri->query); data->query, uri->query);
goto cleanup; goto cleanup;
} }
if (!STREQ_NULLABLE(uri->fragment, data->fragment)) { if (STRNEQ_NULLABLE(uri->fragment, data->fragment)) {
VIR_DEBUG("Expected fragment '%s', actual '%s'", VIR_DEBUG("Expected fragment '%s', actual '%s'",
data->fragment, uri->fragment); data->fragment, uri->fragment);
goto cleanup; goto cleanup;
} }
for (i = 0; data->params && data->params[i].name && i < uri->paramsCount; i++) { for (i = 0; data->params && data->params[i].name && i < uri->paramsCount; i++) {
if (!STREQ_NULLABLE(data->params[i].name, uri->params[i].name)) { if (STRNEQ_NULLABLE(data->params[i].name, uri->params[i].name)) {
VIR_DEBUG("Expected param name %zu '%s', actual '%s'", VIR_DEBUG("Expected param name %zu '%s', actual '%s'",
i, data->params[i].name, uri->params[i].name); i, data->params[i].name, uri->params[i].name);
goto cleanup; goto cleanup;
} }
if (!STREQ_NULLABLE(data->params[i].value, uri->params[i].value)) { if (STRNEQ_NULLABLE(data->params[i].value, uri->params[i].value)) {
VIR_DEBUG("Expected param value %zu '%s', actual '%s'", VIR_DEBUG("Expected param value %zu '%s', actual '%s'",
i, data->params[i].value, uri->params[i].value); i, data->params[i].value, uri->params[i].value);
goto cleanup; goto cleanup;
@ -123,7 +123,7 @@ static int testURIParse(const void *args)
if (!(uristr = virURIFormat(uri))) if (!(uristr = virURIFormat(uri)))
goto cleanup; goto cleanup;
if (!STREQ(uristr, data->uri_out)) { if (STRNEQ(uristr, data->uri_out)) {
VIR_DEBUG("URI did not roundtrip, expect '%s', actual '%s'", VIR_DEBUG("URI did not roundtrip, expect '%s', actual '%s'",
data->uri_out, uristr); data->uri_out, uristr);
goto cleanup; goto cleanup;