Attention is currently required from: Julius Werner, Werner Zeh. Jakub Czapiga has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/59312 )
Change subject: cbfs: Add helper functions to look up size and type of a file ......................................................................
Patch Set 1:
(3 comments)
File src/include/cbfs.h:
https://review.coreboot.org/c/coreboot/+/59312/comment/ea65afe8_e0a0a501 PS1, Line 134: static inline bool cbfs_file_exists(const char *name); : static inline bool cbfs_ro_file_exists(const char *name); I wonder, if we actually need these functions. cbfs_load() will return CB_CBFS_NOT_FOUND (or other error code) if file does not exist. Are there real use cases for this function? The only one I can think of is with cbfs_map(), but it also returns NULL if file does not exist.
https://review.coreboot.org/c/coreboot/+/59312/comment/50b07fca_316e6012 PS1, Line 308: static inline size_t cbfs_get_size(const char *name) Should not these functions be inaccessible for code running in CAR mode and similar? This might make stack big because of cbfs_mdata, which is pretty big. Do early stages have enough stack memory? Or does GCC/Clang optimize it enough?
File src/lib/cbfs.c:
https://review.coreboot.org/c/coreboot/+/59312/comment/396b322e_9f9351ab PS1, Line 528: if ((err = _cbfs_boot_lookup(prog_name(pstage), false, &mdata, &rdev))) Would not it be cleaner to set err value in a separate line above? Personally I find assign-and-check pattern a anti-pattern.