]> xenbits.xensource.com Git - xen.git/commitdiff
stubdom/xenstored: Fix uninitialised variables in lu_read_state()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 11 Feb 2021 21:10:51 +0000 (21:10 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 17 Feb 2021 12:37:08 +0000 (12:37 +0000)
Various version of gcc, when compiling with -Og, complain:

  xenstored_control.c: In function ‘lu_read_state’:
  xenstored_control.c:540:11: error: ‘state.size’ is used uninitialized in this
  function [-Werror=uninitialized]
    if (state.size == 0)
        ~~~~~^~~~~
  xenstored_control.c:543:6: error: ‘state.buf’ may be used uninitialized in
  this function [-Werror=maybe-uninitialized]
    pre = state.buf;
    ~~~~^~~~~~~~~~~
  xenstored_control.c:550:23: error: ‘state.buf’ may be used uninitialized in
  this function [-Werror=maybe-uninitialized]
     (void *)head - state.buf < state.size;
                    ~~~~~^~~~
  xenstored_control.c:550:35: error: ‘state.size’ may be used uninitialized in
  this function [-Werror=maybe-uninitialized]
     (void *)head - state.buf < state.size;
                                ~~~~~^~~~~

for the stubdom build.  This is because lu_get_dump_state() is a no-op stub in
MiniOS, and state really is operated on uninitialised.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Ian Jackson <iwj@xenproject.org>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
tools/xenstore/xenstored_control.c

index 1f733e0a04a60789f49c2b2b4b172ddaee129b2f..f10beaf85eb49ce8102d52d406f096e8a3c8a44e 100644 (file)
@@ -530,7 +530,7 @@ static const char *lu_dump_state(const void *ctx, struct connection *conn)
 
 void lu_read_state(void)
 {
-       struct lu_dump_state state;
+       struct lu_dump_state state = {};
        struct xs_state_record_header *head;
        void *ctx = talloc_new(NULL); /* Work context for subfunctions. */
        struct xs_state_preamble *pre;