]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkdiscard: don't report "zero range" at the end
authorRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 9 Dec 2015 12:01:51 +0000 (13:01 +0100)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 9 Dec 2015 17:23:29 +0000 (18:23 +0100)
We want to address the case that we have printed the last useful
stats line already within the loop. Avoiding an additional line
"Discarded 0 bytes ..." at the end.

Note there is a behavior change now for the edge cases "-v -l 0" and
"-v -o blksize" where we don't print any stats line anymore. But actually
it's correct, we never make any BLKDISCARD syscall with zero range.
Perhaps we should return error in these cases to help people who always
want to parse stats output on success.

CC: Federico Simoncelli <fsimonce@redhat.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
sys-utils/blkdiscard.c

index bb4bae6ea6e0db3839d21ceda20400e814885e94..f36e504927938a526ec47d7b97eb07d8fb8a21a8 100644 (file)
@@ -211,7 +211,7 @@ int main(int argc, char **argv)
                }
        }
 
-       if (verbose)
+       if (verbose && stats[1])
                print_stats(path, stats);
 
        close(fd);