[PATCH spice-server 06/10] tests: Avoid some possible not initialized warning from Clang

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not really possible but clang raise these warnings:

test-sasl.c:555:13: error: variable 'is_ok' is uninitialized when used here [-Werror,-Wuninitialized]
        if (is_ok) {
            ^~~~~
test-sasl.c:553:22: note: initialize the variable 'is_ok' to silence this warning
        uint8_t is_ok;
                     ^
                      = '\0'

test-gst.c:792:18: error: variable 'height' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
    spice_assert(gst_structure_get_int(s, "width", &width) &&
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../spice-common/common/log.h:91:17: note: expanded from macro 'spice_assert'
    if G_LIKELY(x) { } else {                           \
                ^
/usr/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
                                                           ^~~~
/usr/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
   if (expr)                                    \
       ^~~~
test-gst.c:799:17: note: uninitialized use occurs here
    bitmap->y = height;
                ^~~~~~
test-gst.c:792:18: note: remove the '&&' if its condition is always true
    spice_assert(gst_structure_get_int(s, "width", &width) &&
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../spice-common/common/log.h:91:17: note: expanded from macro 'spice_assert'
    if G_LIKELY(x) { } else {                           \
                ^
/usr/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
                                                           ^
/usr/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
   if (expr)                                    \
       ^
test-gst.c:791:23: note: initialize the variable 'height' to silence this warning
    gint width, height;
                      ^
                       = 0

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/tests/test-gst.c  | 2 +-
 server/tests/test-sasl.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/tests/test-gst.c b/server/tests/test-gst.c
index ecd6c49a..91ef92d6 100644
--- a/server/tests/test-gst.c
+++ b/server/tests/test-gst.c
@@ -788,7 +788,7 @@ gst_to_spice_bitmap(GstSample *sample)
     GstStructure *s = gst_caps_get_structure(caps, 0);
     spice_assert(s);
 
-    gint width, height;
+    gint width = 0, height = 0;
     spice_assert(gst_structure_get_int(s, "width", &width) &&
                  gst_structure_get_int(s, "height", &height));
 
diff --git a/server/tests/test-sasl.c b/server/tests/test-sasl.c
index 25ad79af..a620ec59 100644
--- a/server/tests/test-sasl.c
+++ b/server/tests/test-sasl.c
@@ -550,7 +550,7 @@ client_emulator(int sock)
         g_assert_cmpint(datalen, <=, sizeof(buf));
         read_all(sock, buf, datalen);
 
-        uint8_t is_ok;
+        uint8_t is_ok = 0;
         read_all(sock, &is_ok, sizeof(is_ok));
         if (is_ok) {
             // is_ok should be 0 or 1
-- 
2.14.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]