Project

General

Profile

Actions

Bug #13617

closed

mdb: variable may be used uninitialized

Added by Toomas Soome about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
mdb - modular debugger
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Build errors with gcc 10:

    ../../../common/modules/pmcs/pmcs.c: In function 'display_targets':
    ../../../common/modules/pmcs/pmcs.c:791:3: error: 'dtype' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      791 |   mdb_printf(" %5s", dtype);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/pmcs/pmcs.c: In function 'display_phy':
    ../../../common/modules/pmcs/pmcs.c:2063:4: error: 'route_method' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2063 |    mdb_printf("%-4s %-4s %-4s %-4s %-4s %3d %3c/%1c %3d " 
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     2064 |        "%1d 0x%p ", cfgd, apend, asent, changed, dead,
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     2065 |        phy.ref_count, route_attr, route_method,
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     2066 |        phy.enum_attempts, phy.reenumerate, phy.phy_lock);
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/pmcs/pmcs.c:2009:4: error: 'dtype' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2009 |    mdb_printf(" %3d %4d %6s %4s ",
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     2010 |        phy.device_id, phy.phynum, speed, dtype);
          |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/pmcs/pmcs.c: In function 'display_matching_work':
    ../../../common/modules/pmcs/pmcs.c:2602:5: error: 'match_type' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2602 |     mdb_printf("\nWork structures matching %s\n\n",
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     2603 |         match_type, match_val);
          |         ~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/pmcs/pmcs.c: In function 'pmcs_tag':
    ../../../common/modules/pmcs/pmcs.c:2739:2: error: 'state_str' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2739 |  mdb_printf("%16p %9s %4d %1d %1d 0x%08x 0x%04x 0x%04x %16p\n", addr,
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     2740 |      state_str, dip.devi_instance, ss.blocked, ss.configuring,
          |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     2741 |      ss.work_flags, ss.wserno, ss.debug_mask, ss.dip);
          |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/pmcs/pmcs.c: In function 'pmcs_dcmd':
    ../../../common/modules/pmcs/pmcs.c:3045:2: error: 'state_str' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     3045 |  mdb_printf("%16p %9s %4d %1d %1d 0x%08x 0x%04x 0x%04x %16p\n", addr,
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     3046 |      state_str, dip.devi_instance, ss.blocked, ss.configuring,
          |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     3047 |      ss.work_flags, ss.wserno, ss.debug_mask, ss.dip);
          |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/pmcs/pmcs.c:3071:3: error: 'devid' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     3071 |   display_inbound_queues(ss, devid, verbose);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/modules/genunix/typegraph.c: In function 'typeconflict_walk_step':
    ../../../common/modules/genunix/typegraph.c:2789:10: error: 'node' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2789 |  return (wsp->walk_callback(node->tgn_base, NULL, wsp->walk_cbdata));
          |         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/genunix/typegraph.c: In function 'typeunknown_walk_step':
    ../../../common/modules/genunix/typegraph.c:2817:10: error: 'node' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2817 |  return (wsp->walk_callback(node->tgn_base, NULL, wsp->walk_cbdata));
          |         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/modules/ipp/ipp.c: In function 'dump_classes':
    ../../../common/modules/ipp/ipp.c:595:2: error: 'cp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      595 |  mdb_free(cp, sizeof (ipp_class_t) * nelt);
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/ipp/ipp.c: In function 'dump_log':
    ../../../common/modules/ipp/ipp.c:628:2: error: 'lp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      628 |  mdb_free(lp, sizeof (ipp_log_t) * nelt);
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/modules/genunix/net.c: In function 'sonode':
    ../../../common/modules/genunix/net.c:450:21: error: 'type' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      450 |  if ((optt != NULL) && (so.so_type != type))
          |      ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/genunix/net.c:453:21: error: 'proto' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      453 |  if ((optp != NULL) && (so.so_protocol != proto))
          |      ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/genunix/net.c:447:21: error: 'family' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      447 |  if ((optf != NULL) && (so.so_family != family))
          |      ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/genunix/net.c: In function 'do_show_bridge':
    ../../../common/modules/genunix/net.c:1435:10: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
     1435 |   cp[-1] = '\0';
          |   ~~~~~~~^~~~~~
    ../../../common/modules/genunix/net.c:1415:7: note: at offset -1 to object 'bname' with size 32 declared here
     1415 |  char bname[MAXLINKNAMELEN];
          |       ^~~~~
    cc1: all warnings being treated as errors

    ../../../common/modules/genunix/lgrp.c: In function 'lgrp':
    ../../../common/modules/genunix/lgrp.c:321:26: error: 'handle' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      321 |   if ((s_handle != NULL) &&
          |       ~~~~~~~~~~~~~~~~~~~^~
      322 |       handle != (uintptr_t)lgrp.lgrp_plathand)
          |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/genunix/lgrp.c:316:26: error: 'parent' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      316 |   if ((s_parent != NULL) &&
          |       ~~~~~~~~~~~~~~~~~~~^~
      317 |       parent != (uintptr_t)lgrp.lgrp_parent)
          |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/genunix/lgrp.c:319:25: error: 'index' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      319 |   if ((s_index != NULL) && index != (uintptr_t)lgrp.lgrp_id)
          |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/modules/genunix/genunix.c: In function 'cpu_walk_init':
    ../../../common/modules/genunix/genunix.c:3078:22: error: 'addr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     3078 |    cw->cw_array[i++] = addr;
          |    ~~~~~~~~~~~~~~~~~~^~~~~~
    ../../../common/modules/genunix/genunix.c: In function 'cpuinfo_walk_cpu':
    ../../../common/modules/genunix/genunix.c:3343:5: error: 'pinned' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     3343 |     mdb_warn("failed to read kthread_t at %p",
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     3344 |         pinned);
          |         ~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/modules/genunix/kmem.c: In function 'kmem_walk_init_common':
    ../../../common/modules/genunix/kmem.c:1313:4: error: 'slabsize' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1313 |    mdb_free(kmw->kmw_ubase, slabsize +
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1314 |        sizeof (kmem_bufctl_t));
          |        ~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/genunix/kmem.c:1310:38: error: 'chunksize' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1310 |    mdb_free(kmw->kmw_valid, slabsize / chunksize);
          |                             ~~~~~~~~~^~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/modules/libumem/umem.c: In function 'umem_walk_init_common':
    ../../../common/modules/libumem/umem.c:1269:4: error: 'slabsize' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1269 |    mdb_free(umw->umw_ubase, slabsize +
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1270 |        sizeof (umem_bufctl_t));
          |        ~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/modules/libumem/umem.c:1266:4: error: 'chunksize' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1266 |    mdb_free(umw->umw_valid, slabsize / chunksize);
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/mdb/mdb_fmt.c: In function 'mdb_fmt_print':
    ../../../common/mdb/mdb_fmt.c:804:4: error: 'rvalue' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      804 |    mdb_nv_set_value(mdb.m_rvalue, rvalue);
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/mdb/mdb_nm.c: In function 'cmd_nm':
    ../../../common/mdb/mdb_nm.c:789:13: error: 'syms' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      789 |   for (symp = syms; nsyms-- != 0; symp++) {
          |        ~~~~~^~~~~~
    cc1: all warnings being treated as errors

    ../../../common/mdb/mdb_kvm.c: In function 'kt_activate':
    ../../../common/mdb/mdb_kvm.c:636:4: error: 'oflag' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      636 |    mdb_iob_setflags(mdb.m_out, oflag);
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/mdb/mdb_ctf.c: In function 'name_to_type':
    ../../../common/mdb/mdb_ctf.c:297:5: error: 'id' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      297 |  if (id == CTF_ERR) {
          |     ^
    cc1: all warnings being treated as errors

    ../../../common/mdb/mdb_cmds.c: In function 'write_arglist':
    ../../../common/mdb/mdb_cmds.c:344:16: error: 'write_value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      344 |   if ((naddr = write_value(as, addr, value, rdback)) == addr) {
          |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/mdb/mdb_cmds.c: In function 'write_arglist':
    ../../../common/mdb/mdb_cmds.c:344:16: error: 'write_value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      344 |   if ((naddr = write_value(as, addr, value, rdback)) == addr) {
          |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../common/mdb/mdb_cmds.c: In function 'match_arglist':
    ../../../common/mdb/mdb_cmds.c:457:9: error: 'match_value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      457 |  addr = match_value(as, addr, args[0], args[1]);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/mdb/mdb_print.c: In function 'cmd_enum':
    ../../../common/mdb/mdb_print.c:615:7: error: 'search' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      615 |   if ((int)search != search) {
          |       ^~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../../common/mdb/mdb_target.c: In function 'mdb_tgt_readstr':
    ../../../common/mdb/mdb_target.c:525:5: error: 'n' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      525 |  if (nread == 0 && n == -1)
          |     ^
    cc1: all warnings being treated as errors

    ../mdb -c ../../../common/mdb/mdb_proc.c
    ../../../common/mdb/mdb_proc.c: In function 'mdb_proc_tgt_create':
    ../../../common/mdb/mdb_proc.c:5440:49: error: 'state' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     5440 |  if ((t->t_pshandle != NULL && state != PS_DEAD && state != PS_IDLE) ||
          |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    ../../common/findscn.c: In function 'findelfsecidx':
    ../../common/findscn.c:53:7: error: 'name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       53 |   if (strcmp(name, tofind) == 0)
          |       ^~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

Testing done: build/install/boot

also mdb tests from util-test.

Tests passed: 54
Tests failed: 0
Tests run: 54

Actions #1

Updated by Electric Monk about 1 year ago

  • Gerrit CR set to 1321
Actions #2

Updated by Toomas Soome about 1 year ago

  • Description updated (diff)
Actions #3

Updated by Toomas Soome about 1 year ago

  • Description updated (diff)
Actions #4

Updated by Electric Monk about 1 year ago

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

git commit 24537d3ef87e4452da693fc3143ef18a1a0f3cac

commit  24537d3ef87e4452da693fc3143ef18a1a0f3cac
Author: Toomas Soome <tsoome@me.com>
Date:   2021-03-15T19:06:24.000Z

    13617 mdb: variable may be used uninitialized
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF