programmer_table: replace PROGRAMMER_INVALID with programmer_table_size
Change-Id: Icaaeefe001de604df9d7fdd06f05a5ed39fdbd84
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/55117
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71374
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/cli_classic.c b/cli_classic.c
index 89a6c83..5ebc6ea 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -306,7 +306,7 @@
"with \",\". Please see the man page "
"for details.\n");
}
- for (prog = 0; prog < PROGRAMMER_INVALID; prog++) {
+ for (prog = 0; prog < programmer_table_size; prog++) {
name = programmer_table[prog]->name;
namelen = strlen(name);
if (strncmp(optarg, name, namelen) == 0) {
diff --git a/flashrom.c b/flashrom.c
index 26f2ca8..a1f2318 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -140,7 +140,7 @@
{
int ret;
- if (prog >= PROGRAMMER_INVALID) {
+ if (prog >= programmer_table_size) {
msg_perr("Invalid programmer specified!\n");
return -1;
}
@@ -1524,7 +1524,7 @@
enum programmer p;
int i;
- for (p = 0; p < PROGRAMMER_INVALID; p++) {
+ for (p = 0; p < programmer_table_size; p++) {
pname = programmer_table[p]->name;
pnamelen = strlen(pname);
if (remaining - pnamelen - 2 < 0) {
@@ -1545,7 +1545,7 @@
}
msg_ginfo("%s", pname);
remaining -= pnamelen;
- if (p < PROGRAMMER_INVALID - 1) {
+ if (p < programmer_table_size - 1) {
msg_ginfo(",");
remaining--;
} else {
@@ -1654,7 +1654,7 @@
msg_gerr("Programmer table miscompilation!\n");
ret = 1;
}
- for (i = 0; i < PROGRAMMER_INVALID; i++) {
+ for (i = 0; i < programmer_table_size; i++) {
const struct programmer_entry *const p = programmer_table[i];
if (p == NULL) {
msg_gerr("Programmer with index %d is NULL instead of a valid pointer!\n", i);
diff --git a/libflashrom.c b/libflashrom.c
index 743c400..5402978 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -134,11 +134,11 @@
{
unsigned prog;
- for (prog = 0; prog < PROGRAMMER_INVALID; prog++) {
+ for (prog = 0; prog < programmer_table_size; prog++) {
if (strcmp(prog_name, programmer_table[prog]->name) == 0)
break;
}
- if (prog >= PROGRAMMER_INVALID) {
+ if (prog >= programmer_table_size) {
msg_ginfo("Error: Unknown programmer \"%s\". Valid choices are:\n", prog_name);
list_programmers_linebreak(0, 80, 0);
return 1;
diff --git a/print.c b/print.c
index 77cf3d5..fd56128 100644
--- a/print.c
+++ b/print.c
@@ -482,7 +482,7 @@
msg_ginfo("\n");
print_supported_boards_helper(laptops_known, "mobile devices");
#endif
- for (i = 0; i < PROGRAMMER_INVALID; i++) {
+ for (i = 0; i < programmer_table_size; i++) {
const struct programmer_entry *const prog = programmer_table[i];
switch (prog->type) {
case USB:
diff --git a/print_wiki.c b/print_wiki.c
index 0903450..2c8c109 100644
--- a/print_wiki.c
+++ b/print_wiki.c
@@ -380,7 +380,7 @@
unsigned int usb_count = 0;
unsigned int i;
- for (i = 0; i < PROGRAMMER_INVALID; i++) {
+ for (i = 0; i < programmer_table_size; i++) {
const struct programmer_entry *const prog = programmer_table[i];
switch (prog->type) {
case USB:
@@ -399,7 +399,7 @@
"Total amount of supported PCI devices flashrom can use as a programmer: '''%d'''\n\n"
"{%s%s", pci_count, th_start, programmer_th);
- for (i = 0; i < PROGRAMMER_INVALID; i++) {
+ for (i = 0; i < programmer_table_size; i++) {
const struct programmer_entry *const prog = programmer_table[i];
if (prog->type == PCI) {
print_supported_devs_wiki_helper(prog);
@@ -411,7 +411,7 @@
"Total amount of supported USB devices flashrom can use as a programmer: '''%d'''\n\n"
"{%s%s", usb_count, th_start, programmer_th);
- for (i = 0; i < PROGRAMMER_INVALID; i++) {
+ for (i = 0; i < programmer_table_size; i++) {
const struct programmer_entry *const prog = programmer_table[i];
if (prog->type == USB) {
print_supported_devs_wiki_helper(prog);
@@ -424,7 +424,7 @@
printf("! align=\"left\" | Programmer\n"
"! align=\"left\" | Note\n\n");
- for (i = 0; i < PROGRAMMER_INVALID; i++) {
+ for (i = 0; i < programmer_table_size; i++) {
static int c = 0;
const struct programmer_entry *const prog = programmer_table[i];
if (prog->type == OTHER && prog->devs.note != NULL) {