LVM2/lib/report properties.c
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2010-08-20 13:02:39
Modified files:
lib/report : properties.c
Log message:
Define GET_NUM_PROPERTY_FN macro to simplify numeric property 'get' functions.
lib/report/properties.c +9 -0
@@ -20,6 +20,15 @@#include "lvm-types.h" #include "metadata.h" +#define GET_NUM_PROPERTY_FN (NAME ,VALUE ) \ +static int _ ## NAME ## _get (void *obj, struct lvm_property_type *prop) \ +{ \ + struct volume_group *vg = (struct volume_group *)obj; \ +\ + prop->v.n_val = VALUE; \ + return 1; \ +} +static int _not_implemented (void *obj,struct lvm_property_type *prop) {log_errno (ENOSYS ,"Function not implemented" );
Dne 20.8.2010 15:02, wysochanski at sourceware.org napsal(a):
Quoted 18 lines
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2010-08-20 13:02:39Modified files:
lib/report :properties.cLog message:
DefineGET_NUM_PROPERTY_FNmacro to simplify numeric property 'get' functions.lib/report/properties.c +0
-0@@ -20,6 +20,15 @@#include "lvm-types.h" #include "metadata.h"
lib/report/properties.c line 31
Quoted 10 lines
lib/report/properties.c +9
-0+#define GET_NUM_PROPERTY_FN (NAME ,VALUE ) \ +static int _ ## NAME ## _get (void *obj, struct lvm_property_type *prop) \ +{ \ + struct volume_group *vg = (struct volume_group *)obj; \ +\ + prop->v.n_val = VALUE; \ + return 1; \ +} +
Is this going to be part of liblvm API - or it's only purpose is to be used through liblvm2api - in that case it would be better to have this code compiled as a part of liblvm2api library and not increasing size of liblvm ?
Zdenek
Quoted 20 lines · Zdenek Kabelac
Dne 20.8.2010 15:02, wysochanski at sourceware.org napsal(a):
Quoted 19 lines
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2010-08-20 13:02:39Modified files:
lib/report :properties.cLog message:
DefineGET_NUM_PROPERTY_FNmacro to simplify numeric property 'get' functions.lib/report/properties.c +0
-0@@ -20,6 +20,15 @@#include "lvm-types.h" #include "metadata.h"
Quoted 15 lines
lib/report/properties.c line 31
Quoted 9 lines
lib/report/properties.c +9
-0+#define GET_NUM_PROPERTY_FN (NAME ,VALUE ) \ +static int _ ## NAME ## _get (void *obj, struct lvm_property_type *prop) \ +{ \ + struct volume_group *vg = (struct volume_group *)obj; \ +\ + prop->v.n_val = VALUE; \ + return 1; \ +} +Is this going to be part of liblvm API - or it's only purpose is to be used through liblvm2api - in that case it would be better to have this code compiled as a part of liblvm2api library and not increasing size of liblvm ?
I originally had properties.[ch] inside liblvm subdirectory, but then reconsidered based on:
1) Longer term the goal is for tools to call the library. As a result, I try to put only what is absolutely necessary inside liblvm.
2) Based on the fact properties.c included lib/report/columns.h, it seemed like extending the reporting infrastructure was better done inside lib instead of liblvm
That said, I had not considered size implications - can you be more specific as to your concerns there? Is it something specific like initrd, or a design concern?
I think it would fit better under liblvm at the moment, but it really is no big deal.
If in future tools call the library they'll already be including that code then too.
columns.h can be added to include/.symlinks to facilitate this.
Alasdair