summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-29 09:30:10 +0100
committerLeah Rowe <leah@libreboot.org>2026-03-29 09:30:10 +0100
commit1539aff30236b0302c92df2c1d2b635d58f08812 (patch)
tree25e7ff178936b8901486419e3c074be15cb60bce /util
parentc2a70b7de0e15dc80d5b56d438a6d4ed47647b44 (diff)
lbutils: simplify getprogname usage
the functions no longer return errors, so i don't need to handle them. furthermore, the handling in state.c is redundant, so i've removed that too. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/libreboot-utils/include/common.h2
-rw-r--r--util/libreboot-utils/lib/state.c4
-rw-r--r--util/libreboot-utils/lib/string.c8
-rw-r--r--util/libreboot-utils/lottery.c3
-rw-r--r--util/libreboot-utils/mkhtemp.c3
-rw-r--r--util/libreboot-utils/nvmutil.c3
6 files changed, 5 insertions, 18 deletions
diff --git a/util/libreboot-utils/include/common.h b/util/libreboot-utils/include/common.h
index 4b736808..aa5d043a 100644
--- a/util/libreboot-utils/include/common.h
+++ b/util/libreboot-utils/include/common.h
@@ -301,8 +301,6 @@ struct xstate {
struct macaddr mac;
struct xfile f;
- char *argv0;
-
size_t i; /* index to cmd[] for current command */
int no_cmd;
diff --git a/util/libreboot-utils/lib/state.c b/util/libreboot-utils/lib/state.c
index a3cd5b1f..bcf2ccbc 100644
--- a/util/libreboot-utils/lib/state.c
+++ b/util/libreboot-utils/lib/state.c
@@ -77,9 +77,6 @@ xstart(int argc, char *argv[])
/* .f */
{0},
- /* .argv0 (for our getprogname implementation) */
- NULL,
-
/* ->i (index to cmd[]) */
0,
@@ -103,7 +100,6 @@ xstart(int argc, char *argv[])
us.f.buf = us.f.real_buf;
- us.argv0 = argv[0];
us.f.fname = argv[1];
us.f.tmp_fd = -1;
diff --git a/util/libreboot-utils/lib/string.c b/util/libreboot-utils/lib/string.c
index c3cf4519..c7f90f5d 100644
--- a/util/libreboot-utils/lib/string.c
+++ b/util/libreboot-utils/lib/string.c
@@ -324,17 +324,13 @@ err_exit(int nvm_errval, const char *msg, ...)
if (!errno)
saved_errno = errno = ECANCELED;
- if ((p = lbgetprogname()) != NULL)
- fprintf(stderr, "%s: ", p);
+ fprintf(stderr, "%s: ", lbgetprogname());
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
- if (p != NULL)
- fprintf(stderr, ": %s\n", strerror(errno));
- else
- fprintf(stderr, "%s\n", strerror(errno));
+ fprintf(stderr, ": %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
diff --git a/util/libreboot-utils/lottery.c b/util/libreboot-utils/lottery.c
index 48565c87..4c7c145a 100644
--- a/util/libreboot-utils/lottery.c
+++ b/util/libreboot-utils/lottery.c
@@ -21,8 +21,7 @@ main(int argc, char **argv)
(void) argc, (void) argv;
(void) errhook(exit_cleanup);
- if (lbsetprogname(argv[0]) == NULL)
- err_exit(errno, "could not set progname");
+ (void) lbsetprogname(argv[0]);
/* https://man.openbsd.org/pledge.2 */
xpledgex("stdio", NULL);
diff --git a/util/libreboot-utils/mkhtemp.c b/util/libreboot-utils/mkhtemp.c
index 04ce1993..de86a2bf 100644
--- a/util/libreboot-utils/mkhtemp.c
+++ b/util/libreboot-utils/mkhtemp.c
@@ -62,8 +62,7 @@ main(int argc, char *argv[])
int type = MKHTEMP_FILE;
(void) errhook(exit_cleanup);
- if (lbsetprogname(argv[0]) == NULL)
- err_exit(errno, "could not set progname");
+ (void) lbsetprogname(argv[0]);
/* https://man.openbsd.org/pledge.2 */
xpledgex("stdio flock rpath wpath cpath", NULL);
diff --git a/util/libreboot-utils/nvmutil.c b/util/libreboot-utils/nvmutil.c
index 49d81a01..8d1b866c 100644
--- a/util/libreboot-utils/nvmutil.c
+++ b/util/libreboot-utils/nvmutil.c
@@ -33,8 +33,7 @@ main(int argc, char *argv[])
size_t c;
(void) errhook(exit_cleanup);
- if (lbsetprogname(argv[0]) == NULL)
- err_exit(errno, "could not set progname");
+ (void) lbsetprogname(argv[0]);
/* https://man.openbsd.org/pledge.2 */
/* https://man.openbsd.org/unveil.2 */