[Spice-devel] [PATCH spice-server 06/10] tests: Avoid some possible not initialized warning from Clang
Frediano Ziglio
fziglio at redhat.com
Mon Jan 22 17:54:58 UTC 2018
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 at redhat.com>
---
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
More information about the Spice-devel
mailing list