Module Name: src Committed By: joerg Date: Mon May 30 16:03:02 UTC 2011
Modified Files: src/external/gpl2/lvm2/dist/lib/report: report.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1.1.3 -r1.2 src/external/gpl2/lvm2/dist/lib/report/report.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl2/lvm2/dist/lib/report/report.c diff -u src/external/gpl2/lvm2/dist/lib/report/report.c:1.1.1.3 src/external/gpl2/lvm2/dist/lib/report/report.c:1.2 --- src/external/gpl2/lvm2/dist/lib/report/report.c:1.1.1.3 Wed Dec 2 00:26:46 2009 +++ src/external/gpl2/lvm2/dist/lib/report/report.c Mon May 30 16:03:02 2011 @@ -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}, + +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 struct dm_report_field_type _fields[] = { +static const struct dm_report_field_type _fields[] = { #include "columns.h" {0, 0, 0, 0, "", "", NULL, NULL}, };