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.c66
1 files changed, 1 insertions, 65 deletions
diff --git a/util/nvmutil/lib/string.c b/util/nvmutil/lib/string.c
index 529dbf59..4f55c0d3 100644
--- a/util/nvmutil/lib/string.c
+++ b/util/nvmutil/lib/string.c
@@ -1,25 +1,14 @@
/* SPDX-License-Identifier: MIT
- *
* Copyright (c) 2026 Leah Rowe <leah@libreboot.org>
*
* String handling.
*/
-#ifdef __OpenBSD__
-#include <sys/param.h>
-#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdarg.h>
#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
#include <unistd.h>
#include "../include/common.h"
@@ -93,67 +82,14 @@ xstrxlen(const char *scmp, unsigned long maxlen)
return xstr_index;
}
-void
-err(int nvm_errval, const char *msg, ...)
-{
- struct xstate *x = xstatus();
-
- va_list args;
-
- if (errno == 0)
- errno = nvm_errval;
- if (!errno)
- errno = ECANCELED;
-
- (void)exit_cleanup();
-
- if (x != NULL)
- fprintf(stderr, "%s: ", getnvmprogname());
-
- va_start(args, msg);
- vfprintf(stderr, msg, args);
- va_end(args);
-
- fprintf(stderr, ": %s\n", strerror(errno));
-
- exit(EXIT_FAILURE);
-}
-
-const char *
-getnvmprogname(void)
-{
- struct xstate *x = xstatus();
-
- const char *p;
- static char fallback[] = "nvmutil";
-
- char *rval = fallback;
-
- if (x != NULL) {
- if (x->argv0 == NULL || *x->argv0 == '\0')
- return "";
-
- rval = x->argv0;
- }
-
- p = x_c_strrchr(rval, '/');
-
- if (p)
- return p + 1;
- else
- return rval;
-}
-
char *
x_c_strrchr(const char *s, int c)
{
const char *p = NULL;
- while (*s) {
+ for ( ; *s; s++)
if (*s == (char)c)
p = s;
- s++;
- }
if (c == '\0')
return (char *)s;