Project

General

Profile

Actions

Bug #13752

closed

stat: variable may be used uninitialized

Added by Toomas Soome about 1 year ago. Updated about 1 year 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 shadow gcc 7:

    mpstat.c: In function 'main':
    mpstat.c:192:3: error: 'period_n' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      192 |   sleep_until(&start_n, period_n, infinite_cycles, &caught_cont);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

    iostat.c: In function 'show_disk':
    iostat.c:833:8: error: 'serv' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      833 |        fzero(serv) && fzero(w_pct) && fzero(r_pct) &&
          |        ^~~~~~~~~~~
    iostat.c:867:5: error: 'rserv' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      867 |     push_out(fstr, rps, wps, krps, kwps, avw, avr,
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      868 |         wserv, rserv, w_pct, r_pct);
          |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    iostat.c:867:5: error: 'wserv' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    iostat.c:833:39: error: 'r_pct' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      833 |        fzero(serv) && fzero(w_pct) && fzero(r_pct) &&
          |                                       ^~~~~~~~~~~~
    iostat.c:833:23: error: 'w_pct' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      833 |        fzero(serv) && fzero(w_pct) && fzero(r_pct) &&
          |                       ^~~~~~~~~~~~
    iostat.c:832:37: error: 'avr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      832 |        fzero(kwps) && fzero(avw) && fzero(avr) &&
          |                                     ^~~~~~~~~~
    iostat.c:832:23: error: 'avw' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      832 |        fzero(kwps) && fzero(avw) && fzero(avr) &&
          |                       ^~~~~~~~~~
    iostat.c:820:3: error: 'kps' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      820 |   push_out(fstr, kps, tps, serv);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    iostat.c:832:8: error: 'kwps' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      832 |        fzero(kwps) && fzero(avw) && fzero(avr) &&
          |        ^~~~~~~~~~~
    iostat.c:831:36: error: 'krps' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      831 |    if (fzero(rps) && fzero(wps) && fzero(krps) &&
          |                                    ^~~~~~~~~~~
    iostat.c:820:3: error: 'tps' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      820 |   push_out(fstr, kps, tps, serv);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    iostat.c:831:22: error: 'wps' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      831 |    if (fzero(rps) && fzero(wps) && fzero(krps) &&
          |                      ^~~~~~~~~~
    iostat.c:831:8: error: 'rps' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      831 |    if (fzero(rps) && fzero(wps) && fzero(krps) &&
          |        ^~~~~~~~~~
    cc1: all warnings being treated as errors

    /code/illumos-gate/usr/src/cmd/stat/common/dsr.c: In function 'drvinstpart2dev':
    /code/illumos-gate/usr/src/cmd/stat/common/dsr.c:168:25: error: 'mm' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       if (part == NULL && mm->minor_isdisk) {
                           ~~^~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    *** Error code 1
    dmake: Fatal error: Command failed for target `dsr.o'
    Current working directory /code/illumos-gate/usr/src/cmd/stat/iostat

Cleaning them all up.

Testing done: build/install/boot cycle. all *stat commands appear to work as expected.

Device names get translated:

tsoome@beastie:/code/illumos-gate/usr/src/cmd/stat/iostat$ ./iostat -xn sd3 1
                    extended device statistics              
    r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b device
    1.1   15.7   27.0  214.5  0.0  0.0    1.4    0.7   2   1 c3t3d0
                    extended device statistics              
    r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b device
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.0   0   0 c3t3d0
                    extended device statistics              
    r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b device
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.0   0   0 c3t3d0
                    extended device statistics              
    r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b device
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.0   0   0 c3t3d0
                    extended device statistics              
    r/s    w/s   kr/s   kw/s wait actv wsvc_t asvc_t  %w  %b device
    0.0    0.0    0.0    0.0  0.0  0.0    0.0    0.0   0   0 c3t3d0
^C
tsoome@beastie:/code/illumos-gate/usr/src/cmd/stat/iostat$

interval stats are also sorking with mpstat.
Actions #1

Updated by Electric Monk about 1 year ago

  • Gerrit CR set to 1443
Actions #2

Updated by Toomas Soome about 1 year ago

  • Description updated (diff)
Actions #3

Updated by Electric Monk about 1 year ago

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

git commit ea429a71818e2432d0d0a924065a009b1e5abdd1

commit  ea429a71818e2432d0d0a924065a009b1e5abdd1
Author: Toomas Soome <tsoome@me.com>
Date:   2021-05-03T15:03:57.000Z

    13752 stat: variable may be used uninitialized
    Reviewed by: C Fraire <cfraire@me.com>
    Reviewed by: Sebastian Wiedenroth <sebastian.wiedenroth@skylime.net>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF