From: Sami Kerola Date: Sat, 9 Jun 2012 20:45:27 +0000 (+0200) Subject: setarch: do not use -1 as array index [cppcheck] X-Git-Tag: v2.22-rc1~277^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50f32c363ac51f648c27e423ffe2602047dde433;p=thirdparty%2Futil-linux.git 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 --- 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"))