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.
This commit is contained in:
joerg 2011-05-30 16:03:02 +00:00
parent f457cf3348
commit 015f3042c3

View File

@ -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 lvm_report_object {
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 @@ static const struct dm_report_object_type _report_types[] = {
#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},
};