Current-Users archive

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

Re: uninitilized variables with -O1



Am 08.04.2014 05:18, schrieb Takahiro HAYASHI:
> gcc points out two uninitialized variables while building current
> amd64 kernel with makeoptions COPTS="-O1 -fno-omit-frame-pointer",
> but does not complain about these with "-O2 -fno-omit-frame-pointer".
> 
> BTW we should check if initial values are correct.
> 
> Index: src/sys/arch/x86/x86/sys_machdep.c
> ===================================================================
> RCS file: /cvsroot/src/sys/arch/x86/x86/sys_machdep.c,v
> retrieving revision 1.27
> diff -u -p -r1.27 sys_machdep.c
> --- src/sys/arch/x86/x86/sys_machdep.c    20 Mar 2014 20:44:42 -0000   
> 1.27
> +++ src/sys/arch/x86/x86/sys_machdep.c    31 Mar 2014 11:41:17 -0000
> @@ -659,7 +659,7 @@ x86_set_sdbase(void *arg, char which, lw
>  #else
>      struct pcb *pcb;
>      vaddr_t base;
> -    int error;
> +    int error = 0;
>  
>      if (l->l_proc->p_flag & PK_32) {
>          return x86_set_sdbase32(arg, which, l, direct);
> Index: src/sys/dev/usb/xhci.c
> ===================================================================
> RCS file: /cvsroot/src/sys/dev/usb/xhci.c,v
> retrieving revision 1.16
> diff -u -p -r1.16 xhci.c
> --- src/sys/dev/usb/xhci.c    10 Mar 2014 13:21:22 -0000    1.16
> +++ src/sys/dev/usb/xhci.c    31 Mar 2014 11:59:04 -0000
> @@ -356,7 +356,7 @@ xhci_db_write_4(const struct xhci_softc
>  static inline uint8_t
>  xhci_ep_get_type(usb_endpoint_descriptor_t * const ed)
>  {
> -    u_int eptype;
> +    u_int eptype = 0;
>  
>      switch (UE_GET_XFERTYPE(ed->bmAttributes)) {
>      case UE_CONTROL:
> 

I think sys_machdep.c can be changed to:

diff -u -p -r1.27 sys_machdep.c
--- sys/arch/x86/x86/sys_machdep.c      20 Mar 2014 20:44:42 -0000 1.27
+++ sys/arch/x86/x86/sys_machdep.c      8 Apr 2014 11:16:29 -0000
@@ -676,10 +676,6 @@ x86_set_sdbase(void *arg, char which, lw
        if (base >= VM_MAXUSER_ADDRESS)
                return EINVAL;

-       if (error) {
-               return error;
-       }
-
        pcb = lwp_getpcb(l);

        kpreempt_disable();
@@ -699,7 +695,7 @@ x86_set_sdbase(void *arg, char which, lw
        }
        kpreempt_enable();

-       return error;
+       return 0;
 #endif
 }

Index: sys/arch/x86/x86/sys_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/sys_machdep.c,v
retrieving revision 1.27
diff -u -p -r1.27 sys_machdep.c
--- sys/arch/x86/x86/sys_machdep.c      20 Mar 2014 20:44:42 -0000      1.27
+++ sys/arch/x86/x86/sys_machdep.c      8 Apr 2014 11:16:29 -0000
@@ -676,10 +676,6 @@ x86_set_sdbase(void *arg, char which, lw
        if (base >= VM_MAXUSER_ADDRESS)
                return EINVAL;
 
-       if (error) {
-               return error;
-       }
-
        pcb = lwp_getpcb(l);
 
        kpreempt_disable();
@@ -699,7 +695,7 @@ x86_set_sdbase(void *arg, char which, lw
        }
        kpreempt_enable();
 
-       return error;
+       return 0;
 #endif
 }
 


Home | Main Index | Thread Index | Old Index