Yonsm / rt-n56u

Padavan
180 stars 44 forks source link

Can these compile warnings be fixed? #8

Closed mia0x75 closed 4 years ago

mia0x75 commented 4 years ago

I see some warnings during compiling, and I wonder if these warnings can be fixed.

For example:

scripts/kconfig/confdata.c: In function ‘conf_write’:
scripts/kconfig/confdata.c:705:19: warning: ‘%s’ directive writing likely 7 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
  705 |  sprintf(newname, "%s%s", dirname, basename);
      |                   ^~~~~~
scripts/kconfig/confdata.c:705:19: note: assuming directive output of 7 bytes
scripts/kconfig/confdata.c:705:2: note: ‘sprintf’ output 1 or more bytes (assuming 4104) into a destination of size 4097
  705 |  sprintf(newname, "%s%s", dirname, basename);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/kconfig/confdata.c:708:20: warning: ‘.tmpconfig.’ directive writing 11 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
  708 |   sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
      |                    ^~~~~~~~~~~~~~~~~
scripts/kconfig/confdata.c:708:3: note: ‘sprintf’ output between 13 and 4119 bytes into a destination of size 4097
  708 |   sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c: In function 'RTMPAPSetInformation':
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4613:3: warning: 'cfg' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(cfg, (UCHAR **)&cfg, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4641:3: warning: 'cfg' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(cfg, (UCHAR **)&cfg, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4667:3: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(val, (UCHAR **)&val, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4690:3: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(val, (UCHAR **)&val, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4715:3: warning: 'cfg' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(cfg, (UCHAR **)&cfg, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4743:3: warning: 'cfg' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(cfg, (UCHAR **)&cfg, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4771:3: warning: 'cfg' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(cfg, (UCHAR **)&cfg, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4799:3: warning: 'cfg' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(cfg, (UCHAR **)&cfg, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/embedded/ap/ap_cfg.c:4991:3: warning: 'Buf' may be used uninitialized in this function [-Wmaybe-uninitialized]
   os_alloc_mem(Buf, (UCHAR **)&Buf, wrq->u.data.length);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/mt7615_ap/../mt7615/txpwr/single_sku.c: In function 'SKUTxPwrOffsetGet':
drivers/net/wireless/ralink/mt7615_ap/../mt7615/txpwr/single_sku.c:1839:85: warning: array subscript is below array bounds [-Warray-bounds]
  cPowerOffset = (fgSE) ? (pAd->CommonCfg.cTxPowerCompBackup[ucBandIdx][ucRateOffset][ucNSS - 1]) : (pAd->CommonCfg.cTxPowerCompBackup[ucBandIdx][ucRateOffset][3]);
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
net/netfilter/nf_conntrack_rtsp.c: In function 'help':
net/netfilter/nf_conntrack_rtsp.c:474:2: warning: enumeration value 'IP_CT_DIR_MAX' not handled in switch [-Wswitch]
  switch (CTINFO2DIR(ctinfo)) {
  ^~~~~~
./ldso/include/dl-syscall.h: In function '_dl_pread':
./ldso/include/dl-syscall.h:169:69: warning: right shift count >= width of type [-Wshift-count-overflow]
  return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR((offset >> 32), (offset & 0xffffffff)));
                                                                     ^
./include/endian.h:52:39: note: in definition of macro '__LONG_LONG_PAIR'
 # define __LONG_LONG_PAIR(HI, LO) LO, HI
                                       ^~
In file included from ldso/ldso/ldso.c:45:0:
ldso/ldso/mips/elfinterp.c: In function '_dl_parse_relocation_information':
ldso/ldso/mips/elfinterp.c:234:8: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
        if (!tls_tpnt)
        ^~
ldso/ldso/mips/elfinterp.c:237:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     switch (reloc_type) {
     ^~~~~~
In file included from ldso/ldso/ldso.c:86:0:
ldso/ldso/dl-startup.c: In function '_dl_start':
ldso/ldso/dl-startup.c:313:13: warning: variable 'strtab' set but not used [-Wunused-but-set-variable]
       char *strtab;
             ^~~~~~
In file included from libc/misc/fnmatch/fnmatch.c:235:0:
libc/misc/fnmatch/fnmatch_loop.c: In function 'internal_fnmatch':
libc/misc/fnmatch/fnmatch_loop.c:207:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      CHAR *p_init = p;
                     ^
libc/misc/fnmatch/fnmatch_loop.c:208:21: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      CHAR *n_init = n;
                     ^
libc/stdio/_fpmaxtostr.c:153:2: warning: floating constant exceeds range of 'long double' [-Woverflow]
  0x1.0p1024L,
  ^~~~~~~~~~~
libc/string/generic/strlen.c: In function 'strlen':
libc/string/generic/strlen.c:62:34: warning: result of '2130640638 << 16' requires 48 bits to represent, but 'long int' only has 32 bits [-Wshift-overflow=]
       magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL;
                                  ^~
libc/string/generic/strlen.c:62:41: warning: result of '-16908288 << 16' requires 42 bits to represent, but 'long int' only has 32 bits [-Wshift-overflow=]
       magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL;
                                         ^~
libc/string/generic/strlen.c:31:31: warning: variable 'magic_bits' set but not used [-Wunused-but-set-variable]
   unsigned long int longword, magic_bits, himagic, lomagic;
                               ^~~~~~~~~~
libc/string/generic/strchrnul.c: In function 'strchrnul':
libc/string/generic/strchrnul.c:65:40: warning: result of '2130640638 << 16' requires 48 bits to represent, but 'long int' only has 32 bits [-Wshift-overflow=]
     case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
                                        ^~
libc/string/generic/strchrnul.c:65:47: warning: result of '-16908288 << 16' requires 42 bits to represent, but 'long int' only has 32 bits [-Wshift-overflow=]
     case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
                                               ^~
libc/string/generic/strchr.c: In function 'strchr':
libc/string/generic/strchr.c:66:40: warning: result of '2130640638 << 16' requires 48 bits to represent, but 'long int' only has 32 bits [-Wshift-overflow=]
     case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
                                        ^~
libc/string/generic/strchr.c:66:47: warning: result of '-16908288 << 16' requires 42 bits to represent, but 'long int' only has 32 bits [-Wshift-overflow=]
     case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
                                               ^~
./ldso/include/dl-syscall.h: In function '_dl_pread':
./ldso/include/dl-syscall.h:169:69: warning: right shift count >= width of type [-Wshift-count-overflow]
  return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR((offset >> 32), (offset & 0xffffffff)));
                                                                     ^
./include/endian.h:52:39: note: in definition of macro '__LONG_LONG_PAIR'
 # define __LONG_LONG_PAIR(HI, LO) LO, HI
                                       ^~
  CC libc/misc/internals/__uClibc_main.oS
  CC libc/misc/pthread/tsd.os
  CC libc/stdlib/system.oS
  CC ldso/libdl/libdl.oS
In file included from ./include/bits/waitstatus.h:72:0,
                 from ./include/stdlib.h:44,
                 from ./ldso/include/ldso.h:33,
                 from ldso/libdl/libdl.c:40:
./ldso/include/dl-syscall.h: In function '_dl_pread':
./ldso/include/dl-syscall.h:169:69: warning: right shift count >= width of type [-Wshift-count-overflow]
  return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR((offset >> 32), (offset & 0xffffffff)));
                                                                     ^
./include/endian.h:52:39: note: in definition of macro '__LONG_LONG_PAIR'
 # define __LONG_LONG_PAIR(HI, LO) LO, HI
                                       ^~
libpthread/nptl/init.c: In function '__pthread_initialize_minimal_internal':
libpthread/nptl/init.c:187:7: warning: unused variable 'res' [-Wunused-variable]
   int res = INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
       ^~~
libpthread/nptl/allocatestack.c: In function 'allocate_stack':
libpthread/nptl/allocatestack.c:602:6: warning: label 'mprot_error' defined but not used [-Wunused-label]
      mprot_error:
      ^~~~~~~~~~~
libpthread/nptl/allocatestack.c: In function 'setxid_signal_thread':
libpthread/nptl/allocatestack.c:939:7: warning: variable 'val' set but not used [-Wunused-but-set-variable]
   int val;
       ^~~
./ldso/include/dl-syscall.h: In function '_dl_pread':
./ldso/include/dl-syscall.h:169:69: warning: right shift count >= width of type [-Wshift-count-overflow]
  return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR((offset >> 32), (offset & 0xffffffff)));
                                                                     ^
./include/endian.h:52:39: note: in definition of macro '__LONG_LONG_PAIR'
 # define __LONG_LONG_PAIR(HI, LO) LO, HI
                                       ^~
  CC libc/stdlib/atexit.os
  CC libc/stdlib/system.os
  CC ldso/libdl/libdl.os
In file included from ./include/bits/waitstatus.h:72:0,
                 from ./include/stdlib.h:44,
                 from ./ldso/include/ldso.h:33,
                 from ldso/libdl/libdl.c:40:
./ldso/include/dl-syscall.h: In function '_dl_pread':
./ldso/include/dl-syscall.h:169:69: warning: right shift count >= width of type [-Wshift-count-overflow]
  return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR((offset >> 32), (offset & 0xffffffff)));
                                                                     ^
./include/endian.h:52:39: note: in definition of macro '__LONG_LONG_PAIR'
 # define __LONG_LONG_PAIR(HI, LO) LO, HI
                                       ^~
In file included from ldso/libdl/libdl.c:126:0:
./ldso/ldso/mips/elfinterp.c: In function '_dl_parse_relocation_information':
./ldso/ldso/mips/elfinterp.c:234:8: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
        if (!tls_tpnt)
        ^~
./ldso/ldso/mips/elfinterp.c:237:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     switch (reloc_type) {
     ^~~~~~
libpthread/nptl/init.c: In function '__pthread_initialize_minimal_internal':
libpthread/nptl/init.c:187:7: warning: unused variable 'res' [-Wunused-variable]
   int res = INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
       ^~~