diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2015-08-12 21:14:00 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2015-08-12 21:40:43 +0100 |
commit | 098528513f8c00d12f4ca5b5e87e4a932a6ef4f6 (patch) | |
tree | 15a6ef5e1fee4e16bdd3a16f4b1450edd449f594 | |
parent | 829384f46dedee8646cc6b098ef98463658c51d6 (diff) | |
download | lvm2-098528513f8c00d12f4ca5b5e87e4a932a6ef4f6.tar.gz |
dmstats: don't output column headings when args checks fail
The clear, create, delete, and print commands do not use _report:
make sure it is freed and set to NULL before checking arguments.
-rw-r--r-- | tools/dmsetup.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 459639b4b..e913a7edf 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -4193,6 +4193,12 @@ static int _stats_clear(CMD_ARGS) char *name = NULL; int allregions = _switches[ALL_REGIONS_ARG]; + /* clear does not use a report */ + if (_report) { + dm_report_free(_report); + _report = NULL; + } + if (!_switches[REGION_ID_ARG] && !_switches[ALL_REGIONS_ARG]) { err("Please specify a region_id."); return 0; @@ -4206,12 +4212,6 @@ static int _stats_clear(CMD_ARGS) name = argv[1]; } - /* create does not use a report */ - if (_report) { - dm_report_free(_report); - _report = NULL; - } - region_id = (allregions) ? DM_STATS_REGIONS_ALL : (uint64_t) _int_args[REGION_ID_ARG]; @@ -4327,6 +4327,12 @@ static int _stats_create(CMD_ARGS) uint64_t start = 0, len = 0, areas = 0, area_size = 0; int64_t step = 0; + /* create does not use a report */ + if (_report) { + dm_report_free(_report); + _report = NULL; + } + if (_switches[ALL_REGIONS_ARG]) { log_error("Cannot use --allregions with create."); return 0; @@ -4363,12 +4369,6 @@ static int _stats_create(CMD_ARGS) name = argv[1]; } - /* create does not use a report */ - if (_report) { - dm_report_free(_report); - _report = NULL; - } - if (_switches[AREAS_ARG]) areas = (uint64_t) _int_args[AREAS_ARG]; @@ -4443,6 +4443,12 @@ static int _stats_delete(CMD_ARGS) const char *program_id = DM_STATS_PROGRAM_ID; int allregions = _switches[ALL_REGIONS_ARG]; + /* delete does not use a report */ + if (_report) { + dm_report_free(_report); + _report = NULL; + } + if (!_switches[REGION_ID_ARG] && !allregions) { err("Please specify a region_id."); return 0; @@ -4462,12 +4468,6 @@ static int _stats_delete(CMD_ARGS) name = argv[1]; } - /* delete does not use a report */ - if (_report) { - dm_report_free(_report); - _report = NULL; - } - if (_switches[ALL_PROGRAMS_ARG]) program_id = DM_STATS_ALL_PROGRAMS; @@ -4598,6 +4598,12 @@ static int _stats_print(CMD_ARGS) unsigned clear = (unsigned) _switches[CLEAR_ARG]; int allregions = _switches[ALL_REGIONS_ARG]; + /* print does not use a report */ + if (_report) { + dm_report_free(_report); + _report = NULL; + } + if (!_switches[REGION_ID_ARG] && !allregions) { err("Please specify a region_id."); return 0; @@ -4611,12 +4617,6 @@ static int _stats_print(CMD_ARGS) name = argv[1]; } - /* print does not use a report */ - if (_report) { - dm_report_free(_report); - _report = NULL; - } - region_id = (uint64_t) _int_args[REGION_ID_ARG]; dms = dm_stats_create(DM_STATS_PROGRAM_ID); |