Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/68438 )
Change subject: flashrom.c: Move count_max_decode_exceeding() to cli ......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Not sure if moving this to the libflashrom API makes sense. […]
It crossed my mind however I didn't want to introduce it to a user facing API pre-maturely. I think the logical step after this was to move the hunk out of `main()`:
``` unsigned int limitexceeded = count_max_decode_exceedings(fill_flash); if (limitexceeded > 0 && !force) { enum chipbustype commonbuses = fill_flash->mst->buses_supported & fill_flash->chip->bustype;
/* Sometimes chip and programmer have more than one bus in common, * and the limit is not exceeded on all buses. Tell the user. */ if ((bitcount(commonbuses) > limitexceeded)) { msg_pdbg("There is at least one interface available which could support the size of\n" "the selected flash chip.\n"); } msg_cerr("This flash chip is too big for this programmer (--verbose/-V gives details).\n" "Use --force/-f to override at your own risk.\n"); ret = 1; goto out_shutdown; } ```
into a function `check_chip_support_buses(fill_flash);` after the `print_chip_support_status(fill_flash->chip);` line and also have `count_max_decode_exceedings()` as a pure function that doesn't rely on globals. That way at least all these fragments of logic are collated together into something coherent - give me a context and I will check if the bus limits are suitable for the chip/programmer pair.