[libvirt PATCH v2 1/7] tests: Fix false positive in testConfRoundTrip.

Tim Wiederhake posted 7 patches 5 years, 4 months ago
[libvirt PATCH v2 1/7] tests: Fix false positive in testConfRoundTrip.
Posted by Tim Wiederhake 5 years, 4 months ago
testConfRoundTrip would return 0 (success) if virConfWriteMem returned 0 (nothing
written) and virTestCompareToFile failed.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
---
 tests/virconftest.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/virconftest.c b/tests/virconftest.c
index ab29b5b712..cac3718495 100644
--- a/tests/virconftest.c
+++ b/tests/virconftest.c
@@ -51,8 +51,7 @@ static int testConfRoundTrip(const void *opaque)
         fprintf(stderr, "Failed to process %s\n", srcfile);
         goto cleanup;
     }
-    ret = virConfWriteMem(buffer, &len, conf);
-    if (ret < 0) {
+    if (virConfWriteMem(buffer, &len, conf) < 0) {
         fprintf(stderr, "Failed to serialize %s back\n", srcfile);
         goto cleanup;
     }
-- 
2.26.2

Re: [libvirt PATCH v2 1/7] tests: Fix false positive in testConfRoundTrip.
Posted by Ján Tomko 5 years, 4 months ago
On a Monday in 2020, Tim Wiederhake wrote:
>testConfRoundTrip would return 0 (success) if virConfWriteMem returned 0 (nothing
>written) and virTestCompareToFile failed.
>

s/returned 0/succeeded/

The caller treats all non-negative values as a success. (as is usual in
the codebase)

Jano

>Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
>---
> tests/virconftest.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/tests/virconftest.c b/tests/virconftest.c
>index ab29b5b712..cac3718495 100644
>--- a/tests/virconftest.c
>+++ b/tests/virconftest.c
>@@ -51,8 +51,7 @@ static int testConfRoundTrip(const void *opaque)
>         fprintf(stderr, "Failed to process %s\n", srcfile);
>         goto cleanup;
>     }
>-    ret = virConfWriteMem(buffer, &len, conf);
>-    if (ret < 0) {
>+    if (virConfWriteMem(buffer, &len, conf) < 0) {
>         fprintf(stderr, "Failed to serialize %s back\n", srcfile);
>         goto cleanup;
>     }
>-- 
>2.26.2
>