shithub: dav1d

Download patch

ref: d52533651f72a3e81a103b460d08059d39c1c3f2
parent: 9e08ac7112b6a4fef6e1dde6152ceef1117aa6f4
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Thu Nov 29 09:34:57 EST 2018

tools/dav1d: abort on unused/unknown CLI arguments

--- a/tools/dav1d_cli_parse.c
+++ b/tools/dav1d_cli_parse.c
@@ -135,7 +135,7 @@
     dav1d_default_settings(lib_settings);
     int grain_specified = 0;
 
-    while ((o = getopt_long(argc, argv, short_opts, long_opts, NULL)) >= 0) {
+    while ((o = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
         switch (o) {
         case 'o':
             cli_settings->outputfile = optarg;
@@ -186,10 +186,12 @@
             fprintf(stderr, "%s\n", dav1d_version());
             exit(0);
         default:
-            break;
+            usage(argv[0], NULL);
         }
     }
 
+    if (optind < argc)
+        usage(argv[0], "Extra/unused arguments found, e.g. '%s'\n", argv[optind]);
     if (cli_settings->verify) {
         if (cli_settings->outputfile)
             usage(argv[0], "Verification (--verify) requires output file (-o/--output) to not set");