Dmitry Zhadinets has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/87195?usp=email )
Change subject: cli: Use flashrom_supported_programmers API in cli ......................................................................
cli: Use flashrom_supported_programmers API in cli
Testing: Both unit tests and CLI tools serve as libflashrom clients. All unit tests run successfully.
Change-Id: I86ac83ee0ef4e850e69aa4e7b607e28ebab9d3d5 Signed-off-by: Dmitry Zhadinets dzhadinets@gmail.com --- M flashrom.c 1 file changed, 10 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/95/87195/1
diff --git a/flashrom.c b/flashrom.c index af15552..7c14b9b 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1556,11 +1556,14 @@ const char *pname; int pnamelen; int remaining = 0, firstline = 1; - size_t p; int i; + const char **programmers = flashrom_supported_programmers(); + if (!programmers) + return; + const char **ptr = programmers;
- for (p = 0; p < programmer_table_size; p++) { - pname = programmer_table[p]->name; + do { + pname = *ptr; pnamelen = strlen(pname); if (remaining - pnamelen - 2 < 0) { if (firstline) @@ -1574,20 +1577,21 @@ msg_ginfo(" "); remaining--; } - if (paren && (p == 0)) { + if (paren && (ptr == programmers)) { msg_ginfo("("); remaining--; } msg_ginfo("%s", pname); remaining -= pnamelen; - if (p < programmer_table_size - 1) { + if (*(ptr + 1) != NULL) { msg_ginfo(","); remaining--; } else { if (paren) msg_ginfo(")"); } - } + } while (*(++ptr)); + flashrom_data_free(programmers); }
int selfcheck(void)