forked from auracaster/openocd
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.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8947 Reviewed-by: Brandon Martin Tested-by: jenkins
This commit is contained in:
@@ -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; i < ARRAY_SIZE(flash_drivers); i++) {
|
||||
if (strcmp(name, flash_drivers[i]->name) == 0)
|
||||
return flash_drivers[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user