Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/44085 )
Change subject: lib/string: Add standard strstr() function ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/44085/1/src/lib/string.c File src/lib/string.c:
https://review.coreboot.org/c/coreboot/+/44085/1/src/lib/string.c@169 PS1, Line 169: for (; *haystack; haystack++) {
We should bail if `strlen(haystack) < strlen(needle)`
I mean, it's gonna do that automatically (strncmp() still stops at '\0' on either string). In the common case needle will be much shorter than haystack. By adding a strlen(haystack) here you are iterating one extra time through the whole (commonly) large haystack, and all you gain is that if someone calls the function with incorrect input, it will terminate slightly earlier (but if haystack is shorter than needle that probably means they're both extremely short in most cases, so it would finish quite quickly anyway). I don't think that trade-off is worth it.