]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
tools/ocaml: Fix build error with CentOS 7
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 10 Sep 2019 14:04:55 +0000 (15:04 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 10 Sep 2019 14:28:55 +0000 (15:28 +0100)
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28) complains:

  xenctrl_stubs.c: In function 'stub_xc_domain_create':
  xenctrl_stubs.c:216:28: error: 'val' may be used uninitialized
                          in this function [-Werror=maybe-uninitialized]
     cfg.arch.emulation_flags = ocaml_list_to_c_bitmap
                              ^
  xenctrl_stubs.c:198:12: error: 'val' may be used uninitialized
                          in this function [-Werror=maybe-uninitialized]
    cfg.flags = ocaml_list_to_c_bitmap
              ^
  cc1: all warnings being treated as errors

GCC doesn't point at the correct piece of code, but the diagnostic text is
correct, and can occur when the list is empty. Initialise val to 0.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/libs/xc/xenctrl_stubs.c

index f86ecc7b7ea67f74cbbfe0671823b38ed8385e59..d7bc2cf40d5e7cdf08cf8c2545d55e94aa46b18d 100644 (file)
@@ -160,7 +160,7 @@ static unsigned int ocaml_list_to_c_bitmap(value l)
              * for xenctrl_abi_check.  The parsing there is ad-hoc.
              */
 {
-       unsigned int val;
+       unsigned int val = 0;
 
        for ( ; l != Val_none; l = Field(l, 1) )
                val |= 1u << Int_val(Field(l, 0));