Project

General

Profile

Actions

Bug #13805

closed

nwamcfg: variable may be used uninitialized

Added by Toomas Soome 7 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Build errors with gcc compilers:

    nwamcfg.c: In function 'do_commit':
    nwamcfg.c:1209:6: error: 'verr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1209 |   if (verr != NWAM_SUCCESS)
          |      ^
    nwamcfg.c: In function 'show_prop_test':
    nwamcfg.c:2350:6: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2350 |   if (ret != NWAM_SUCCESS)
          |      ^
    nwamcfg.c: In function 'is_prop_multivalued':
    nwamcfg.c:2487:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2487 |  if (ret != NWAM_SUCCESS)
          |     ^
    nwamcfg.c: In function 'prop_value_type':
    nwamcfg.c:1993:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1993 |  if (ret != NWAM_SUCCESS)
          |     ^
    nwamcfg.c: In function 'str_to_nwam_value':
    nwamcfg.c:2137:3: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2137 |   nwamerr(ret, "Failed creating nwam_value");
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nwamcfg.c:2113:20: error: 'boolean_vals' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2113 |    boolean_vals[i] = str_to_boolean(val[i]);
          |    ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
    nwamcfg.c:2096:18: error: 'uint_vals' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2096 |     uint_vals[i] = str_as_enum;
          |     ~~~~~~~~~~~~~^~~~~~~~~~~~~
    nwamcfg.c:2080:16: error: 'int_vals' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2080 |    int_vals[i] = (int64_t)atoi(val[i]);
          |    ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
    nwamcfg.c: In function 'output_prop_val':
    nwamcfg.c:2790:10: error: 'val' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2790 |   (void) fprintf(wf, "%s%s", tostr(val, prop_name, str),
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     2791 |       i != num-1 ? NWAM_VALUE_DELIMITER_STR : "");
          |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nwamcfg.c:2790:10: error: 'tostr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    nwamcfg.c: In function 'destroy_func':
    nwamcfg.c:1685:12: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1685 |  } else if (ret != NWAM_SUCCESS) {
          |            ^
    nwamcfg.c: In function 'revert_func':
    nwamcfg.c:1833:4: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1833 |    nwamerr(ret, "Revert error");
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    nwamcfg.c: In function 'clear_func':
    nwamcfg.c:3864:38: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     3864 |   if (ret == NWAM_INVALID_ARG || ret == NWAM_ENTITY_NOT_FOUND) {
          |                                  ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
    nwamcfg.c: In function 'verify_func':
    nwamcfg.c:4161:3: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     4161 |   nwamerr(ret, "Verify error on property '%s'", errprop);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    nwamcfg.c: In function 'cmd_file':
    nwamcfg.c:4287:3: error: 'infile' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       (void) fclose(infile);
       ^~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    *** Error code 1
    dmake: Fatal error: Command failed for target `nwamcfg.o'
    Current working directory /code/illumos-gate/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg

Testing done: build/install/boot

Actions #1

Updated by Toomas Soome 7 months ago

  • Description updated (diff)
Actions #2

Updated by Electric Monk 7 months ago

  • Gerrit CR set to 1490
Actions #3

Updated by Joshua M. Clulow 3 months ago

Toomas notes he is able to run nwamcfg:

nwamcfg> list ncp automatic
NCUs:
    phys    e1000g0
    ip    e1000g0
    phys    igb0
    ip    igb0
nwamcfg> list loc user
loc:User
    activation-mode              manual
    enabled                      false
    nameservices                 dns
    nameservices-config-file     "/etc/svc/volatile/nwam/User/nsswitch.conf" 
    dns-nameservice-configsrc    manual
    dns-nameservice-domain       "lan" 
    dns-nameservice-servers      "192.168.1.1" 
    dns-nameservice-search       "lan" 
nwamcfg> 
nwamcfg> select loc user
nwamcfg:loc:User> set dns-nameservice-servers=192.168.150.1
nwamcfg:loc:User> commit
Committed changes
nwamcfg:loc:User> exit
root@beastie:~# nwamcfg list loc user
loc:User
    activation-mode              manual
    enabled                      false
    nameservices                 dns
    nameservices-config-file     "/etc/svc/volatile/nwam/User/nsswitch.conf" 
    dns-nameservice-configsrc    manual
    dns-nameservice-domain       "lan" 
    dns-nameservice-servers      "192.168.150.1" 
    dns-nameservice-search       "lan" 
root@beastie:~# 
Actions #4

Updated by Electric Monk 3 months ago

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

git commit 4a5cced59c85fb4e06290040b640fc651cceba52

commit  4a5cced59c85fb4e06290040b640fc651cceba52
Author: Toomas Soome <tsoome@me.com>
Date:   2021-08-31T19:27:03.000Z

    13805 nwamcfg: variable may be used uninitialized
    Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org>
    Approved by: Joshua M. Clulow <josh@sysmgr.org>

Actions

Also available in: Atom PDF