Project

General

Profile

Actions

Bug #13619

closed

sgs: variable may be used uninitialized

Added by Toomas Soome over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

Build errors with gcc 10:

    ../common/rdelf.c: In function 'fetch_symtab':
    ../common/rdelf.c:317:11: error: 'symdata_aux' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      317 |    (void) gelf_getsym(symdata_aux, i, &gsym);
          |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../common/rdelf.c:271:17: error: 'nsyms_pri' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      271 |  if ((nsyms_pri + nsyms_aux) != (GElf_Xword)nsyms) {
          |      ~~~~~~~~~~~^~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../common/y2.c: In function 'defin':
    ../common/y2.c:1047:24: error: 'val' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1047 |  tokset[ntokens].value = val;
          |  ~~~~~~~~~~~~~~~~~~~~~~^~~~~
    cc1: all warnings being treated as errors

    ../common/elfdump.c: In function 'syminfo64':
    ../common/elfdump.c:2022:15: error: 'dynerr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2022 |    if (!dynerr[boundto]) {
          |               ^
    ../common/elfdump.c: In function 'dyn_symtest':
    ../common/elfdump.c:2910:6: error: '_cache' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2910 |   if ((_cache != NULL) &&
          |      ^
    In file included from ../common/elfdump.c:44:
    ../common/elfdump.c: In function 'cap_section':
    ../../include/debug.h:1094:24: error: 'strs_size' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1094 | #define Elf_cap_entry  Elf64_cap_entry
          |                        ^~~~~~~~~~~~~~~
    ../common/elfdump.c:1332:10: note: 'strs_size' was declared here
     1332 |  size_t  strs_size;
          |          ^~~~~~~~~
    In file included from ../common/elfdump.c:47:
    ../common/_elfdump.h:191:18: error: 'strcache' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      191 | #define string   string64
          |                  ^~~~~~~~
    ../common/elfdump.c:1328:20: note: 'strcache' was declared here
     1328 |  Cache  *cicache, *strcache;
          |                    ^~~~~~~~
    ../common/elfdump.c:1609:3: error: 'capinfonum' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1609 |   for (inum = 1, cip++; inum < capinfonum; inum++, cip++) {
          |   ^~~
    In file included from ../common/elfdump.c:47:
    ../common/_elfdump.h:191:18: error: 'cicache' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      191 | #define string   string64
          |                  ^~~~~~~~
    ../common/elfdump.c:1328:10: note: 'cicache' was declared here
     1328 |  Cache  *cicache, *strcache;
          |          ^~~~~~~
    ../common/elfdump.c:1583:13: error: 'cishdr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1583 |   if (cishdr->sh_info >= shnum) {
          |       ~~~~~~^~~~~~~~~
    ../common/elfdump.c: In function 'cap64':
    ../common/elfdump.c:1765:46: error: 'cphdr_sz' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1765 |   } else if ((cphdr_off != cshdr->sh_offset) ||
          |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
     1766 |       (cphdr_sz != cshdr->sh_size)) {
          |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    *** Error code 1
    dmake: Warning: Target `all' not remade because of errors
    Current working directory /code/illumos-gate/usr/src/cmd/sgs/elfdump/i386

    ../common/fcns.c: In function 'ar_sym_read':
    ../common/fcns.c:73:11: error: 'fmt' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       73 |    (void) printf(fmt, EC_XWORD(arsym->as_off),
          |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       74 |        (arsym->as_name ? arsym->as_name : ""));
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../common/elfdump.c: In function 'symbols_getxindex':
    ../common/elfdump.c:1063:19: error: 'symn' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1063 |   state->shxndx.n = symn;
          |   ~~~~~~~~~~~~~~~~^~~~~~
    ../common/elfdump.c: In function 'output_symbol':
    ../common/elfdump.c:1272:11: error: 'shndx' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1272 |    (void) fprintf(stderr,
          |           ^~~~~~~~~~~~~~~
     1273 |        MSG_INTL(MSG_ERR_BADSYM6), state->file,
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1274 |        state->secname, EC_WORD(symndx),
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1275 |        demangle(symname, state->flags),
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1276 |        EC_WORD(shndx), EC_XWORD(tshdr->sh_size),
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1277 |        EC_XWORD(sym->st_value), EC_XWORD(sym->st_size));
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../common/elfdump.c: In function 'syminfo32':
    ../common/elfdump.c:2022:15: error: 'dynerr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2022 |    if (!dynerr[boundto]) {
          |               ^
    ../common/elfdump.c: In function 'dyn_symtest':
    ../common/elfdump.c:2910:6: error: '_cache' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2910 |   if ((_cache != NULL) &&
          |      ^
    In file included from ../common/elfdump.c:44:
    ../common/elfdump.c: In function 'cap_section':
    ../../include/debug.h:1130:24: error: 'strs_size' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1130 | #define Elf_cap_entry  Elf32_cap_entry
          |                        ^~~~~~~~~~~~~~~
    ../common/elfdump.c:1332:10: note: 'strs_size' was declared here
     1332 |  size_t  strs_size;
          |          ^~~~~~~~~
    In file included from ../common/elfdump.c:47:
    ../common/_elfdump.h:215:18: error: 'strcache' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      215 | #define string   string32
          |                  ^~~~~~~~
    ../common/elfdump.c:1328:20: note: 'strcache' was declared here
     1328 |  Cache  *cicache, *strcache;
          |                    ^~~~~~~~
    ../common/elfdump.c:1609:3: error: 'capinfonum' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1609 |   for (inum = 1, cip++; inum < capinfonum; inum++, cip++) {
          |   ^~~
    In file included from ../common/elfdump.c:47:
    ../common/_elfdump.h:215:18: error: 'cicache' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      215 | #define string   string32
          |                  ^~~~~~~~
    ../common/elfdump.c:1328:10: note: 'cicache' was declared here
     1328 |  Cache  *cicache, *strcache;
          |          ^~~~~~~
    ../common/elfdump.c:1583:13: error: 'cishdr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1583 |   if (cishdr->sh_info >= shnum) {
          |       ~~~~~~^~~~~~~~~
    ../common/elfdump.c: In function 'cap32':
    ../common/elfdump.c:1765:46: error: 'cphdr_sz' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1765 |   } else if ((cphdr_off != cshdr->sh_offset) ||
          |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
     1766 |       (cphdr_sz != cshdr->sh_size)) {
          |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../common/dfn.c: In function 'dfn_findcycle':
    ../common/dfn.c:238:17: error: 'cycleheadp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      238 |   if (cycleheadp->cyclehead != cycleheadp) {
          |       ~~~~~~~~~~^~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../common/dfn.c: In function 'dfn_findcycle':
    ../common/dfn.c:238:17: error: 'cycleheadp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      238 |   if (cycleheadp->cyclehead != cycleheadp) {
          |       ~~~~~~~~~~^~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../common/main.c: In function 'main':
    ../common/main.c:970:10: error: 'osabi' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      970 |    ret = archive(file, fd, elf, flags, wname, wfd, osabi);
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../common/crle.c: In function 'main':
    ../common/crle.c:453:13: error: 'objdir' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      453 |      (void) fprintf(stderr,
          |             ^~~~~~~~~~~~~~~
      454 |          MSG_INTL(MSG_SYS_ACCESS),
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~
      455 |          crle.c_name, objdir->o_objdir,
          |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      456 |          strerror(err));
          |          ~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../common/errorpi.c: In function 'pi':
    ../common/errorpi.c:312:19: error: 'nwordv' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      312 |    wordv = nwordv - 1;
          |            ~~~~~~~^~~
    cc1: all warnings being treated as errors

    ../common/readelf.c: In function 'get_symtab':
    ../common/readelf.c:549:11: error: 'symdata_aux' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      549 |    (void) gelf_getsym(symdata_aux, i, &gsym);
          |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../common/readelf.c:514:17: error: 'nsyms_pri' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      514 |  if ((nsyms_pri + nsyms_aux) != (GElf_Xword)nsyms)
          |      ~~~~~~~~~~~^~~~~~~~~~~~
    cc1: all warnings being treated as errors
    *** Error code 1
    dmake: Warning: Command failed for target `readelf.o'
    Current working directory /code/illumos-gate/usr/src/cmd/sgs/gprof/i386

Testing done: build/install/boot.

Actions #1

Updated by Electric Monk over 2 years ago

  • Gerrit CR set to 1323
Actions #2

Updated by Toomas Soome over 2 years ago

  • Description updated (diff)
Actions #3

Updated by Electric Monk over 2 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100

git commit 7879e8a6e519927d54da6cc205d016d1ffe88e09

commit  7879e8a6e519927d54da6cc205d016d1ffe88e09
Author: Toomas Soome <tsoome@me.com>
Date:   2021-05-17T15:55:19.000Z

    13619 sgs: variable may be used uninitialized
    Reviewed by: Rich Lowe <richlowe@richlowe.net>
    Reviewed by: Andy Fiddaman <andy@omnios.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF