[libvirt] [PATCH] tests: initialize some variables

Ján Tomko posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1842986f88af1fd159073a2e7e5ed952ba5693c4.1527667995.git.jtomko@redhat.com
Test syntax-check passed
tests/metadatatest.c    | 2 +-
tests/objecteventtest.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[libvirt] [PATCH] tests: initialize some variables
Posted by Ján Tomko 5 years, 10 months ago
Found by cppcheck:
[tests/metadatatest.c:284]: (error) Uninitialized variable: test
[tests/objecteventtest.c:855]: (error) Uninitialized variable: test

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 tests/metadatatest.c    | 2 +-
 tests/objecteventtest.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/metadatatest.c b/tests/metadatatest.c
index d5a6f37119..b17a85c883 100644
--- a/tests/metadatatest.c
+++ b/tests/metadatatest.c
@@ -268,7 +268,7 @@ testTextMetadata(const void *data)
 static int
 mymain(void)
 {
-    struct metadataTest test;
+    struct metadataTest test = { 0 };
     int ret = EXIT_SUCCESS;
 
     if (!(test.conn = virConnectOpen("test:///default")))
diff --git a/tests/objecteventtest.c b/tests/objecteventtest.c
index 4b12572eb4..e6de11ec39 100644
--- a/tests/objecteventtest.c
+++ b/tests/objecteventtest.c
@@ -835,7 +835,7 @@ timeout(int id ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED)
 static int
 mymain(void)
 {
-    objecteventTest test;
+    objecteventTest test = { 0 };
     int ret = EXIT_SUCCESS;
     int timer;
 
-- 
2.16.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: initialize some variables
Posted by Jiri Denemark 5 years, 10 months ago
On Wed, May 30, 2018 at 10:13:25 +0200, Ján Tomko wrote:
> Found by cppcheck:
> [tests/metadatatest.c:284]: (error) Uninitialized variable: test
> [tests/objecteventtest.c:855]: (error) Uninitialized variable: test
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>

Could have been pushed as trivial :-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

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