From 50f32c363ac51f648c27e423ffe2602047dde433 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 9 Jun 2012 22:45:27 +0200 Subject: [PATCH] setarch: do not use -1 as array index [cppcheck] Negative array index does technically work, but looks awkward and can confuse static analyser such as cppcheck. [sys-utils/setarch.c:267]: (error) Array index -1 is out of bounds Signed-off-by: Sami Kerola --- sys-utils/setarch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c index 97269f45ae..a0c6ea81fb 100644 --- a/sys-utils/setarch.c +++ b/sys-utils/setarch.c @@ -259,12 +259,12 @@ int main(int argc, char *argv[]) p = program_invocation_short_name; if (!strcmp(p, "setarch")) { - argv++; argc--; if (argc < 1) show_usage(_("Not enough arguments")); - p = argv[0]; - argv[0] = argv[-1]; /* for getopt_long() to get the program name */ + p = argv[1]; + argv[1] = argv[0]; /* for getopt_long() to get the program name */ + argv++; if (!strcmp(p, "-h") || !strcmp(p, "--help")) show_help(); else if (!strcmp(p, "-V") || !strcmp(p, "--version")) -- 2.47.3