summaryrefslogtreecommitdiffstats
path: root/htop.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-11-16 16:59:01 +0100
committerChristian Göttsche <cgzones@googlemail.com>2020-11-17 13:06:31 +0100
commitb3b890f546e5054b4d9222c8efcef3a425a152ab (patch)
treec91bf3508e3f3ad2096477d51931093cc37cabb5 /htop.c
parentf38af725c21e4beab01070ffe73180ca0549129e (diff)
Use 0 as no-match value for sortkey
Field numbers start at 1, and using -1 as no-match special value triggers static analyzers using a potential negative array access.
Diffstat (limited to 'htop.c')
-rw-r--r--htop.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/htop.c b/htop.c
index c6cd5411..1bbdd50a 100644
--- a/htop.c
+++ b/htop.c
@@ -139,7 +139,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
}
exit(0);
}
- flags.sortKey = -1;
+ flags.sortKey = 0;
for (int j = 1; j < Platform_numberOfFields; j++) {
if (Process_fields[j].name == NULL)
continue;
@@ -148,7 +148,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
break;
}
}
- if (flags.sortKey == -1) {
+ if (flags.sortKey == 0) {
fprintf(stderr, "Error: invalid column \"%s\".\n", optarg);
exit(1);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy