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

[xen staging] stubdom/xenstored: Fix uninitialised variables in lu_read_state()



commit 7a4133feaf42000923eb9d84badb6b171625f137
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Feb 11 21:10:51 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Feb 17 12:37:08 2021 +0000

    stubdom/xenstored: Fix uninitialised variables in lu_read_state()
    
    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@xxxxxxxxxx>
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
    Release-Acked-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
---
 tools/xenstore/xenstored_control.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/xenstore/xenstored_control.c 
b/tools/xenstore/xenstored_control.c
index 1f733e0a04..f10beaf85e 100644
--- a/tools/xenstore/xenstored_control.c
+++ b/tools/xenstore/xenstored_control.c
@@ -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;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.