From: Zdenek Kabelac Date: Thu, 7 Jan 2010 14:40:46 +0000 (+0000) Subject: Add macros outsize() for out_size() and outhint() for out_hint() that check X-Git-Tag: v2_02_91~2432 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=1e13fa7a6a342457bcc0e8406bfb7113b677b9d3;p=lvm2.git Add macros outsize() for out_size() and outhint() for out_hint() that check for errors in a similar way as outf() for out_text(). --- diff --git a/WHATS_NEW b/WHATS_NEW index f4fb979ae..f264951c7 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.57 - ==================================== + Add macros outsize() and outhint(). Use offsetof() macro for FIELD() macro in lib/report/report.c. Rename mirror_device_fault_policy to mirror_image_fault policy. Remove empty PV devices if lvconvert --repair is using defined policies. diff --git a/lib/format_text/export.c b/lib/format_text/export.c index 72d61585b..f776957e1 100644 --- a/lib/format_text/export.c +++ b/lib/format_text/export.c @@ -386,9 +386,8 @@ static int _print_vg(struct formatter *f, struct volume_group *vg) if (vg->system_id && *vg->system_id) outf(f, "system_id = \"%s\"", vg->system_id); - if (!out_size(f, (uint64_t) vg->extent_size, "extent_size = %u", - vg->extent_size)) - return_0; + outsize(f, (uint64_t) vg->extent_size, "extent_size = %u", + vg->extent_size); outf(f, "max_lv = %u", vg->max_lv); outf(f, "max_pv = %u", vg->max_pv); @@ -453,9 +452,8 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg) return 0; } - if (!out_hint(f, "device = \"%s\"", - escape_double_quotes(buf, pv_dev_name(pv)))) - return_0; + outhint(f, "device = \"%s\"", + escape_double_quotes(buf, pv_dev_name(pv))); outnl(f); if (!_print_flag_config(f, pv->status, PV_FLAGS)) @@ -467,13 +465,11 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg) outf(f, "tags = %s", buffer); } - if (!out_size(f, pv->size, "dev_size = %" PRIu64, pv->size)) - return_0; + outsize(f, pv->size, "dev_size = %" PRIu64, pv->size); outf(f, "pe_start = %" PRIu64, pv->pe_start); - if (!out_size(f, vg->extent_size * (uint64_t) pv->pe_count, - "pe_count = %u", pv->pe_count)) - return_0; + outsize(f, vg->extent_size * (uint64_t) pv->pe_count, + "pe_count = %u", pv->pe_count); _dec_indent(f); outf(f, "}"); @@ -493,9 +489,8 @@ static int _print_segment(struct formatter *f, struct volume_group *vg, _inc_indent(f); outf(f, "start_extent = %u", seg->le); - if (!out_size(f, (uint64_t) seg->len * vg->extent_size, - "extent_count = %u", seg->len)) - return_0; + outsize(f, (uint64_t) seg->len * vg->extent_size, + "extent_count = %u", seg->len); outnl(f); outf(f, "type = \"%s\"", seg->segtype->name); diff --git a/lib/format_text/text_export.h b/lib/format_text/text_export.h index cdba82f42..f1b69e1b5 100644 --- a/lib/format_text/text_export.h +++ b/lib/format_text/text_export.h @@ -16,6 +16,8 @@ #ifndef _LVM_TEXT_EXPORT_H #define _LVM_TEXT_EXPORT_H +#define outsize(args...) do {if (!out_size(args)) return_0;} while (0) +#define outhint(args...) do {if (!out_hint(args)) return_0;} while (0) #define outf(args...) do {if (!out_text(args)) return_0;} while (0) #define outnl(f) do {if (!out_newline(f)) return_0;} while (0)