diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-18 19:30:32 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-19 04:25:43 +0000 |
| commit | 2ed8db3adc19dd922e31082634146e159f65af2e (patch) | |
| tree | dd242e1f7a178ee0c925cd080d61bac22fd681f5 /util/nvmutil/lib/string.c | |
| parent | 6ccd54635fdec85f44a9960b93c52fde89c07f41 (diff) | |
util/nvmutil: major cleanup
handle init in xstatus()
it's now a singleton design
also tidied up some other code
also removed todo.c. bloat.
will do all those anyway.
too much change. i just kept
touching the code until it
looked good
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/lib/string.c')
| -rw-r--r-- | util/nvmutil/lib/string.c | 55 |
1 files changed, 1 insertions, 54 deletions
diff --git a/util/nvmutil/lib/string.c b/util/nvmutil/lib/string.c index 529dbf59..517f490b 100644 --- a/util/nvmutil/lib/string.c +++ b/util/nvmutil/lib/string.c @@ -93,67 +93,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; |
