1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib
Tony Asleson 91f737383c lvm2app: Add signed numerical property values
Currently lvm2app properties have the following structure:

typedef struct lvm_property_value {
        uint32_t is_settable:1;
        uint32_t is_string:1;
        uint32_t is_integer:1;
        uint32_t is_valid:1;
        uint32_t padding:28;
        union {
                const char *string;
                uint64_t integer;
        } value;
} lvm_property_value_t;

which assumes that numerical values were in the range of 0 to 2**64-1.  However,
some of the properties were 'signed', like LV major/minor numbers and some
reserved values for properties that represent percentages.  Thus when the
values were retrieved they were in two's complement notation.  So for a -1
major number the API user would get a value of 18446744073709551615.  The
API user could cast the returned value to an int64_t to handle this, but that
requires the API developer to look at the source code and determine when it
should be done.

This change modifies the return property structure to:

typedef struct lvm_property_value {
        uint32_t is_settable:1;
        uint32_t is_string:1;
        uint32_t is_integer:1;
        uint32_t is_valid:1;
        uint32_t is_signed:1;
        uint32_t padding:27;
        union {
                const char *string;
                uint64_t integer;
                int64_t signed_integer;
        } value;
} lvm_property_value_t;

With this addition the API user can interrogate that the value is numerical,
(is_integer = 1) and subsequently check if it's signed (is_signed = 1) too.
If signed, then the API developer should use the union's signed_integer to
avoid casting.

This change maintains backwards compatibility as the structure size remains
unchanged and integer value remains unchanged.  Only the additional bit
taken from the pad is utilized.

Bugzilla reference:
https://bugzilla.redhat.com/show_bug.cgi?id=838257

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2015-05-06 08:51:04 -05:00
..
activate config: fix check_options array 2015-04-23 10:35:34 -05:00
cache devices: improve handling of duplicate PVs 2015-04-28 10:41:32 -05:00
cache_segtype cache: use writethrough cache_mode for older metadata 2015-01-29 12:05:58 +01:00
commands systemid: Use correct mempool. 2015-03-18 23:25:30 +00:00
config config: add CFG_DEFAULT_COMMENTED to comment out default value on output 2015-04-30 18:26:56 +02:00
datastruct datastruct: Add str_list_add_list. 2015-03-26 18:30:37 +00:00
device devices: improve handling of duplicate PVs 2015-04-28 10:41:32 -05:00
display display: fix return values 2015-03-10 14:10:18 +01:00
error segtype: drop cmdcontex pointer 2014-10-30 23:58:49 +01:00
filters config: use timestamp with nanosecond precision 2015-03-18 13:42:56 +01:00
format1 cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
format_pool cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
format_text alloc: Respect cling_tag_list in contig alloc. 2015-04-11 01:55:24 +01:00
freeseg segtype: drop cmdcontex pointer 2014-10-30 23:58:49 +01:00
label cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
locking locking: rename LCK_CONVERT 2014-11-18 16:50:49 +01:00
log debug: change envvar 2015-04-20 19:18:56 +02:00
metadata raid: reread status when 0 is reported 2015-05-04 13:09:05 +02:00
mirror cmirror: Adjust region size to work around CPG msg limit to avoid hang. 2015-02-25 14:42:15 -06:00
misc lvm-file: wrapper to read ctim from stat 2015-03-18 13:42:24 +01:00
mm memory: disable check with valgrind pool build 2015-02-12 15:40:53 +01:00
properties lvm2app: Add signed numerical property values 2015-05-06 08:51:04 -05:00
raid segtype: add SEG_ONLY_EXCLUSIVE flag 2014-11-10 22:05:48 +01:00
replicator cleanup: drop default implementation 2014-10-24 16:39:31 +02:00
report lvm2app: Add signed numerical property values 2015-05-06 08:51:04 -05:00
snapshot segtype: add SEG_ONLY_EXCLUSIVE flag 2014-11-10 22:05:48 +01:00
striped segtype: drop cmdcontex pointer 2014-10-30 23:58:49 +01:00
thin cleanup: add lv_is_error_when_full() macro 2015-01-20 14:52:06 +01:00
unknown segtype: drop cmdcontex pointer 2014-10-30 23:58:49 +01:00
uuid cleanup: drop unused define 2014-03-12 19:12:34 +01:00
zero cleanup: remove unused headers 2014-11-13 17:49:42 +01:00
Makefile.in configure: Look for valgrind.h independently of VALGRIND_POOLS. 2015-02-05 13:50:34 +01:00