Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl2/lvm2/dist/lib/report Pull in report.c, 1.107 f...



details:   https://anonhg.NetBSD.org/src/rev/27509a55c3a3
branches:  trunk
changeset: 765562:27509a55c3a3
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon May 30 16:03:02 2011 +0000

description:
Pull in report.c, 1.107 from upstream:
Use offsetof() macro and avoid defining dummy static union for FIELD()
macro.  Makes it compilable by clang compiler.

diffstat:

 external/gpl2/lvm2/dist/lib/report/report.c |  27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diffs (56 lines):

diff -r 7a144f51090d -r 27509a55c3a3 external/gpl2/lvm2/dist/lib/report/report.c
--- a/external/gpl2/lvm2/dist/lib/report/report.c       Mon May 30 15:38:07 2011 +0000
+++ b/external/gpl2/lvm2/dist/lib/report/report.c       Mon May 30 16:03:02 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: report.c,v 1.1.1.3 2009/12/02 00:26:46 haad Exp $      */
+/*     $NetBSD: report.c,v 1.2 2011/05/30 16:03:02 joerg Exp $ */
 
 /*
  * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
@@ -26,6 +26,8 @@
 #include "str_list.h"
 #include "lvmcache.h"
 
+#include <stddef.h> /* offsetof() */
+
 struct lvm_report_object {
        struct volume_group *vg;
        struct logical_volume *lv;
@@ -34,17 +36,6 @@
        struct pv_segment *pvseg;
 };
 
-/*
- * For macro use
- */
-static union {
-       struct physical_volume _pv;
-       struct logical_volume _lv;
-       struct volume_group _vg;
-       struct lv_segment _seg;
-       struct pv_segment _pvseg;
-} _dummy;
-
 static char _alloc_policy_char(alloc_policy_t alloc)
 {
        switch (alloc) {
@@ -1158,9 +1149,17 @@
 
 #define STR DM_REPORT_FIELD_TYPE_STRING
 #define NUM DM_REPORT_FIELD_TYPE_NUMBER
-#define FIELD(type, strct, sorttype, head, field, width, func, id, desc) {type, sorttype, (off_t)((uintptr_t)&_dummy._ ## strct.field - (uintptr_t)&_dummy._ ## strct), width, id, head, &_ ## func ## 
_disp, desc},
+#define FIELD(type, strct, sorttype, head, field, width, func, id, desc) \
+       {type, sorttype, offsetof(type_ ## strct, field), width, \
+        id, head, &_ ## func ## _disp, desc},
 
-static struct dm_report_field_type _fields[] = {
+typedef struct physical_volume type_pv;
+typedef struct logical_volume type_lv;
+typedef struct volume_group type_vg;
+typedef struct lv_segment type_seg;
+typedef struct pv_segment type_pvseg;
+
+static const struct dm_report_field_type _fields[] = {
 #include "columns.h"
 {0, 0, 0, 0, "", "", NULL, NULL},
 };



Home | Main Index | Thread Index | Old Index