[libvirt] [PATCH 01/14] tests: utils: Tolerate NULL actual data in virTestCompareToFile

Ján Tomko jtomko at redhat.com
Sat Mar 31 11:01:13 UTC 2018


On Thu, Mar 29, 2018 at 01:50:58PM +0200, Peter Krempa wrote:
>The function docs state that 'strcontent' may be NULL, but code added in
>3506f1ecfde did not use the 'cmpcontent' variable which was fixed and
>dereferenced it.

easier to follow as:

3506f1ecfde dereferenced it instead of using the fixed 'cmpcontent'
variable.

>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> tests/testutils.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/tests/testutils.c b/tests/testutils.c
>index 040ef1d2f7..4bd1b63755 100644
>--- a/tests/testutils.c
>+++ b/tests/testutils.c
>@@ -800,8 +800,8 @@ virTestCompareToFile(const char *strcontent,
>
>         if (filecontentLen > 0 &&
>             filecontent[filecontentLen - 1] == '\n' &&
>-            strcontent[strlen(strcontent) - 1] != '\n') {
>-            if (virAsprintf(&fixedcontent, "%s\n", strcontent) < 0)
>+            cmpcontent[strlen(cmpcontent) - 1] != '\n') {
>+            if (virAsprintf(&fixedcontent, "%s\n", cmpcontent) < 0)

ACK if you check if strlen(cmpcontent) > 0 as well.

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180331/008685ce/attachment-0001.sig>


More information about the libvir-list mailing list