qapi: Drop superfluous qapi_enum_parse() parameter max
The lookup tables have a sentinel, no need to make callers pass their
size.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-3-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Rebased, commit message corrected]
diff --git a/block/file-posix.c b/block/file-posix.c
index cb3bfce..97e8a92 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -439,7 +439,7 @@
? BLOCKDEV_AIO_OPTIONS_NATIVE
: BLOCKDEV_AIO_OPTIONS_THREADS;
aio = qapi_enum_parse(BlockdevAioOptions_lookup, qemu_opt_get(opts, "aio"),
- BLOCKDEV_AIO_OPTIONS__MAX, aio_default, &local_err);
+ aio_default, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
@@ -448,7 +448,7 @@
s->use_linux_aio = (aio == BLOCKDEV_AIO_OPTIONS_NATIVE);
locking = qapi_enum_parse(OnOffAuto_lookup, qemu_opt_get(opts, "locking"),
- ON_OFF_AUTO__MAX, ON_OFF_AUTO_AUTO, &local_err);
+ ON_OFF_AUTO_AUTO, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
@@ -1975,8 +1975,7 @@
nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false);
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
prealloc = qapi_enum_parse(PreallocMode_lookup, buf,
- PREALLOC_MODE__MAX, PREALLOC_MODE_OFF,
- &local_err);
+ PREALLOC_MODE_OFF, &local_err);
g_free(buf);
if (local_err) {
error_propagate(errp, local_err);
diff --git a/block/file-win32.c b/block/file-win32.c
index 4706335..978d805 100644
--- a/block/file-win32.c
+++ b/block/file-win32.c
@@ -304,7 +304,7 @@
aio_default = (flags & BDRV_O_NATIVE_AIO) ? BLOCKDEV_AIO_OPTIONS_NATIVE
: BLOCKDEV_AIO_OPTIONS_THREADS;
aio = qapi_enum_parse(BlockdevAioOptions_lookup, qemu_opt_get(opts, "aio"),
- BLOCKDEV_AIO_OPTIONS__MAX, aio_default, errp);
+ aio_default, errp);
switch (aio) {
case BLOCKDEV_AIO_OPTIONS_NATIVE:
diff --git a/block/gluster.c b/block/gluster.c
index 3064a45..8367e80 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -544,8 +544,7 @@
if (!strcmp(ptr, "tcp")) {
ptr = "inet"; /* accept legacy "tcp" */
}
- type = qapi_enum_parse(SocketAddressType_lookup, ptr,
- SOCKET_ADDRESS_TYPE__MAX, -1, NULL);
+ type = qapi_enum_parse(SocketAddressType_lookup, ptr, -1, NULL);
if (type != SOCKET_ADDRESS_TYPE_INET
&& type != SOCKET_ADDRESS_TYPE_UNIX) {
error_setg(&local_err,
@@ -1002,8 +1001,7 @@
BDRV_SECTOR_SIZE);
tmp = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
- prealloc = qapi_enum_parse(PreallocMode_lookup, tmp,
- PREALLOC_MODE__MAX, PREALLOC_MODE_OFF,
+ prealloc = qapi_enum_parse(PreallocMode_lookup, tmp, PREALLOC_MODE_OFF,
&local_err);
g_free(tmp);
if (local_err) {
diff --git a/block/parallels.c b/block/parallels.c
index e1e06d2..eb92366 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -697,7 +697,8 @@
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,
- PRL_PREALLOC_MODE__MAX, PRL_PREALLOC_MODE_FALLOCATE, &local_err);
+ PRL_PREALLOC_MODE_FALLOCATE,
+ &local_err);
g_free(buf);
if (local_err != NULL) {
goto fail_options;
diff --git a/block/qcow2.c b/block/qcow2.c
index a3679c6..470a0de 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2917,8 +2917,7 @@
}
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
prealloc = qapi_enum_parse(PreallocMode_lookup, buf,
- PREALLOC_MODE__MAX, PREALLOC_MODE_OFF,
- &local_err);
+ PREALLOC_MODE_OFF, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
@@ -3608,8 +3607,7 @@
optstr = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
prealloc = qapi_enum_parse(PreallocMode_lookup, optstr,
- PREALLOC_MODE__MAX, PREALLOC_MODE_OFF,
- &local_err);
+ PREALLOC_MODE_OFF, &local_err);
g_free(optstr);
if (local_err) {
goto err;