Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Device-mapper Development (http://www.linux-archive.org/device-mapper-development/)
-   -   Export outsz() and outhnt() for modules (http://www.linux-archive.org/device-mapper-development/273362-export-outsz-outhnt-modules.html)

Zdenek Kabelac 11-02-2009 01:20 PM

Export outsz() and outhnt() for modules
 
Adding macro outsz() for out_size() and outhnt() for out_hint()
that checks for error in a similar way as outf() does for out_text()

Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/format_text/export.c | 23 +++++++++--------------
lib/format_text/text_export.h | 2 ++
2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 7f7d0de..f25b80e 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;
+ outsz(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;
+ outhnt(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;
+ outsz(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;
+ outsz(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;
+ outsz(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 cdba82f..a452439 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 outsz(args...) do {if (!out_size(args)) return_0;} while (0)
+#define outhnt(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)

--
1.6.5.1

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

Alasdair G Kergon 11-02-2009 01:54 PM

Export outsz() and outhnt() for modules
 
On Mon, Nov 02, 2009 at 03:20:07PM +0100, Zdenek Kabelac wrote:
> Adding macro outsz() for out_size() and outhnt() for out_hint()
> that checks for error in a similar way as outf() does for out_text()

Ack.

outhint rather than outhnt perhaps?

Alasdair

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


All times are GMT. The time now is 11:03 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.