1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cov: validate list emptiness

Emit internal error for empty list.
This commit is contained in:
Zdenek Kabelac 2024-07-29 16:53:28 +02:00
parent d1c6da2f66
commit e150931fc4
4 changed files with 10 additions and 1 deletions

View File

@ -4757,6 +4757,8 @@ static int _output_as_rows(struct dm_report *rh)
dm_list_iterate_items(fp, &rh->field_props) { dm_list_iterate_items(fp, &rh->field_props) {
if (fp->flags & FLD_HIDDEN) { if (fp->flags & FLD_HIDDEN) {
dm_list_iterate_items(row, &rh->rows) { dm_list_iterate_items(row, &rh->rows) {
if (dm_list_empty(&row->fields))
continue;
field = dm_list_item(dm_list_first(&row->fields), struct dm_report_field); field = dm_list_item(dm_list_first(&row->fields), struct dm_report_field);
dm_list_del(&field->list); dm_list_del(&field->list);
} }

View File

@ -1959,7 +1959,7 @@ static uint32_t _stripes_per_mimage(struct lv_segment *seg)
if (seg_is_mirrored(seg) && seg->area_count && seg_type(seg, 0) == AREA_LV) { if (seg_is_mirrored(seg) && seg->area_count && seg_type(seg, 0) == AREA_LV) {
last_lvseg = dm_list_item(dm_list_last(&seg_lv(seg, 0)->segments), struct lv_segment); last_lvseg = dm_list_item(dm_list_last(&seg_lv(seg, 0)->segments), struct lv_segment);
if (seg_is_striped(last_lvseg)) if (last_lvseg && seg_is_striped(last_lvseg))
return last_lvseg->area_count; return last_lvseg->area_count;
} }

View File

@ -4755,6 +4755,8 @@ static int _output_as_rows(struct dm_report *rh)
dm_list_iterate_items(fp, &rh->field_props) { dm_list_iterate_items(fp, &rh->field_props) {
if (fp->flags & FLD_HIDDEN) { if (fp->flags & FLD_HIDDEN) {
dm_list_iterate_items(row, &rh->rows) { dm_list_iterate_items(row, &rh->rows) {
if (dm_list_empty(&row->fields))
continue;
field = dm_list_item(dm_list_first(&row->fields), struct dm_report_field); field = dm_list_item(dm_list_first(&row->fields), struct dm_report_field);
dm_list_del(&field->list); dm_list_del(&field->list);
} }

View File

@ -5792,6 +5792,11 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
int is_lockd; int is_lockd;
int ret = 0; int ret = 0;
if (dm_list_empty(&lr->poll_idls)) {
log_error(INTERNAL_ERROR "Cannot detach writecache.");
return 0;
}
idl = dm_list_item(dm_list_first(&lr->poll_idls), struct convert_poll_id_list); idl = dm_list_item(dm_list_first(&lr->poll_idls), struct convert_poll_id_list);
id = idl->id; id = idl->id;
is_lockd = lvmcache_vg_is_lockd_type(cmd, id->vg_name, NULL); is_lockd = lvmcache_vg_is_lockd_type(cmd, id->vg_name, NULL);