Mesa (master): loader: use ARRAY_SIZE instead of NULL sentinel

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 7 20:31:56 UTC 2019


Module: Mesa
Branch: master
Commit: b9157ea415d9734e67678d2d5a26798d6fa03a02
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b9157ea415d9734e67678d2d5a26798d6fa03a02

Author: Eric Engestrom <eric.engestrom at intel.com>
Date:   Wed Oct  2 13:42:14 2019 +0100

loader: use ARRAY_SIZE instead of NULL sentinel

Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
Acked-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

---

 src/loader/loader.c            | 4 +++-
 src/loader/pci_id_driver_map.h | 5 -----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 873f55c8a9c..c828105c951 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -56,6 +56,8 @@
 #endif
 #endif
 
+#include "util/macros.h"
+
 #define __IS_LOADER
 #include "pci_id_driver_map.h"
 
@@ -465,7 +467,7 @@ loader_get_driver_for_fd(int fd)
       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;
 
diff --git a/src/loader/pci_id_driver_map.h b/src/loader/pci_id_driver_map.h
index 63fb1ae01b6..f71548a1c4e 100644
--- a/src/loader/pci_id_driver_map.h
+++ b/src/loader/pci_id_driver_map.h
@@ -4,10 +4,6 @@
 #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
@@ -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) },
-   { 0x0000, NULL, NULL, 0 },
 };
 
 #endif /* _PCI_ID_DRIVER_MAP_H_ */




More information about the mesa-commit mailing list