This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8947

-- gerrit

commit ba9eb609c7001a6891284c2d1eb2a6c3029fffd7
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Sat Jun 14 14:02:25 2025 +0200

    flash: nor: use array size to constraint the loop
    
    Instead of using NULL terminated arrays to determine the last
    element of the array, use the size of the array.
    
    Change-Id: Ia3d739b0a9f201ba2e7b1d1244d60c8e5546c9c1
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/flash/nor/drivers.c b/src/flash/nor/drivers.c
index 4f468848bc..c67c386af5 100644
--- a/src/flash/nor/drivers.c
+++ b/src/flash/nor/drivers.c
@@ -7,6 +7,8 @@
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+
+#include <helper/types.h>
 #include "imp.h"
 
 /**
@@ -89,12 +91,11 @@ static const struct flash_driver * const flash_drivers[] = {
        &xcf_flash,
        &xmc1xxx_flash,
        &xmc4xxx_flash,
-       NULL,
 };
 
 const struct flash_driver *flash_driver_find_by_name(const char *name)
 {
-       for (unsigned int i = 0; flash_drivers[i]; i++) {
+       for (size_t i = 0; ARRAY_SIZE(flash_drivers); i++) {
                if (strcmp(name, flash_drivers[i]->name) == 0)
                        return flash_drivers[i];
        }

-- 

Reply via email to