[PATCH 3/7] x86/sysctl: Make arch_do_sysctl() compile at -Og

Andrew Cooper posted 7 patches 4 years, 9 months ago
[PATCH 3/7] x86/sysctl: Make arch_do_sysctl() compile at -Og
Posted by Andrew Cooper 4 years, 9 months ago
When compiling at -Og:

  sysctl.c: In function ‘arch_do_sysctl’:
  sysctl.c:197:19: error: ‘hcpu’ may be used uninitialized in this function[-Werror=maybe-uninitialized]
               ret = continue_hypercall_on_cpu(0, fn, hcpu);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  sysctl.c: In function ‘arch_do_sysctl’:
  sysctl.c:197:19: error: ‘fn’ may be used uninitialized in this function[-Werror=maybe-uninitialized]
               ret = continue_hypercall_on_cpu(0, fn, hcpu);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

These look to be caused by insufficient analysis around the !ret conditionals.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wl@xen.org>
---
 xen/arch/x86/sysctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index aff52a13f3..6ac09bac79 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -150,8 +150,8 @@ long arch_do_sysctl(
         unsigned int cpu = sysctl->u.cpu_hotplug.cpu;
         unsigned int op  = sysctl->u.cpu_hotplug.op;
         bool plug;
-        long (*fn)(void *);
-        void *hcpu;
+        long (*fn)(void *) = NULL;
+        void *hcpu = NULL;
 
         switch ( op )
         {
-- 
2.11.0