From 55f006318a35990d7d19a796e9af4c5f351b389a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 19 Mar 2026 16:02:15 +0000 Subject: tidy some comments Signed-off-by: Leah Rowe --- util/nvmutil/lib/string.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'util/nvmutil/lib/string.c') 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 * - * String handling. + * String functions */ #include @@ -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) { -- cgit v1.2.1