Attention is currently required from: Angel Pons, Nikolai Artemiev, Sergii Dmytruk. Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/58481 )
Change subject: libflashrom,writeprotect: add flashrom_wp_get_available_ranges() ......................................................................
Patch Set 53: Code-Review+1
(7 comments)
Patchset:
PS53: Ah, sorry, apparently I forgot to publish comments the last time I looked ._.
File libflashrom.h:
https://review.coreboot.org/c/flashrom/+/58481/comment/fcccc7bd_4ba2a9a3 PS49, Line 153: range_list Maybe abbreviate here and in the two functions below like above, i.e. `ranges`?
https://review.coreboot.org/c/flashrom/+/58481/comment/9576828b_e70802af PS49, Line 154: size_t I would prefer `unsigned int` as `size_t` is officially for byte counts. We use it internally sometimes for indices in general, but it seems better to not have such local style in the API.
File libflashrom.c:
https://review.coreboot.org/c/flashrom/+/58481/comment/c53b32cf_e53d5790 PS49, Line 800: } No need to change this if you don't want to. The pattern that seems to prevail nowadays is to check for errors first and bail out, so the actual code is at the end and doesn't need indentation, i.e.
if (index >= list->count) return FLASHROM_WP_ERR_OTHER;
*start = ...
https://review.coreboot.org/c/flashrom/+/58481/comment/2b0a954f_2f3c1252 PS49, Line 811: free(list->ranges); Better to check for NULL first, e.g.
if (!list) return;
Then the caller doesn't need to ensure it's set. free() allows NULL and it makes error paths easier to handle when one just needs to write `free(x);` without needing to care if `x` was allocated already.
(flashrom_flash_release() doesn't follow that rule either, I'll push a patch CB:62340)
File writeprotect.c:
https://review.coreboot.org/c/flashrom/+/58481/comment/2fb0e985_9bbbb4d7 PS49, Line 171: Comparitor Compar*a*tor
https://review.coreboot.org/c/flashrom/+/58481/comment/d664bd22_eae082f0 PS49, Line 200: size_t j = a->bits.bp_bit_count - i - 1; Reversing the loop would be more readable, I guess:
for (int i = a->bits.bp_bit_count - 1; i >= 0; --i)