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

const: use common error path

Instead of defining  _field_selection_value_alloc_failed_msg[],
use common error path code for printing field_id.
This commit is contained in:
Zdenek Kabelac 2024-05-03 15:18:46 +02:00
parent 8bbd00162b
commit e0bd66b73a
2 changed files with 16 additions and 10 deletions

View File

@ -3516,7 +3516,6 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
struct reserved_value_wrapper *rvw, struct reserved_value_wrapper *rvw,
void *custom) void *custom)
{ {
static const char *_field_selection_value_alloc_failed_msg = "dm_report: struct field_selection_value allocation failed for selection field %s";
const struct dm_report_field_type *fields = implicit ? _implicit_report_fields const struct dm_report_field_type *fields = implicit ? _implicit_report_fields
: rh->fields; : rh->fields;
struct field_properties *fp, *found = NULL; struct field_properties *fp, *found = NULL;
@ -3564,8 +3563,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
} }
if (!(fs->value = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) { if (!(fs->value = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) {
log_error(_field_selection_value_alloc_failed_msg, field_id); stack;
goto error; goto error_field_id;
} }
if (((rvw->reserved && (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)) || if (((rvw->reserved && (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)) ||
@ -3573,8 +3572,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
custom && ((struct time_value *) custom)->range)) custom && ((struct time_value *) custom)->range))
&& &&
!(fs->value->next = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) { !(fs->value->next = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) {
log_error(_field_selection_value_alloc_failed_msg, field_id); stack;
goto error; goto error_field_id;
} }
fs->fp = found; fs->fp = found;
@ -3723,6 +3722,10 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
} }
return fs; return fs;
error_field_id:
log_error("dm_report: struct field_selection_value allocation failed for selection field %s",
field_id);
goto error;
bad: bad:
log_error(INTERNAL_ERROR "Forbiden NULL custom detected."); log_error(INTERNAL_ERROR "Forbiden NULL custom detected.");
error: error:

View File

@ -3514,7 +3514,6 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
struct reserved_value_wrapper *rvw, struct reserved_value_wrapper *rvw,
void *custom) void *custom)
{ {
static const char *_field_selection_value_alloc_failed_msg = "dm_report: struct field_selection_value allocation failed for selection field %s";
const struct dm_report_field_type *fields = implicit ? _implicit_report_fields const struct dm_report_field_type *fields = implicit ? _implicit_report_fields
: rh->fields; : rh->fields;
struct field_properties *fp, *found = NULL; struct field_properties *fp, *found = NULL;
@ -3562,8 +3561,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
} }
if (!(fs->value = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) { if (!(fs->value = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) {
log_error(_field_selection_value_alloc_failed_msg, field_id); stack;
goto error; goto error_field_id;
} }
if (((rvw->reserved && (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)) || if (((rvw->reserved && (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)) ||
@ -3571,8 +3570,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
custom && ((struct time_value *) custom)->range)) custom && ((struct time_value *) custom)->range))
&& &&
!(fs->value->next = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) { !(fs->value->next = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) {
log_error(_field_selection_value_alloc_failed_msg, field_id); stack;
goto error; goto error_field_id;
} }
fs->fp = found; fs->fp = found;
@ -3721,6 +3720,10 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
} }
return fs; return fs;
error_field_id:
log_error("dm_report: struct field_selection_value allocation failed for selection field %s",
field_id);
goto error;
bad: bad:
log_error(INTERNAL_ERROR "Forbiden NULL custom detected."); log_error(INTERNAL_ERROR "Forbiden NULL custom detected.");
error: error: