diff mbox

[v2,13/54] qapi: drop the sentinel in enum array

Message ID 20170822132255.23945-14-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Aug. 22, 2017, 1:22 p.m. UTC
Now that all usages have been converted to user lookup helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/qapi.py   | 1 -
 block/parallels.c | 1 -
 ui/input-legacy.c | 2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)

Comments

Markus Armbruster Aug. 23, 2017, 12:37 p.m. UTC | #1
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Now that all usages have been converted to user lookup helpers.

I don't think you got them all:

    $ git-grep -F _lookup.
    tests/test-qobject-input-visitor.c:    for (i = 0; i < EnumOne_lookup.size; i++) {
    tests/test-qobject-input-visitor.c:        v = visitor_input_test_init(data, "%s", EnumOne_lookup.array[i]);
    tests/test-qobject-input-visitor.c:                           UserDefNativeListUnionKind_lookup.array[kind],
    tests/test-string-input-visitor.c:    for (i = 0; i < EnumOne_lookup.size; i++) {
    tests/test-string-input-visitor.c:        v = visitor_input_test_init(data, EnumOne_lookup.array[i]);
    ui/input-legacy.c:    for (i = 0; i < QKeyCode_lookup.size; i++) {
    ui/input-legacy.c:        if (!strncmp(key, QKeyCode_lookup.array[i], key_length) &&
    ui/input-legacy.c:            !QKeyCode_lookup.array[i][key_length]) {

I think I commented on all of these guys in my review of PATCH 06-12.
diff mbox

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 314d7e0365..73adb90379 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1863,7 +1863,6 @@  static const char *const %(c_name)s_array[] = {
 
     max_index = c_enum_const(name, '_MAX', prefix)
     ret += mcgen('''
-    [%(max_index)s] = NULL,
 };
 
 const QEnumLookup %(c_name)s_lookup = {
diff --git a/block/parallels.c b/block/parallels.c
index f870bbac3e..d5de692c9c 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -72,7 +72,6 @@  typedef enum ParallelsPreallocMode {
 static const char *prealloc_mode_array[] = {
     "falloc",
     "truncate",
-    NULL,
 };
 
 static QEnumLookup prealloc_mode_lookup = {
diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index c597bdc711..d50a18a505 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -61,7 +61,7 @@  int index_from_key(const char *key, size_t key_length)
 {
     int i;
 
-    for (i = 0; QKeyCode_lookup.array[i] != NULL; i++) {
+    for (i = 0; i < QKeyCode_lookup.size; i++) {
         if (!strncmp(key, QKeyCode_lookup.array[i], key_length) &&
             !QKeyCode_lookup.array[i][key_length]) {
             break;