diff mbox

testutils: Fix coverity warning with REGENERATE_OUTPUT

Message ID 44366fb1b8ffc50d0fd8149a5b7fd6c6612e696d.1452614685.git.crobinso@redhat.com
State Accepted
Commit ebfd6f45c385bb04623479bab7a77beb3ffe167b
Headers show

Commit Message

Cole Robinson Jan. 12, 2016, 4:04 p.m. UTC
- 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(-)

-- 
2.5.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Cole Robinson Jan. 12, 2016, 4:35 p.m. UTC | #1
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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox

Patch

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;
         }