Skip to contentSkip to conversation

master - dmstats: don't output column headings if report fails

PATCH Bryn Reeves 1 participant 1 message Aug 12, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7995eedd3581407b030b0864202068b51dd1ef45
Commit:        7995eedd3581407b030b0864202068b51dd1ef45
Parent:        098528513f8c00d12f4ca5b5e87e4a932a6ef4f6
Author:        Bryn M. Reeves <[email protected]>
AuthorDate:    Wed Aug 12 22:02:23 2015 +0100
Committer:     Bryn M. Reeves <[email protected]>
CommitterDate: Wed Aug 12 22:02:23 2015 +0100

dmstats: don't output column headings if report fails

If _stats_report fails (e.g. due to an invalid device on the command line) destroy the _report to prevent stats columns headings from being displayed.

This also requires a change in main to test the return from _perform_command_for_all_repeatable_args inside the interval loop and exit immediately in case of error.

---
 tools/dmsetup.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
tools/dmsetup.c +7 -0
index e913a7e..dd2f153 100644
@@ -4692,6 +4692,10 @@ static int _stats_report(CMD_ARGS)
 
       out:
 	dm_task_destroy(dmt);
+	if (!r && _report) {
+		dm_report_free(_report);
+		_report = NULL;
+	}
 	return r;
 }
 
@@ -5838,6 +5842,9 @@ doit:
 					goto_out;
 			}
 		}
+
+		if (r)
+			break;
 	} while (--_count);
 
 out: