Fixes the following -fanalyzer warning with at least gcc-12.
Ok for trunk?
PS: nowadays our self initializations might do more harm than good,
might even hinder optimizations down the pipe. We should maybe revisit these.
gcc -Wp,-MD,util-linux/.chrt.o.d -std=gnu99 -Iinclude -Ilibbb -include
include/autoconf.h -D_GNU_SOURCE -DNDEBUG -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DBB_VER='"1.35.0.git"'
-malign-data=abi -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes
-Wunused -Wunused-parameter -Wunused-function -Wunused-value
-Wmissing-prototypes -Wmissing-declarations -Wno-format-security
-Wdeclaration-after-statement -Wold-style-definition -finline-limit=0
-fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections
-fno-guess-branch-probability -funsigned-char -static-libgcc
-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1
-fno-unwind-tables -fno-asynchronous-unwind-tables -fno-builtin-printf -Os
-fanalyzer -DKBUILD_BASENAME='"chrt"' -DKBUILD_MODNAME='"chrt"' -c -o
util-linux/chrt.o util-linux/chrt.c
util-linux/chrt.c: In function ‘chrt_main’:
util-linux/chrt.c:192:29: warning: use of uninitialized value ‘priority’
[CWE-457] [-Wanalyzer-use-of-uninitialized-value]
192 | sp.sched_priority = xstrtou_range(priority, 0,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
193 | sched_get_priority_min(policy),
sched_get_priority_max(policy)
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194 | );
| ~
‘chrt_main’: event 1
|
| 107 | if (opt & OPT_m) { /* print min/max and exit */
| | ^
| | |
| | (1) following ‘false’ branch...
|
‘chrt_main’: events 2-3
|
| 117 | if (opt & OPT_f)
| | ^
| | |
| | (2) ...to here
|......
| 127 | if (!argv[0])
| | ~
| | |
| | (3) following ‘false’ branch...
|
‘chrt_main’: events 4-7
|
| 129 | if (opt & OPT_p) {
| | ~ ^
| | | |
| | | (4) ...to here
| | (5) following ‘true’ branch...
| 130 | pid_str = *argv++;
| | ~~~~~~
| | |
| | (6) ...to here
| 131 | if (*argv) { /* "-p PRIO PID [...]" */
| | ~
| | |
| | (7) following ‘false’ branch...
|
‘chrt_main’: event 8
|
|include/xatonum.h:56:10:
| 56 | { return xato##UW##_range(str, l, u); } \
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (8) ...to here
include/xatonum.h:87:1: note: in expansion of macro ‘DEFINE_EQUIV_STR_CONV’
| 87 | DEFINE_EQUIV_STR_CONV(long, l, ll, ul, ull)
| | ^~~~~~~~~~~~~~~~~~~~~
|
‘chrt_main’: event 9
|
|util-linux/chrt.c:192:29:
| 192 | sp.sched_priority = xstrtou_range(priority, 0,
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (9) use of uninitialized value
‘priority’ here
| 193 | sched_get_priority_min(policy),
sched_get_priority_max(policy)
| |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 194 | );
| | ~
|
Bernhard Reutner-Fischer (1):
chrt: silence analyzer warning
util-linux/chrt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.33.0
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox