[PATCH 07/14] Refactor and add code for (lv) 'mirror_log' get function.
Petr Rockai <[email protected]>
| Newsgroups | dev.linux.lists.lvm-devel |
|---|---|
| Message-ID | <[email protected].> |
Dave Wysochanski <[email protected]> writes: > Signed-off-by: Dave Wysochanski <[email protected]> Reviewed-By: Petr Rockai <[email protected]> > --- a/lib/metadata/lv.c > +++ b/lib/metadata/lv.c > @@ -17,6 +17,22 @@ > #include "metadata.h" > #include "activate.h" > #include "toolcontext.h" > +#include "segtype.h" > + > +char *lv_mirror_log_dup(struct dm_pool *mem, const struct logical_volume *lv) > +{ > + struct lv_segment *seg; > + const char *name = NULL; > + > + dm_list_iterate_items(seg, &lv->segments) { > + if (!seg_is_mirrored(seg) || !seg->log_lv) > + continue; > + name = seg->log_lv->name; > + } > + if (name) > + return dm_pool_strndup(mem, name, strlen(name) + 1); > + return NULL; > +} strndup & unnecessary temporary again > --- a/lib/report/properties.c > +++ b/lib/report/properties.c > @@ -135,7 +135,7 @@ GET_LV_STR_PROPERTY_FN(convert_lv, lv_convert_lv_dup(lv->vg->vgmem, lv)) > #define _convert_lv_set _not_implemented_set > GET_LV_STR_PROPERTY_FN(lv_tags, lv_tags_dup(lv)) > #define _lv_tags_set _not_implemented_set > -#define _mirror_log_get _not_implemented_get > +GET_LV_STR_PROPERTY_FN(mirror_log, lv_mirror_log_dup(lv->vg->vgmem, lv)) > #define _mirror_log_set _not_implemented_set > #define _modules_get _not_implemented_get > #define _modules_set _not_implemented_set > --- a/lib/report/report.c > +++ b/lib/report/report.c > @@ -297,14 +297,11 @@ static int _loglv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(( > const void *data, void *private __attribute__((unused))) > { > const struct logical_volume *lv = (const struct logical_volume *) data; > - struct lv_segment *seg; > + const char *name; > > - dm_list_iterate_items(seg, &lv->segments) { > - if (!seg_is_mirrored(seg) || !seg->log_lv) > - continue; > - return dm_report_field_string(rh, field, > - (const char **) &seg->log_lv->name); > - } > + name = lv_mirror_log_dup(mem, lv); > + if (name) > + return dm_report_field_string(rh, field, &name); > > dm_report_field_set_value(field, "", NULL); > return 1; OK. Your other patches use if ((name = ...)) style, maybe use it here as well? (Or change the others to use this style instead?) Yours, Petr.