mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
device_mapper: query for json report once
Remember _is_json_report() check for whole function.
This commit is contained in:
parent
f59fa69507
commit
fd9f7d10ca
@ -4854,6 +4854,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
struct dm_report_field *field;
|
||||
struct dm_list *last_rowh;
|
||||
int do_field_delim;
|
||||
int is_json_report = _is_json_report(rh);
|
||||
char *line;
|
||||
|
||||
/* If headings not printed yet, calculate field widths and print them */
|
||||
@ -4873,7 +4874,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_is_json_report(rh)) {
|
||||
if (is_json_report) {
|
||||
if (!dm_pool_grow_object(rh->mem, JSON_OBJECT_START, 0)) {
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
goto bad;
|
||||
@ -4888,7 +4889,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
continue;
|
||||
|
||||
if (do_field_delim) {
|
||||
if (_is_json_report(rh)) {
|
||||
if (is_json_report) {
|
||||
if (!dm_pool_grow_object(rh->mem, JSON_SEPARATOR, 0) ||
|
||||
!dm_pool_grow_object(rh->mem, JSON_SPACE, 0)) {
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
@ -4910,7 +4911,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
dm_list_del(&field->list);
|
||||
}
|
||||
|
||||
if (_is_json_report(rh)) {
|
||||
if (is_json_report) {
|
||||
if (!dm_pool_grow_object(rh->mem, JSON_OBJECT_END, 0)) {
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
goto bad;
|
||||
|
@ -4852,6 +4852,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
struct dm_report_field *field;
|
||||
struct dm_list *last_rowh;
|
||||
int do_field_delim;
|
||||
int is_json_report = _is_json_report(rh);
|
||||
char *line;
|
||||
|
||||
/* If headings not printed yet, calculate field widths and print them */
|
||||
@ -4871,7 +4872,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_is_json_report(rh)) {
|
||||
if (is_json_report) {
|
||||
if (!dm_pool_grow_object(rh->mem, JSON_OBJECT_START, 0)) {
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
goto bad;
|
||||
@ -4886,7 +4887,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
continue;
|
||||
|
||||
if (do_field_delim) {
|
||||
if (_is_json_report(rh)) {
|
||||
if (is_json_report) {
|
||||
if (!dm_pool_grow_object(rh->mem, JSON_SEPARATOR, 0) ||
|
||||
!dm_pool_grow_object(rh->mem, JSON_SPACE, 0)) {
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
@ -4908,7 +4909,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
dm_list_del(&field->list);
|
||||
}
|
||||
|
||||
if (_is_json_report(rh)) {
|
||||
if (is_json_report) {
|
||||
if (!dm_pool_grow_object(rh->mem, JSON_OBJECT_END, 0)) {
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
goto bad;
|
||||
|
Loading…
Reference in New Issue
Block a user