diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2017-08-24 10:46:10 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2017-09-04 13:09:13 +0200 |
commit | f7abe0ecd4973dfe36944b916c5b9cf8ec199b8a (patch) | |
tree | 99ca676afbfcf2da0182b3bf99811d000cb69c58 /block/parallels.c | |
parent | 788b305c91398f18e5952667b929d7f45e2c211c (diff) |
qapi: Change data type of the FOO_lookup generated for enum FOO
Currently, a FOO_lookup is an array of strings terminated by a NULL
sentinel.
A future patch will generate enums with "holes". NULL-termination
will cease to work then.
To prepare for that, store the length in the FOO_lookup by wrapping it
in a struct and adding a member for the length.
The sentinel will be dropped next.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-13-marcandre.lureau@redhat.com>
[Basically redone]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-16-git-send-email-armbru@redhat.com>
[Rebased]
Diffstat (limited to 'block/parallels.c')
-rw-r--r-- | block/parallels.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/block/parallels.c b/block/parallels.c index d812210b4f..cce7336cac 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -68,13 +68,15 @@ typedef enum ParallelsPreallocMode { PRL_PREALLOC_MODE__MAX = 2, } ParallelsPreallocMode; -static const char *prealloc_mode_lookup[] = { - "falloc", - "truncate", - NULL, +static QEnumLookup prealloc_mode_lookup = { + .array = (const char *const[]) { + "falloc", + "truncate", + NULL, + }, + .size = PRL_PREALLOC_MODE__MAX }; - typedef struct BDRVParallelsState { /** Locking is conservative, the lock protects * - image file extending (truncate, fallocate) @@ -695,7 +697,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, qemu_opt_get_size_del(opts, PARALLELS_OPT_PREALLOC_SIZE, 0); s->prealloc_size = MAX(s->tracks, s->prealloc_size >> BDRV_SECTOR_BITS); buf = qemu_opt_get_del(opts, PARALLELS_OPT_PREALLOC_MODE); - s->prealloc_mode = qapi_enum_parse(prealloc_mode_lookup, buf, + s->prealloc_mode = qapi_enum_parse(&prealloc_mode_lookup, buf, PRL_PREALLOC_MODE_FALLOCATE, &local_err); g_free(buf); |