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/+/8949

-- gerrit

commit fcff4d61e2aa5e95b5a617ba48a6430f08c5c445
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Sat Jun 14 13:58:38 2025 +0200

    flash: nand: 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: I532a51a223061348e57bae3bd66ee6b346c1b070
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/flash/nand/driver.c b/src/flash/nand/driver.c
index 69b3ba9618..eda033b5b7 100644
--- a/src/flash/nand/driver.c
+++ b/src/flash/nand/driver.c
@@ -10,6 +10,8 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+
+#include <helper/types.h>
 #include "core.h"
 #include "driver.h"
 
@@ -29,12 +31,11 @@ static struct nand_flash_controller 
*nand_flash_controllers[] = {
        &s3c2440_nand_controller,
        &s3c2443_nand_controller,
        &s3c6400_nand_controller,
-       NULL
 };
 
 struct nand_flash_controller *nand_driver_find_by_name(const char *name)
 {
-       for (unsigned int i = 0; nand_flash_controllers[i]; i++) {
+       for (size_t i = 0; i < ARRAY_SIZE(nand_flash_controllers); i++) {
                struct nand_flash_controller *controller = 
nand_flash_controllers[i];
                if (strcmp(name, controller->name) == 0)
                        return controller;
@@ -43,7 +44,7 @@ struct nand_flash_controller *nand_driver_find_by_name(const 
char *name)
 }
 int nand_driver_walk(nand_driver_walker_t f, void *x)
 {
-       for (unsigned int i = 0; nand_flash_controllers[i]; i++) {
+       for (size_t i = 0; i < ARRAY_SIZE(nand_flash_controllers); i++) {
                int retval = (*f)(nand_flash_controllers[i], x);
                if (retval != ERROR_OK)
                        return retval;

-- 

Reply via email to