mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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:
committed by
Michal Privoznik
parent
1b4de77e85
commit
32cee5b2f0
@@ -516,7 +516,7 @@ static int test13(const void *unused ATTRIBUTE_UNUSED)
|
||||
virCommandFree(cmd);
|
||||
cmd = NULL;
|
||||
|
||||
if (!STREQ(outactual, outexpect)) {
|
||||
if (STRNEQ(outactual, outexpect)) {
|
||||
virtTestDifference(stderr, outexpect, outactual);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -580,15 +580,15 @@ static int test14(const void *unused ATTRIBUTE_UNUSED)
|
||||
if (!jointactual)
|
||||
goto cleanup;
|
||||
|
||||
if (!STREQ(outactual, outexpect)) {
|
||||
if (STRNEQ(outactual, outexpect)) {
|
||||
virtTestDifference(stderr, outexpect, outactual);
|
||||
goto cleanup;
|
||||
}
|
||||
if (!STREQ(erractual, errexpect)) {
|
||||
if (STRNEQ(erractual, errexpect)) {
|
||||
virtTestDifference(stderr, errexpect, erractual);
|
||||
goto cleanup;
|
||||
}
|
||||
if (!STREQ(jointactual, jointexpect)) {
|
||||
if (STRNEQ(jointactual, jointexpect)) {
|
||||
virtTestDifference(stderr, jointexpect, jointactual);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -666,7 +666,7 @@ static int test16(const void *unused ATTRIBUTE_UNUSED)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!STREQ(outactual, outexpect)) {
|
||||
if (STRNEQ(outactual, outexpect)) {
|
||||
virtTestDifference(stderr, outexpect, outactual);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ testSELinuxCheckLabels(testSELinuxFile *files, size_t nfiles)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!STREQ_NULLABLE(files[i].context, ctx)) {
|
||||
if (STRNEQ_NULLABLE(files[i].context, ctx)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"File %s context '%s' did not match epected '%s'",
|
||||
files[i].file, ctx, files[i].context);
|
||||
|
||||
@@ -60,7 +60,7 @@ static int testAuthLookup(const void *args)
|
||||
|
||||
if (data->expect) {
|
||||
if (!actual ||
|
||||
!STREQ(actual, data->expect)) {
|
||||
STRNEQ(actual, data->expect)) {
|
||||
VIR_WARN("Expected value '%s' for '%s' '%s' '%s', but got '%s'",
|
||||
data->expect, data->hostname,
|
||||
data->service, data->credname,
|
||||
|
||||
@@ -355,7 +355,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
|
||||
if (!str)
|
||||
goto error;
|
||||
|
||||
if (!STREQ(str, ""))
|
||||
if (STRNEQ(str, ""))
|
||||
goto error;
|
||||
|
||||
VIR_FREE(str);
|
||||
@@ -365,7 +365,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
|
||||
if (!str)
|
||||
goto error;
|
||||
|
||||
if (!STREQ(str, "0"))
|
||||
if (STRNEQ(str, "0"))
|
||||
goto error;
|
||||
|
||||
VIR_FREE(str);
|
||||
@@ -376,7 +376,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
|
||||
if (!str)
|
||||
goto error;
|
||||
|
||||
if (!STREQ(str, "0,4-5"))
|
||||
if (STRNEQ(str, "0,4-5"))
|
||||
goto error;
|
||||
|
||||
VIR_FREE(str);
|
||||
@@ -386,7 +386,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
|
||||
if (!str)
|
||||
goto error;
|
||||
|
||||
if (!STREQ(str, "0,4-6"))
|
||||
if (STRNEQ(str, "0,4-6"))
|
||||
goto error;
|
||||
|
||||
VIR_FREE(str);
|
||||
@@ -399,7 +399,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
|
||||
if (!str)
|
||||
goto error;
|
||||
|
||||
if (!STREQ(str, "0,4-6,13-16"))
|
||||
if (STRNEQ(str, "0,4-6,13-16"))
|
||||
goto error;
|
||||
|
||||
VIR_FREE(str);
|
||||
@@ -410,7 +410,7 @@ test6(const void *v ATTRIBUTE_UNUSED)
|
||||
if (!str)
|
||||
goto error;
|
||||
|
||||
if (!STREQ(str, "0,4-6,13-16,62-63"))
|
||||
if (STRNEQ(str, "0,4-6,13-16,62-63"))
|
||||
goto error;
|
||||
|
||||
|
||||
|
||||
@@ -662,7 +662,7 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
|
||||
}
|
||||
|
||||
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,
|
||||
"Wrong parameter name value from virCgroupGetPercpuStats at %zu (is: %s)\n",
|
||||
i, params[i].field);
|
||||
|
||||
@@ -70,17 +70,17 @@ static int testParse(const void *args ATTRIBUTE_UNUSED)
|
||||
VIR_DEBUG("Missing Value 'Foo.three'");
|
||||
goto cleanup;
|
||||
}
|
||||
if (!STREQ(virKeyFileGetValueString(kf, "Foo", "one"),
|
||||
if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "one"),
|
||||
"The first entry is here")) {
|
||||
VIR_DEBUG("Wrong value for 'Foo.one'");
|
||||
goto cleanup;
|
||||
}
|
||||
if (!STREQ(virKeyFileGetValueString(kf, "Foo", "two"),
|
||||
if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "two"),
|
||||
"The second entry")) {
|
||||
VIR_DEBUG("Wrong value for 'Foo.one'");
|
||||
goto cleanup;
|
||||
}
|
||||
if (!STREQ(virKeyFileGetValueString(kf, "Foo", "three"),
|
||||
if (STRNEQ(virKeyFileGetValueString(kf, "Foo", "three"),
|
||||
"The third entry")) {
|
||||
VIR_DEBUG("Wrong value for 'Foo.one'");
|
||||
goto cleanup;
|
||||
@@ -94,7 +94,7 @@ static int testParse(const void *args ATTRIBUTE_UNUSED)
|
||||
VIR_DEBUG("Missing Value 'Bar.one'");
|
||||
goto cleanup;
|
||||
}
|
||||
if (!STREQ(virKeyFileGetValueString(kf, "Bar", "one"),
|
||||
if (STRNEQ(virKeyFileGetValueString(kf, "Bar", "one"),
|
||||
"The first entry in second group")) {
|
||||
VIR_DEBUG("Wrong value for 'Bar.one'");
|
||||
goto cleanup;
|
||||
|
||||
@@ -406,7 +406,7 @@ static int testSocketSSH(const void *opaque)
|
||||
}
|
||||
buf[rv] = '\0';
|
||||
|
||||
if (!STREQ(buf, data->expectOut)) {
|
||||
if (STRNEQ(buf, data->expectOut)) {
|
||||
virtTestDifference(stderr, data->expectOut, buf);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ testTypedParamsGetStringList(const void *opaque ATTRIBUTE_UNUSED)
|
||||
goto cleanup;
|
||||
continue;
|
||||
}
|
||||
if (!STREQLEN(strings[i], "bar", 3))
|
||||
if (STRNEQLEN(strings[i], "bar", 3))
|
||||
goto cleanup;
|
||||
if (strings[i][3] != l++)
|
||||
goto cleanup;
|
||||
|
||||
@@ -58,13 +58,13 @@ static int testURIParse(const void *args)
|
||||
if (!(uri = virURIParse(data->uri)))
|
||||
goto cleanup;
|
||||
|
||||
if (!STREQ(uri->scheme, data->scheme)) {
|
||||
if (STRNEQ(uri->scheme, data->scheme)) {
|
||||
VIR_DEBUG("Expected scheme '%s', actual '%s'",
|
||||
data->scheme, uri->scheme);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!STREQ(uri->server, data->server)) {
|
||||
if (STRNEQ(uri->server, data->server)) {
|
||||
VIR_DEBUG("Expected server '%s', actual '%s'",
|
||||
data->server, uri->server);
|
||||
goto cleanup;
|
||||
@@ -76,31 +76,31 @@ static int testURIParse(const void *args)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!STREQ_NULLABLE(uri->path, data->path)) {
|
||||
if (STRNEQ_NULLABLE(uri->path, data->path)) {
|
||||
VIR_DEBUG("Expected path '%s', actual '%s'",
|
||||
data->path, uri->path);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!STREQ_NULLABLE(uri->query, data->query)) {
|
||||
if (STRNEQ_NULLABLE(uri->query, data->query)) {
|
||||
VIR_DEBUG("Expected query '%s', actual '%s'",
|
||||
data->query, uri->query);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!STREQ_NULLABLE(uri->fragment, data->fragment)) {
|
||||
if (STRNEQ_NULLABLE(uri->fragment, data->fragment)) {
|
||||
VIR_DEBUG("Expected fragment '%s', actual '%s'",
|
||||
data->fragment, uri->fragment);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
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'",
|
||||
i, data->params[i].name, uri->params[i].name);
|
||||
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'",
|
||||
i, data->params[i].value, uri->params[i].value);
|
||||
goto cleanup;
|
||||
@@ -123,7 +123,7 @@ static int testURIParse(const void *args)
|
||||
if (!(uristr = virURIFormat(uri)))
|
||||
goto cleanup;
|
||||
|
||||
if (!STREQ(uristr, data->uri_out)) {
|
||||
if (STRNEQ(uristr, data->uri_out)) {
|
||||
VIR_DEBUG("URI did not roundtrip, expect '%s', actual '%s'",
|
||||
data->uri_out, uristr);
|
||||
goto cleanup;
|
||||
|
||||
Reference in New Issue
Block a user