]> sourceware.org Git - lvm2.git/commitdiff
dmstats: check uuid, major, and alldevices before argc (Coverity)
authorBryn M. Reeves <bmr@redhat.com>
Mon, 18 Jul 2016 17:28:07 +0000 (18:28 +0100)
committerBryn M. Reeves <bmr@redhat.com>
Mon, 18 Jul 2016 17:48:34 +0000 (18:48 +0100)
The --uuid, --major and --alldevices arguments were incorrectly tested
after confirming argc is > 0, in a branch that only executes if argc
== 0 (i.e. they were unreachable).

Move all device checks before the test for argc and log an appropriate
error before returning.

tools/dmsetup.c

index a282572284be85166002ad4b4bf7203f92239b5a..985f63b0331022e84913b27b370538b8d6663257 100644 (file)
@@ -4978,24 +4978,24 @@ static int _stats_create_file(CMD_ARGS)
                return 0;
        }
 
+       if (_switches[UUID_ARG] || _switches[MAJOR_ARG]) {
+               log_error("--uuid and --major are incompatible with --filemap.");
+               return 0;
+       }
+
+       if (_switches[ALL_DEVICES_ARG]) {
+               log_error("--alldevices is incompatible with --filemap.");
+               return 0;
+       }
+
        /* _stats_create_file does not use _process_all() */
-       if (names || !argc) {
+       if (!argc) {
                log_error("--filemap requires a file path argument");
                return 0;
-       } else {
-               if (argc)
-                       path = argv[0];
-               else {
-                       if (_switches[UUID_ARG] || _switches[MAJOR_ARG])
-                               log_error("--uuid and --major are incompatible "
-                                         "with --filemap.");
-                       if (_switches[ALL_DEVICES_ARG])
-                               log_error("--alldevices is incompatible with "
-                                         "--filemap.");
-                       return 0;
-               }
        }
 
+       path = argv[0];
+
        if (_switches[PRECISE_ARG]) {
                if (!dm_stats_driver_supports_precise()) {
                        log_error("Using --precise requires driver version "
This page took 0.050198 seconds and 5 git commands to generate.