mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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.
This commit is contained in:
parent
829384f46d
commit
098528513f
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user