[libvirt PATCH] util: ensure min/maj are initialized in virGetDeviceID

Daniel P. Berrangé posted 1 patch 4 years, 1 month ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20200312184033.961421-1-berrange@redhat.com
src/util/virutil.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[libvirt PATCH] util: ensure min/maj are initialized in virGetDeviceID
Posted by Daniel P. Berrangé 4 years, 1 month ago
The stub impl of virGetDeviceID just returns ENOSYS and does not
initialize the min/maj output parameters. This lead to a false
positive warning on mingw about possible use of uninitialized
variables.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/util/virutil.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index f77ee05dbf..ddd8805101 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1407,9 +1407,10 @@ virGetDeviceID(const char *path, int *maj, int *min)
 #else
 int
 virGetDeviceID(const char *path G_GNUC_UNUSED,
-               int *maj G_GNUC_UNUSED,
-               int *min G_GNUC_UNUSED)
+               int *maj,
+               int *min)
 {
+    *maj = *min = 0;
     return -ENOSYS;
 }
 #endif
-- 
2.24.1

Re: [libvirt PATCH] util: ensure min/maj are initialized in virGetDeviceID
Posted by Ján Tomko 4 years, 1 month ago
On a Thursday in 2020, Daniel P. Berrangé wrote:
>The stub impl of virGetDeviceID just returns ENOSYS and does not
>initialize the min/maj output parameters. This lead to a false
>positive warning on mingw about possible use of uninitialized
>variables.
>
>Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
>---
> src/util/virutil.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano