mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-19 19:23:24 +02:00
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>
This commit is contained in:
@@ -301,8 +301,6 @@ struct xstate {
|
|||||||
struct macaddr mac;
|
struct macaddr mac;
|
||||||
struct xfile f;
|
struct xfile f;
|
||||||
|
|
||||||
char *argv0;
|
|
||||||
|
|
||||||
size_t i; /* index to cmd[] for current command */
|
size_t i; /* index to cmd[] for current command */
|
||||||
int no_cmd;
|
int no_cmd;
|
||||||
|
|
||||||
|
|||||||
@@ -77,9 +77,6 @@ xstart(int argc, char *argv[])
|
|||||||
/* .f */
|
/* .f */
|
||||||
{0},
|
{0},
|
||||||
|
|
||||||
/* .argv0 (for our getprogname implementation) */
|
|
||||||
NULL,
|
|
||||||
|
|
||||||
/* ->i (index to cmd[]) */
|
/* ->i (index to cmd[]) */
|
||||||
0,
|
0,
|
||||||
|
|
||||||
@@ -103,7 +100,6 @@ xstart(int argc, char *argv[])
|
|||||||
|
|
||||||
us.f.buf = us.f.real_buf;
|
us.f.buf = us.f.real_buf;
|
||||||
|
|
||||||
us.argv0 = argv[0];
|
|
||||||
us.f.fname = argv[1];
|
us.f.fname = argv[1];
|
||||||
|
|
||||||
us.f.tmp_fd = -1;
|
us.f.tmp_fd = -1;
|
||||||
|
|||||||
@@ -324,17 +324,13 @@ err_exit(int nvm_errval, const char *msg, ...)
|
|||||||
if (!errno)
|
if (!errno)
|
||||||
saved_errno = errno = ECANCELED;
|
saved_errno = errno = ECANCELED;
|
||||||
|
|
||||||
if ((p = lbgetprogname()) != NULL)
|
fprintf(stderr, "%s: ", lbgetprogname());
|
||||||
fprintf(stderr, "%s: ", p);
|
|
||||||
|
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vfprintf(stderr, msg, args);
|
vfprintf(stderr, msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (p != NULL)
|
fprintf(stderr, ": %s\n", strerror(errno));
|
||||||
fprintf(stderr, ": %s\n", strerror(errno));
|
|
||||||
else
|
|
||||||
fprintf(stderr, "%s\n", strerror(errno));
|
|
||||||
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ main(int argc, char **argv)
|
|||||||
(void) argc, (void) argv;
|
(void) argc, (void) argv;
|
||||||
|
|
||||||
(void) errhook(exit_cleanup);
|
(void) errhook(exit_cleanup);
|
||||||
if (lbsetprogname(argv[0]) == NULL)
|
(void) lbsetprogname(argv[0]);
|
||||||
err_exit(errno, "could not set progname");
|
|
||||||
|
|
||||||
/* https://man.openbsd.org/pledge.2 */
|
/* https://man.openbsd.org/pledge.2 */
|
||||||
xpledgex("stdio", NULL);
|
xpledgex("stdio", NULL);
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ main(int argc, char *argv[])
|
|||||||
int type = MKHTEMP_FILE;
|
int type = MKHTEMP_FILE;
|
||||||
|
|
||||||
(void) errhook(exit_cleanup);
|
(void) errhook(exit_cleanup);
|
||||||
if (lbsetprogname(argv[0]) == NULL)
|
(void) lbsetprogname(argv[0]);
|
||||||
err_exit(errno, "could not set progname");
|
|
||||||
|
|
||||||
/* https://man.openbsd.org/pledge.2 */
|
/* https://man.openbsd.org/pledge.2 */
|
||||||
xpledgex("stdio flock rpath wpath cpath", NULL);
|
xpledgex("stdio flock rpath wpath cpath", NULL);
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ main(int argc, char *argv[])
|
|||||||
size_t c;
|
size_t c;
|
||||||
|
|
||||||
(void) errhook(exit_cleanup);
|
(void) errhook(exit_cleanup);
|
||||||
if (lbsetprogname(argv[0]) == NULL)
|
(void) lbsetprogname(argv[0]);
|
||||||
err_exit(errno, "could not set progname");
|
|
||||||
|
|
||||||
/* https://man.openbsd.org/pledge.2 */
|
/* https://man.openbsd.org/pledge.2 */
|
||||||
/* https://man.openbsd.org/unveil.2 */
|
/* https://man.openbsd.org/unveil.2 */
|
||||||
|
|||||||
Reference in New Issue
Block a user