mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: report: add dm_report_group_output_and_pop_all
The dm_report_group_output_and_pop_all calls dm_report_output and dm_report_group_pop for all the items that are currently in report group. This is just a shortcut that makes it easier to output and pop group's content so the group handle can be reused again without a need to initialize and configure it again. The functionality of dm_report_group_output_and_pop_all is the same as dm_report_destroy but without destroying the report group handle.
This commit is contained in:
parent
d86caf952e
commit
7d1125e5b7
@ -1 +1,2 @@
|
|||||||
dm_report_destroy_rows
|
dm_report_destroy_rows
|
||||||
|
dm_report_group_output_and_pop_all
|
||||||
|
@ -2974,6 +2974,7 @@ typedef enum {
|
|||||||
struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data);
|
struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data);
|
||||||
int dm_report_group_push(struct dm_report_group *group, struct dm_report *report, void *data);
|
int dm_report_group_push(struct dm_report_group *group, struct dm_report *report, void *data);
|
||||||
int dm_report_group_pop(struct dm_report_group *group);
|
int dm_report_group_pop(struct dm_report_group *group);
|
||||||
|
int dm_report_group_output_and_pop_all(struct dm_report_group *group);
|
||||||
int dm_report_group_destroy(struct dm_report_group *group);
|
int dm_report_group_destroy(struct dm_report_group *group);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5028,57 +5028,40 @@ int dm_report_group_pop(struct dm_report_group *group)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _report_group_destroy_single(void)
|
int dm_report_group_output_and_pop_all(struct dm_report_group *group)
|
||||||
{
|
{
|
||||||
return 1;
|
struct report_group_item *item, *tmp_item;
|
||||||
}
|
|
||||||
|
|
||||||
static int _report_group_destroy_basic(void)
|
dm_list_iterate_items_safe(item, tmp_item, &group->items) {
|
||||||
{
|
if (!item->parent) {
|
||||||
return 1;
|
item->store.finished_count = 0;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
if (item->report && !dm_report_output(item->report))
|
||||||
|
return_0;
|
||||||
|
if (!dm_report_group_pop(group))
|
||||||
|
return_0;
|
||||||
|
}
|
||||||
|
|
||||||
static int _report_group_destroy_json(struct dm_report_group *group)
|
if (group->type == DM_REPORT_GROUP_JSON) {
|
||||||
{
|
|
||||||
_json_output_start(group);
|
_json_output_start(group);
|
||||||
log_print(JSON_OBJECT_END);
|
log_print(JSON_OBJECT_END);
|
||||||
|
group->indent -= JSON_INDENT_UNIT;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dm_report_group_destroy(struct dm_report_group *group)
|
int dm_report_group_destroy(struct dm_report_group *group)
|
||||||
{
|
{
|
||||||
struct report_group_item *item, *tmp_item;
|
int r = 1;
|
||||||
int r = 0;
|
|
||||||
|
|
||||||
if (!group)
|
if (!group)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
dm_list_iterate_items_safe(item, tmp_item, &group->items) {
|
if (!dm_report_group_output_and_pop_all(group))
|
||||||
if (item->report && !dm_report_output(item->report))
|
r = 0;
|
||||||
goto_out;
|
|
||||||
if (!dm_report_group_pop(group))
|
|
||||||
goto_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (group->type) {
|
|
||||||
case DM_REPORT_GROUP_SINGLE:
|
|
||||||
if (!_report_group_destroy_single())
|
|
||||||
goto_out;
|
|
||||||
break;
|
|
||||||
case DM_REPORT_GROUP_BASIC:
|
|
||||||
if (!_report_group_destroy_basic())
|
|
||||||
goto_out;
|
|
||||||
break;
|
|
||||||
case DM_REPORT_GROUP_JSON:
|
|
||||||
if (!_report_group_destroy_json(group))
|
|
||||||
goto_out;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = 1;
|
|
||||||
out:
|
|
||||||
dm_pool_destroy(group->mem);
|
dm_pool_destroy(group->mem);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user