]> sourceware.org Git - lvm2.git/commitdiff
dmsetup: fix error propagation in _display_info_cols()
authorBryn M. Reeves <bmr@redhat.com>
Thu, 28 Jun 2018 13:25:30 +0000 (14:25 +0100)
committerBryn M. Reeves <bmr@redhat.com>
Thu, 28 Jun 2018 13:25:30 +0000 (14:25 +0100)
Commit 3f35146 added a check on the value returned by the
_display_info_cols() function:

  1024         if (!_switches[COLS_ARG])
  1025                 _display_info_long(dmt, &info);
  1026         else
  1027                 r = _display_info_cols(dmt, &info);
  1028
  1029         return r;

This exposes a bug in the dmstats code in _display_info_cols:
the fact that a device has no regions is explicitly not an error
(and is documented as such in the code), but since the return
code is not changed before leaving the function it is now treated
as an error leading to:

  # dmstats list
  Command failed.

When no regions exist.

Set the return code to the correct value before returning.

libdm/dm-tools/dmsetup.c

index 44386a6dd764c9cf626798c95817fbf3aef4b0f2..fb1a5747cbab0be755764cb7ba173a5698aed050 100644 (file)
@@ -943,8 +943,10 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
                        goto_out;
 
                /* No regions to report is not an error */
-               if (!dm_stats_get_nr_regions(obj.stats))
+               if (!dm_stats_get_nr_regions(obj.stats)) {
+                       r = 1;
                        goto out;
+               }
        }
 
        /* group report with no groups? */
This page took 0.043838 seconds and 5 git commands to generate.