Attention is currently required from: Edward O'Callaghan, Angel Pons, Arthur Heymans, Anastasia Klimchuk. Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/55269 )
Change subject: treewide: Use calloc() where applicable ......................................................................
Patch Set 1:
(5 comments)
Patchset:
PS1: I'm not convinced about unnecessary initialization. Want to have it discussed at least once...
File jlink_spi.c:
https://review.coreboot.org/c/flashrom/+/55269/comment/796f3f29_e13f22fd PS1, Line 128: memset(buffer + writecnt, 0x00, readcnt); I wonder why this is done at all.
File libflashrom.c:
https://review.coreboot.org/c/flashrom/+/55269/comment/cf3f41c7_d207abf8 PS1, Line 123: const char **supported_programmers = calloc(PROGRAMMER_INVALID + 1, sizeof(char *)); This is probably what the original author intended. IIRC, I left a comment in Gerrit about this API (which is completely broken).
https://review.coreboot.org/c/flashrom/+/55269/comment/0cd9cdb4_71590a0a PS1, Line 144: calloc(flashchips_size, sizeof(*supported_flashchips)); Hmmm, I'm not convinced to initialize things that are supposed to be completely overwritten later. I doubt that it's the case for calloc() but I know that some static analysis tools complain about explicit but unnecessary initialization.
Failure to override all fields could be avoided, for instance, by using a struct initializer below, e.g.
const struct flashrom_flashchip_info supported_flashchip = { .vendor = flashchips[i].vendor, /* ... */ }; supported_flashchips[i] = supported_flashchip;
File mstarddc_spi.c:
https://review.coreboot.org/c/flashrom/+/55269/comment/e63a6177_c38b5157 PS1, Line 83: uint8_t *cmd = malloc((writecnt + 1) * sizeof(uint8_t)); This is just `malloc(writecnt + 1);` AIUI.