summaryrefslogtreecommitdiff
path: root/util-linux/dmesg.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/dmesg.c')
-rw-r--r--util-linux/dmesg.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index aa26f58..e38fd55 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -44,10 +44,15 @@ int dmesg_main( int argc, char** argv )
int level = 0;
int lastc;
int cmd = 3;
+ int stopDoingThat;
+
+ argc--;
+ argv++;
/* Parse any options */
while (argc && **argv == '-') {
- while (*++(*argv))
+ stopDoingThat = FALSE;
+ while (stopDoingThat == FALSE && *++(*argv)) {
switch (**argv) {
case 'c':
cmd = 4;
@@ -57,19 +62,22 @@ int dmesg_main( int argc, char** argv )
if (--argc == 0)
goto end;
level = atoi (*(++argv));
- --argc;
- ++argv;
+ if (--argc > 0)
+ ++argv;
+ stopDoingThat = TRUE;
break;
case 's':
if (--argc == 0)
goto end;
bufsize = atoi (*(++argv));
- --argc;
- ++argv;
+ if (--argc > 0)
+ ++argv;
+ stopDoingThat = TRUE;
break;
default:
goto end;
}
+ }
}
if (argc > 1) {