]> sourceware.org Git - systemtap.git/commit
Avoid gcc-12 -Werror=format= issues in staprun/monitor.c
authorWilliam Cohen <wcohen@redhat.com>
Mon, 25 Apr 2022 19:02:15 +0000 (15:02 -0400)
committerWilliam Cohen <wcohen@redhat.com>
Mon, 25 Apr 2022 19:41:45 +0000 (15:41 -0400)
commitfcce232e2d76695203d6677bf72a3abbfd667d27
tree87e7878ea5194334c8c2266e9db326e470934f78
parent506532e991258da99af37c0459bbe29f5dbd06af
Avoid gcc-12 -Werror=format= issues in staprun/monitor.c

The %*s format in the wprintw takes a pair of arguments, an int and a
pointer to a string.  The the width array supplying the first argument
was declared as size_t.  On rawhide gcc-12 would flag those with
errors like the following:

monitor.c:450:27: error: field width specifier ‘*’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
  450 |       wprintw(status, "\n%*s\t%*s\t%*s\t%*s\t%*s\t%*s\t%s\n",
      |                          ~^~
      |                           |
      |                           int
  451 |               width[p_index], HIGHLIGHT("index", p_index, comp_fn_index),
      |               ~~~~~~~~~~~~~~
      |                    |
      |                    size_t {aka long unsigned int}

The %*s makes use of the integer sign to indicate whether to left
justify or right justify the output, so the cautious compiler flags
passing in the long unsigned int.  To follow the %*s conventions made
width array an int which eliminates these errors.
staprun/monitor.c
This page took 0.024459 seconds and 5 git commands to generate.