loader: use ARRAY_SIZE instead of NULL sentinel
authorEric Engestrom <eric.engestrom@intel.com>
Wed, 2 Oct 2019 12:42:14 +0000 (13:42 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Mon, 7 Oct 2019 20:30:16 +0000 (21:30 +0100)
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/loader/loader.c
src/loader/pci_id_driver_map.h

index 873f55c8a9cb8540252d2bf3ec1e1b59a80bfd6d..c828105c95121add61ee269b740d96375aaac838 100644 (file)
@@ -56,6 +56,8 @@
 #endif
 #endif
 
 #endif
 #endif
 
+#include "util/macros.h"
+
 #define __IS_LOADER
 #include "pci_id_driver_map.h"
 
 #define __IS_LOADER
 #include "pci_id_driver_map.h"
 
@@ -465,7 +467,7 @@ loader_get_driver_for_fd(int fd)
       return driver;
    }
 
       return driver;
    }
 
-   for (i = 0; driver_map[i].driver; i++) {
+   for (i = 0; i < ARRAY_SIZE(driver_map); i++) {
       if (vendor_id != driver_map[i].vendor_id)
          continue;
 
       if (vendor_id != driver_map[i].vendor_id)
          continue;
 
index 63fb1ae01b65261ddc87ae20077681da1d2adba5..f71548a1c4e187191e476a2a995154660bc89788 100644 (file)
@@ -4,10 +4,6 @@
 #include <stdbool.h>
 #include <stddef.h>
 
 #include <stdbool.h>
 #include <stddef.h>
 
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
-#endif
-
 #ifndef __IS_LOADER
 #  error "Only include from loader.c"
 #endif
 #ifndef __IS_LOADER
 #  error "Only include from loader.c"
 #endif
@@ -106,7 +102,6 @@ static const struct {
    { 0x10de, "nouveau", NULL, -1, },
    { 0x1af4, "virtio_gpu", virtio_gpu_chip_ids, ARRAY_SIZE(virtio_gpu_chip_ids) },
    { 0x15ad, "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids) },
    { 0x10de, "nouveau", NULL, -1, },
    { 0x1af4, "virtio_gpu", virtio_gpu_chip_ids, ARRAY_SIZE(virtio_gpu_chip_ids) },
    { 0x15ad, "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids) },
-   { 0x0000, NULL, NULL, 0 },
 };
 
 #endif /* _PCI_ID_DRIVER_MAP_H_ */
 };
 
 #endif /* _PCI_ID_DRIVER_MAP_H_ */