summaryrefslogtreecommitdiff
path: root/util/nvmutil/lib/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/nvmutil/lib/string.c')
-rw-r--r--util/nvmutil/lib/string.c22
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)
{