MCPcopy Create free account
hub / github.com/coreboot/coreboot / strncmp

Function strncmp

payloads/libpayload/libc/string.c:111–122  ·  view source on GitHub ↗

* Compare two strings with fixed length. * * @param s1 The first string. * @param s2 The second string. * @param maxlen Return at most maxlen characters as length of the string. * @return A non-zero value if s1 and s2 differ, or zero if s1 equals s2. */

Source from the content-addressed store, hash-verified

109 * @return A non-zero value if s1 and s2 differ, or zero if s1 equals s2.
110 */
111int strncmp(const char *s1, const char *s2, size_t maxlen)
112{
113 int res = 0;
114
115 for (size_t i = 0; i < maxlen; i++) {
116 res = s1[i] - s2[i];
117 if (res || (s1[i] == '\0'))
118 break;
119 }
120
121 return res;
122}
123
124/**
125 * Copy a string with a maximum length.

Callers 11

parse_long_optionsFunction · 0.70
cb_parse_headerFunction · 0.70
fmap_find_areaFunction · 0.70
usb_hid_set_layoutFunction · 0.50
keyboard_set_layoutFunction · 0.50
mainFunction · 0.50
getwinFunction · 0.50
form_request_by_nameFunction · 0.50
menu_request_by_nameFunction · 0.50
gdb_command_loopFunction · 0.50
parse_headerFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected