diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-19 16:02:15 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-19 16:02:15 +0000 |
| commit | 55f006318a35990d7d19a796e9af4c5f351b389a (patch) | |
| tree | 3a3cc47a97a52b9bbd534821ac1b67c7d08e0bc8 /util/nvmutil/lib/string.c | |
| parent | 7ad924a91f6800de4fdd89dbc390d6c46d78a861 (diff) | |
tidy some comments
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/lib/string.c')
| -rw-r--r-- | util/nvmutil/lib/string.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/util/nvmutil/lib/string.c b/util/nvmutil/lib/string.c index 4139c354..b1a5c3e2 100644 --- a/util/nvmutil/lib/string.c +++ b/util/nvmutil/lib/string.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: MIT * Copyright (c) 2026 Leah Rowe <leah@libreboot.org> * - * String handling. + * String functions */ #include <sys/types.h> @@ -13,10 +13,10 @@ #include "../include/common.h" -/* - * Portable strcmp() but blocks NULL/empty/unterminated - * strings. Even stricter than strncmp(). +/* Portable strncmp() that blocks + * NULL/empty/unterminated strings */ + int xstrxcmp(const char *a, const char *b, unsigned long maxlen) { @@ -43,24 +43,16 @@ xstrxcmp(const char *a, const char *b, unsigned long maxlen) return ac - bc; } - /* - * We reached maxlen, so assume unterminated string. - */ err(EINVAL, "Unterminated string in xstrxcmp"); - /* - * Should never reach here. This keeps compilers happy. - */ errno = EINVAL; return -1; } -/* - * strnlen() but aborts on NULL input, and empty strings. - * Our version also prohibits unterminated strings. - * strnlen() was standardized in POSIX.1-2008 and is not - * available on some older systems, so we provide our own. +/* Portable strncmp() that blocks + * NULL/empty/unterminated strings */ + unsigned long xstrxlen(const char *scmp, unsigned long maxlen) { |
