dma: accept -q without argument. report argument errors.
authorSimon Schubert <corecode@dragonflybsd.org>
Tue, 21 Jul 2009 23:20:08 +0000 (01:20 +0200)
committerSimon Schubert <corecode@dragonflybsd.org>
Tue, 21 Jul 2009 23:20:08 +0000 (01:20 +0200)
libexec/dma/dma.c

index 25e0c0c..ca9e9c1 100644 (file)
@@ -527,7 +527,7 @@ main(int argc, char **argv)
        }
 
        opterr = 0;
-       while ((ch = getopt(argc, argv, "A:b:B:C:d:Df:F:h:iL:N:no:O:q:r:R:UV:vX:")) != -1) {
+       while ((ch = getopt(argc, argv, ":A:b:B:C:d:Df:F:h:iL:N:no:O:q:r:R:UV:vX:")) != -1) {
                switch (ch) {
                case 'A':
                        /* -AX is being ignored, except for -A{c,m} */
@@ -583,7 +583,15 @@ main(int argc, char **argv)
                case 'X':
                        break;
 
+               case ':':
+                       if (optopt == 'q') {
+                               doqueue = 1;
+                               break;
+                       }
+                       /* FALLTHROUGH */
+
                default:
+                       fprintf(stderr, "invalid argument: `-%c'\n", optopt);
                        exit(1);
                }
        }