]> sourceware.org Git - lvm2.git/commitdiff
Use offsetof() macro and avoid defining dummy static union for FIELD() macro.
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 7 Jan 2010 14:37:11 +0000 (14:37 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 7 Jan 2010 14:37:11 +0000 (14:37 +0000)
Makes it compilable by clang compiler.

WHATS_NEW
lib/report/report.c

index 8270f74deb44fc8b1d120577d61e494c1b622a9a..f4fb979aeae1d2b08addaafb5320252e13ff793e 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  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.
   Use fixed buffer to prevent stack overflow in persistent filter dump.
index 54192d56b5b7c55c74acccfaac5bf58a6be4a83e..31e31745d9adafc45164a076be1243a96415f9d6 100644 (file)
@@ -24,6 +24,8 @@
 #include "str_list.h"
 #include "lvmcache.h"
 
+#include <stddef.h> /* offsetof() */
+
 struct lvm_report_object {
        struct volume_group *vg;
        struct logical_volume *lv;
@@ -32,17 +34,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) {
@@ -1156,9 +1147,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},
+
+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},
 };
This page took 0.043415 seconds and 5 git commands to generate.