greybus: loopback_test: null terminate the dict structure
authorGreg Kroah-Hartman <gregkh@google.com>
Tue, 15 Dec 2015 21:57:22 +0000 (13:57 -0800)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 18 Dec 2015 02:17:07 +0000 (18:17 -0800)
This lets us test for any number of entries, no need to do an
ARRAY_SIZE-type comparison.  This fixes a build warning of comparing
signed/unsigned values.)

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/tools/loopback_test.c

index 5c2a9fc..27c733d 100644 (file)
@@ -34,7 +34,8 @@ struct dict {
 static struct dict dict[] = {
        {"ping", 2},
        {"transfer", 3},
-       {"sink", 4}
+       {"sink", 4},
+       {NULL,}         /* list termination */
 };
 
 struct loopback_results {
@@ -805,7 +806,7 @@ void loopback_run(struct loopback_test *t)
        int i;
        int ret;
 
-       for (i = 0; i < sizeof(dict) / sizeof(struct dict); i++) {
+       for (i = 0; dict[i].name != NULL; i++) {
                if (strstr(dict[i].name, t->test_name))
                        t->test_id = dict[i].type;
        }