mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
cleanup: use #define for field's quote and pair character and also for the error msg while extending output line
This commit is contained in:
parent
248f47d489
commit
f2e59e05ed
@ -4175,6 +4175,11 @@ static int _sort_rows(struct dm_report *rh)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define STANDARD_QUOTE "\'"
|
||||||
|
#define STANDARD_PAIR "="
|
||||||
|
|
||||||
|
#define UNABLE_TO_EXTEND_OUTPUT_LINE_MSG "dm_report: Unable to extend output line"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Produce report output
|
* Produce report output
|
||||||
*/
|
*/
|
||||||
@ -4196,27 +4201,27 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dm_pool_grow_object(rh->mem, rh->output_field_name_prefix, 0)) {
|
if (!dm_pool_grow_object(rh->mem, rh->output_field_name_prefix, 0)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
dm_free(field_id);
|
dm_free(field_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dm_pool_grow_object(rh->mem, _toupperstr(field_id), 0)) {
|
if (!dm_pool_grow_object(rh->mem, _toupperstr(field_id), 0)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
dm_free(field_id);
|
dm_free(field_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dm_free(field_id);
|
dm_free(field_id);
|
||||||
|
|
||||||
if (!dm_pool_grow_object(rh->mem, "=", 1)) {
|
if (!dm_pool_grow_object(rh->mem, STANDARD_PAIR, 1)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED) &&
|
if (!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED) &&
|
||||||
!dm_pool_grow_object(rh->mem, "\'", 1)) {
|
!dm_pool_grow_object(rh->mem, STANDARD_QUOTE, 1)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4225,7 +4230,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
|
|||||||
width = field->props->width;
|
width = field->props->width;
|
||||||
if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
|
if (!(rh->flags & DM_REPORT_OUTPUT_ALIGNED)) {
|
||||||
if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
|
if (!dm_pool_grow_object(rh->mem, repstr, 0)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -4248,7 +4253,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (!dm_pool_grow_object(rh->mem, buf, width)) {
|
if (!dm_pool_grow_object(rh->mem, buf, width)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
} else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
|
} else if (align & DM_REPORT_FIELD_ALIGN_RIGHT) {
|
||||||
@ -4258,7 +4263,7 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (!dm_pool_grow_object(rh->mem, buf, width)) {
|
if (!dm_pool_grow_object(rh->mem, buf, width)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4266,8 +4271,8 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
|
|||||||
|
|
||||||
if ((rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) &&
|
if ((rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) &&
|
||||||
!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED))
|
!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED))
|
||||||
if (!dm_pool_grow_object(rh->mem, "\'", 1)) {
|
if (!dm_pool_grow_object(rh->mem, STANDARD_QUOTE, 1)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4345,7 +4350,7 @@ static int _output_as_rows(struct dm_report *rh)
|
|||||||
|
|
||||||
if (!dm_list_end(&rh->rows, &row->list))
|
if (!dm_list_end(&rh->rows, &row->list))
|
||||||
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
|
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4393,7 +4398,7 @@ static int _output_as_columns(struct dm_report *rh)
|
|||||||
|
|
||||||
if (!dm_list_end(&row->fields, fh))
|
if (!dm_list_end(&row->fields, fh))
|
||||||
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
|
if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
|
||||||
log_error("dm_report: Unable to extend output line");
|
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user