[libvirt] [PATCH] testutils: Fix coverity warning with REGENERATE_OUTPUT

- Don't double check for expectName - actual is always non-NULL by this point, so don't check it either --- tests/testutils.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 4ffea0c..b587f83 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -469,15 +469,14 @@ virtTestDifferenceFullInternal(FILE *stream, actualStart = actual; actualEnd = actual + (strlen(actual)-1); - if (regenerate && (virTestGetRegenerate() > 0) && expectName && actual) { + if (expectName && regenerate && (virTestGetRegenerate() > 0)) { char *regencontent; /* Try to properly indent qemu argv files */ if (!(regencontent = virStringReplace(actual, " -", " \\\n-"))) return -1; - if (expectName && actual && - virFileWriteStr(expectName, regencontent, 0666) < 0) { + if (virFileWriteStr(expectName, regencontent, 0666) < 0) { VIR_FREE(regencontent); return -1; } -- 2.5.0

On Tue, Jan 12, 2016 at 11:04:45AM -0500, Cole Robinson wrote:
- Don't double check for expectName - actual is always non-NULL by this point, so don't check it either --- tests/testutils.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
ACK and safe for freeze.

On 01/12/2016 11:04 AM, Cole Robinson wrote:
- Don't double check for expectName - actual is always non-NULL by this point, so don't check it either --- tests/testutils.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tests/testutils.c b/tests/testutils.c index 4ffea0c..b587f83 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -469,15 +469,14 @@ virtTestDifferenceFullInternal(FILE *stream, actualStart = actual; actualEnd = actual + (strlen(actual)-1);
- if (regenerate && (virTestGetRegenerate() > 0) && expectName && actual) { + if (expectName && regenerate && (virTestGetRegenerate() > 0)) { char *regencontent;
/* Try to properly indent qemu argv files */ if (!(regencontent = virStringReplace(actual, " -", " \\\n-"))) return -1;
- if (expectName && actual && - virFileWriteStr(expectName, regencontent, 0666) < 0) { + if (virFileWriteStr(expectName, regencontent, 0666) < 0) { VIR_FREE(regencontent); return -1; }
Double ACK ;-)... it resolves coverity issue too. John

On 01/12/2016 11:22 AM, John Ferlan wrote:
On 01/12/2016 11:04 AM, Cole Robinson wrote:
- Don't double check for expectName - actual is always non-NULL by this point, so don't check it either --- tests/testutils.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tests/testutils.c b/tests/testutils.c index 4ffea0c..b587f83 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -469,15 +469,14 @@ virtTestDifferenceFullInternal(FILE *stream, actualStart = actual; actualEnd = actual + (strlen(actual)-1);
- if (regenerate && (virTestGetRegenerate() > 0) && expectName && actual) { + if (expectName && regenerate && (virTestGetRegenerate() > 0)) { char *regencontent;
/* Try to properly indent qemu argv files */ if (!(regencontent = virStringReplace(actual, " -", " \\\n-"))) return -1;
- if (expectName && actual && - virFileWriteStr(expectName, regencontent, 0666) < 0) { + if (virFileWriteStr(expectName, regencontent, 0666) < 0) { VIR_FREE(regencontent); return -1; }
Double ACK ;-)... it resolves coverity issue too.
John
Thanks, pushed - Cole
participants (3)
-
Cole Robinson
-
John Ferlan
-
Martin Kletzander