programmer_table: replace PROGRAMMER_INVALID with programmer_table_size

Change-Id: Icaaeefe001de604df9d7fdd06f05a5ed39fdbd84
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55117
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/cli_classic.c b/cli_classic.c
index bc2d40d..f3ae123 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -406,7 +406,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 b804e2d..c036fea 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -134,7 +134,7 @@
 {
 	int ret;
 
-	if (prog >= PROGRAMMER_INVALID) {
+	if (prog >= programmer_table_size) {
 		msg_perr("Invalid programmer specified!\n");
 		return -1;
 	}
@@ -1585,7 +1585,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) {
@@ -1606,7 +1606,7 @@
 		}
 		msg_ginfo("%s", pname);
 		remaining -= pnamelen;
-		if (p < PROGRAMMER_INVALID - 1) {
+		if (p < programmer_table_size - 1) {
 			msg_ginfo(",");
 			remaining--;
 		} else {
@@ -1715,7 +1715,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 d0296d0..f3df1c7 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -120,10 +120,10 @@
 const char **flashrom_supported_programmers(void)
 {
 	enum programmer p = 0;
-	const char **supported_programmers = malloc((PROGRAMMER_INVALID + 1) * sizeof(char*));
+	const char **supported_programmers = malloc((programmer_table_size + 1) * sizeof(char*));
 
 	if (supported_programmers != NULL) {
-		for (; p < PROGRAMMER_INVALID; ++p) {
+		for (; p < programmer_table_size; ++p) {
 			supported_programmers[p] = programmer_table[p]->name;
 		}
 	} else {
@@ -278,11 +278,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 3610135..9af2e3e 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) {