about summary refs log tree commit homepage
path: root/mincore.c
diff options
context:
space:
mode:
Diffstat (limited to 'mincore.c')
-rw-r--r--mincore.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/mincore.c b/mincore.c
index 41adf7b..b2de217 100644
--- a/mincore.c
+++ b/mincore.c
@@ -1,5 +1,11 @@
 #include "compat-util.h"
 
+static int usage(const char * argv0)
+{
+        fprintf(stderr, "Usage: %s [-o offset] [-l length] FILE...\n", argv0);
+        return 1;
+}
+
 static void mincore_stats(const char *path, off_t offset, off_t len)
 {
         char *map;
@@ -70,7 +76,7 @@ int main(int argc, char * const argv[])
         int argi = 1;
         int opt;
 
-        while ((opt = getopt(argc, argv, "o:l:")) != -1) {
+        while ((opt = getopt(argc, argv, "o:l:h")) != -1) {
                 char *err;
 
                 argi += 2;
@@ -90,13 +96,13 @@ int main(int argc, char * const argv[])
                         }
                         break;
                 default:
-                        fprintf(stderr,
-                                "Usage: %s [-o offset] "
-                                "[-l length] <files>\n", argv[0]);
-                        return 1;
+                        return usage(argv[0]);
                 }
         }
 
+        if (argi >= argc)
+                return usage(argv[0]);
+
         for (; argi < argc; ++argi)
                 mincore_stats(argv[argi], offset, len);
         return 0;