summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/libreboot-utils/include/common.h2
-rw-r--r--util/libreboot-utils/lib/checksum.c4
-rw-r--r--util/libreboot-utils/lib/command.c54
-rw-r--r--util/libreboot-utils/lib/file.c8
-rw-r--r--util/libreboot-utils/lib/io.c48
-rw-r--r--util/libreboot-utils/lib/num.c2
-rw-r--r--util/libreboot-utils/lib/state.c2
-rw-r--r--util/libreboot-utils/lib/usage.c2
-rw-r--r--util/libreboot-utils/lib/word.c2
-rw-r--r--util/libreboot-utils/nvmutil.c18
10 files changed, 71 insertions, 71 deletions
diff --git a/util/libreboot-utils/include/common.h b/util/libreboot-utils/include/common.h
index b028e437..196f2810 100644
--- a/util/libreboot-utils/include/common.h
+++ b/util/libreboot-utils/include/common.h
@@ -495,7 +495,7 @@ int try_err(int loop_err, int errval);
void usage(void);
void err_no_cleanup(int nvm_errval, const char *msg, ...);
-void err(int nvm_errval, const char *msg, ...);
+void b0rk(int nvm_errval, const char *msg, ...);
int exit_cleanup(void);
const char *getnvmprogname(void);
diff --git a/util/libreboot-utils/lib/checksum.c b/util/libreboot-utils/lib/checksum.c
index b417dc7e..9a041989 100644
--- a/util/libreboot-utils/lib/checksum.c
+++ b/util/libreboot-utils/lib/checksum.c
@@ -59,10 +59,10 @@ read_checksums(void)
if (_num_invalid >= _max_invalid) {
if (_max_invalid == 1)
- err(ECANCELED, "%s: part %lu has a bad checksum",
+ b0rk(ECANCELED, "%s: part %lu has a bad checksum",
f->fname, (size_t)f->part);
- err(ECANCELED, "%s: No valid checksum found in file",
+ b0rk(ECANCELED, "%s: No valid checksum found in file",
f->fname);
}
}
diff --git a/util/libreboot-utils/lib/command.c b/util/libreboot-utils/lib/command.c
index 94840191..6d0e8856 100644
--- a/util/libreboot-utils/lib/command.c
+++ b/util/libreboot-utils/lib/command.c
@@ -46,27 +46,27 @@ sanitize_command_index(size_t c)
check_command_num(c);
if (cmd->argc < 3)
- err(EINVAL, "cmd index %lu: argc below 3, %d",
+ b0rk(EINVAL, "cmd index %lu: argc below 3, %d",
(size_t)c, cmd->argc);
if (cmd->str == NULL)
- err(EINVAL, "cmd index %lu: NULL str",
+ b0rk(EINVAL, "cmd index %lu: NULL str",
(size_t)c);
if (*cmd->str == '\0')
- err(EINVAL, "cmd index %lu: empty str",
+ b0rk(EINVAL, "cmd index %lu: empty str",
(size_t)c);
if (slen(cmd->str, MAX_CMD_LEN +1, &rval) < 0)
- err(errno, "Could not get command length");
+ b0rk(errno, "Could not get command length");
if (rval > MAX_CMD_LEN) {
- err(EINVAL, "cmd index %lu: str too long: %s",
+ b0rk(EINVAL, "cmd index %lu: str too long: %s",
(size_t)c, cmd->str);
}
if (cmd->run == NULL)
- err(EINVAL, "cmd index %lu: cmd ptr null",
+ b0rk(EINVAL, "cmd index %lu: cmd ptr null",
(size_t)c);
check_bin(cmd->arg_part, "cmd.arg_part");
@@ -80,19 +80,19 @@ sanitize_command_index(size_t c)
case NVM_SIZE:
break;
default:
- err(EINVAL, "Unsupported rw_size: %lu",
+ b0rk(EINVAL, "Unsupported rw_size: %lu",
(size_t)gbe_rw_size);
}
if (gbe_rw_size > GBE_PART_SIZE)
- err(EINVAL, "rw_size larger than GbE part: %lu",
+ b0rk(EINVAL, "rw_size larger than GbE part: %lu",
(size_t)gbe_rw_size);
_flag = (cmd->flags & O_ACCMODE);
if (_flag != O_RDONLY &&
_flag != O_RDWR)
- err(EINVAL, "invalid cmd.flags setting");
+ b0rk(EINVAL, "invalid cmd.flags setting");
}
void
@@ -148,11 +148,11 @@ set_cmd_args(int argc, char *argv[])
/* Maintainer bug
*/
if (cmd->arg_part && argc < 4)
- err(EINVAL,
+ b0rk(EINVAL,
"arg_part set for command that needs argc4");
if (cmd->arg_part && i == CMD_SETMAC)
- err(EINVAL,
+ b0rk(EINVAL,
"arg_part set on CMD_SETMAC");
if (i == CMD_SETMAC) {
@@ -174,13 +174,13 @@ conv_argv_part_num(const char *part_str)
unsigned char ch;
if (part_str[0] == '\0' || part_str[1] != '\0')
- err(EINVAL, "Partnum string '%s' wrong length", part_str);
+ b0rk(EINVAL, "Partnum string '%s' wrong length", part_str);
/* char signedness is implementation-defined
*/
ch = (unsigned char)part_str[0];
if (ch < '0' || ch > '1')
- err(EINVAL, "Bad part number (%c)", ch);
+ b0rk(EINVAL, "Bad part number (%c)", ch);
return (size_t)(ch - '0');
}
@@ -189,7 +189,7 @@ void
check_command_num(size_t c)
{
if (!valid_command(c))
- err(EINVAL, "Invalid run_cmd arg: %lu",
+ b0rk(EINVAL, "Invalid run_cmd arg: %lu",
(size_t)c);
}
@@ -205,7 +205,7 @@ valid_command(size_t c)
cmd = &x->cmd[c];
if (c != cmd->chk)
- err(EINVAL,
+ b0rk(EINVAL,
"Invalid cmd chk value (%lu) vs arg: %lu",
cmd->chk, c);
@@ -240,10 +240,10 @@ parse_mac_string(void)
size_t rval;
if (slen(x->mac.str, 18, &rval) < 0)
- err(EINVAL, "Could not determine MAC length");
+ b0rk(EINVAL, "Could not determine MAC length");
if (rval != 17)
- err(EINVAL, "MAC address is the wrong length");
+ b0rk(EINVAL, "MAC address is the wrong length");
memset(mac->mac_buf, 0, sizeof(mac->mac_buf));
@@ -251,10 +251,10 @@ parse_mac_string(void)
set_mac_byte(mac_byte);
if ((mac->mac_buf[0] | mac->mac_buf[1] | mac->mac_buf[2]) == 0)
- err(EINVAL, "Must not specify all-zeroes MAC address");
+ b0rk(EINVAL, "Must not specify all-zeroes MAC address");
if (mac->mac_buf[0] & 1)
- err(EINVAL, "Must not specify multicast MAC address");
+ b0rk(EINVAL, "Must not specify multicast MAC address");
}
void
@@ -272,7 +272,7 @@ set_mac_byte(size_t mac_byte_pos)
if (mac_str_pos < 15) {
if ((separator = mac->str[mac_str_pos + 2]) != ':')
- err(EINVAL, "Invalid MAC address separator '%c'",
+ b0rk(EINVAL, "Invalid MAC address separator '%c'",
separator);
}
@@ -294,9 +294,9 @@ set_mac_nib(size_t mac_str_pos,
if ((hex_num = hextonum(mac_ch)) > 15) {
if (hex_num >= 17)
- err(EIO, "Randomisation failure");
+ b0rk(EIO, "Randomisation failure");
else
- err(EINVAL, "Invalid character '%c'",
+ b0rk(EINVAL, "Invalid character '%c'",
mac->str[mac_str_pos + mac_nib_pos]);
}
@@ -509,7 +509,7 @@ cat(size_t nff)
if ((size_t)x->cat != nff) {
- err(ECANCELED, "erroneous call to cat");
+ b0rk(ECANCELED, "erroneous call to cat");
}
fflush(NULL);
@@ -532,12 +532,12 @@ void
cat_buf(unsigned char *b)
{
if (b == NULL)
- err(errno, "null pointer in cat command");
+ b0rk(errno, "null pointer in cat command");
if (rw_file_exact(STDOUT_FILENO, b,
GBE_PART_SIZE, 0, IO_WRITE, LOOP_EAGAIN, LOOP_EINTR,
MAX_ZERO_RW_RETRY, OFF_ERR) < 0)
- err(errno, "stdout: cat");
+ b0rk(errno, "stdout: cat");
}
void
check_cmd(void (*fn)(void),
@@ -547,7 +547,7 @@ check_cmd(void (*fn)(void),
size_t i = x->i;
if (x->cmd[i].run != fn)
- err(ECANCELED, "Running %s, but cmd %s is set",
+ b0rk(ECANCELED, "Running %s, but cmd %s is set",
name, x->cmd[i].str);
/* prevent second command
@@ -559,6 +559,6 @@ check_cmd(void (*fn)(void),
void
cmd_helper_err(void)
{
- err(ECANCELED,
+ b0rk(ECANCELED,
"Erroneously running command twice");
}
diff --git a/util/libreboot-utils/lib/file.c b/util/libreboot-utils/lib/file.c
index 4a12cca7..46d5e016 100644
--- a/util/libreboot-utils/lib/file.c
+++ b/util/libreboot-utils/lib/file.c
@@ -96,16 +96,16 @@ void
xopen(int *fd_ptr, const char *path, int flags, struct stat *st)
{
if ((*fd_ptr = open(path, flags)) < 0)
- err(errno, "%s", path);
+ err_no_cleanup(errno, "%s", path);
if (fstat(*fd_ptr, st) < 0)
- err(errno, "%s: stat", path);
+ err_no_cleanup(errno, "%s: stat", path);
if (!S_ISREG(st->st_mode))
- err(errno, "%s: not a regular file", path);
+ err_no_cleanup(errno, "%s: not a regular file", path);
if (lseek_on_eintr(*fd_ptr, 0, SEEK_CUR, 1, 1) == (off_t)-1)
- err(errno, "%s: file not seekable", path);
+ err_no_cleanup(errno, "%s: file not seekable", path);
}
/* fsync() the directory of a file,
diff --git a/util/libreboot-utils/lib/io.c b/util/libreboot-utils/lib/io.c
index 295e15c0..d05adbcc 100644
--- a/util/libreboot-utils/lib/io.c
+++ b/util/libreboot-utils/lib/io.c
@@ -32,16 +32,16 @@ open_gbe_file(void)
O_NOFOLLOW | O_CLOEXEC | O_NOCTTY, &f->gbe_st);
if (f->gbe_st.st_nlink > 1)
- err(EINVAL,
+ b0rk(EINVAL,
"%s: warning: file has multiple (%lu) hard links\n",
f->fname, (size_t)f->gbe_st.st_nlink);
if (f->gbe_st.st_nlink == 0)
- err(EIO, "%s: file unlinked while open", f->fname);
+ b0rk(EIO, "%s: file unlinked while open", f->fname);
_flags = fcntl(f->gbe_fd, F_GETFL);
if (_flags == -1)
- err(errno, "%s: fcntl(F_GETFL)", f->fname);
+ b0rk(errno, "%s: fcntl(F_GETFL)", f->fname);
/* O_APPEND allows POSIX write() to ignore
* the current write offset and write at EOF,
@@ -49,7 +49,7 @@ open_gbe_file(void)
*/
if (_flags & O_APPEND)
- err(EIO, "%s: O_APPEND flag", f->fname);
+ b0rk(EIO, "%s: O_APPEND flag", f->fname);
f->gbe_file_size = f->gbe_st.st_size;
@@ -59,11 +59,11 @@ open_gbe_file(void)
case SIZE_128KB:
break;
default:
- err(EINVAL, "File size must be 8KB, 16KB or 128KB");
+ b0rk(EINVAL, "File size must be 8KB, 16KB or 128KB");
}
if (lock_file(f->gbe_fd, cmd->flags) == -1)
- err(errno, "%s: can't lock", f->fname);
+ b0rk(errno, "%s: can't lock", f->fname);
}
void
@@ -98,7 +98,7 @@ read_file(void)
MAX_ZERO_RW_RETRY, OFF_ERR);
if (_r < 0)
- err(errno, "%s: read failed", f->fname);
+ b0rk(errno, "%s: read failed", f->fname);
/* copy to tmpfile
*/
@@ -107,34 +107,34 @@ read_file(void)
MAX_ZERO_RW_RETRY, OFF_ERR);
if (_r < 0)
- err(errno, "%s: %s: copy failed",
+ b0rk(errno, "%s: %s: copy failed",
f->fname, f->tname);
/* file size comparison
*/
if (fstat(f->tmp_fd, &_st) == -1)
- err(errno, "%s: stat", f->tname);
+ b0rk(errno, "%s: stat", f->tname);
f->gbe_tmp_size = _st.st_size;
if (f->gbe_tmp_size != f->gbe_file_size)
- err(EIO, "%s: %s: not the same size",
+ b0rk(EIO, "%s: %s: not the same size",
f->fname, f->tname);
/* needs sync, for verification
*/
if (fsync_on_eintr(f->tmp_fd) == -1)
- err(errno, "%s: fsync (tmpfile copy)", f->tname);
+ b0rk(errno, "%s: fsync (tmpfile copy)", f->tname);
_r = rw_file_exact(f->tmp_fd, f->bufcmp, f->gbe_file_size,
0, IO_PREAD, NO_LOOP_EAGAIN, LOOP_EINTR,
MAX_ZERO_RW_RETRY, OFF_ERR);
if (_r < 0)
- err(errno, "%s: read failed (cmp)", f->tname);
+ b0rk(errno, "%s: read failed (cmp)", f->tname);
if (memcmp(f->buf, f->bufcmp, f->gbe_file_size) != 0)
- err(errno, "%s: %s: read contents differ (pre-test)",
+ b0rk(errno, "%s: %s: read contents differ (pre-test)",
f->fname, f->tname);
}
@@ -152,10 +152,10 @@ write_gbe_file(void)
return;
if (same_file(f->tmp_fd, &f->tmp_st, 0) < 0)
- err(errno, "%s: file inode/device changed", f->tname);
+ b0rk(errno, "%s: file inode/device changed", f->tname);
if (same_file(f->gbe_fd, &f->gbe_st, 1) < 0)
- err(errno, "%s: file has changed", f->fname);
+ b0rk(errno, "%s: file has changed", f->fname);
update_checksum = cmd->chksum_write;
@@ -188,7 +188,7 @@ rw_gbe_file_part(size_t p, int rw_type,
gbe_rw_size = cmd->rw_size;
if (rw_type < IO_PREAD || rw_type > IO_PWRITE)
- err(errno, "%s: %s: part %lu: invalid rw_type, %d",
+ b0rk(errno, "%s: %s: part %lu: invalid rw_type, %d",
f->fname, rw_type_str, (size_t)p, rw_type);
mem_offset = gbe_mem_offset(p, rw_type_str);
@@ -198,11 +198,11 @@ rw_gbe_file_part(size_t p, int rw_type,
gbe_rw_size, file_offset, rw_type);
if (rval == -1)
- err(errno, "%s: %s: part %lu",
+ b0rk(errno, "%s: %s: part %lu",
f->fname, rw_type_str, (size_t)p);
if ((size_t)rval != gbe_rw_size)
- err(EIO, "%s: partial %s: part %lu",
+ b0rk(EIO, "%s: partial %s: part %lu",
f->fname, rw_type_str, (size_t)p);
}
@@ -226,7 +226,7 @@ write_to_gbe_bin(void)
*/
if (fsync_on_eintr(f->tmp_fd) == -1)
- err(errno, "%s: fsync (pre-verification)",
+ b0rk(errno, "%s: fsync (pre-verification)",
f->tname);
check_written_part(0);
@@ -235,7 +235,7 @@ write_to_gbe_bin(void)
report_io_err_rw();
if (f->io_err_gbe)
- err(EIO, "%s: bad write", f->fname);
+ b0rk(EIO, "%s: bad write", f->fname);
saved_errno = errno;
@@ -307,10 +307,10 @@ check_written_part(size_t p)
memset(f->pad, 0xff, sizeof(f->pad));
if (same_file(f->tmp_fd, &f->tmp_st, 0) < 0)
- err(errno, "%s: file inode/device changed", f->tname);
+ b0rk(errno, "%s: file inode/device changed", f->tname);
if (same_file(f->gbe_fd, &f->gbe_st, 1) < 0)
- err(errno, "%s: file changed during write", f->fname);
+ b0rk(errno, "%s: file changed during write", f->fname);
rval = rw_gbe_file_exact(f->tmp_fd, f->pad,
gbe_rw_size, file_offset, IO_PREAD);
@@ -540,11 +540,11 @@ gbe_x_offset(size_t p, const char *f_op, const char *d_type,
off = ((off_t)p) * (off_t)nsize;
if (off > ncmp - GBE_PART_SIZE)
- err(ECANCELED, "%s: GbE %s %s out of bounds",
+ b0rk(ECANCELED, "%s: GbE %s %s out of bounds",
f->fname, d_type, f_op);
if (off != 0 && off != ncmp >> 1)
- err(ECANCELED, "%s: GbE %s %s at bad offset",
+ b0rk(ECANCELED, "%s: GbE %s %s at bad offset",
f->fname, d_type, f_op);
return off;
diff --git a/util/libreboot-utils/lib/num.c b/util/libreboot-utils/lib/num.c
index 91a1514f..43efba71 100644
--- a/util/libreboot-utils/lib/num.c
+++ b/util/libreboot-utils/lib/num.c
@@ -436,6 +436,6 @@ void
check_bin(size_t a, const char *a_name)
{
if (a > 1)
- err(EINVAL, "%s must be 0 or 1, but is %lu",
+ err_no_cleanup(EINVAL, "%s must be 0 or 1, but is %lu",
a_name, (size_t)a);
}
diff --git a/util/libreboot-utils/lib/state.c b/util/libreboot-utils/lib/state.c
index a1120906..409c2544 100644
--- a/util/libreboot-utils/lib/state.c
+++ b/util/libreboot-utils/lib/state.c
@@ -170,7 +170,7 @@ xstatus(void)
}
void
-err(int nvm_errval, const char *msg, ...)
+b0rk(int nvm_errval, const char *msg, ...)
{
struct xstate *x = xstatus();
diff --git a/util/libreboot-utils/lib/usage.c b/util/libreboot-utils/lib/usage.c
index 3b0614e8..2b5a93ca 100644
--- a/util/libreboot-utils/lib/usage.c
+++ b/util/libreboot-utils/lib/usage.c
@@ -26,5 +26,5 @@ usage(void)
util, util, util, util,
util, util, util);
- err(EINVAL, "Too few arguments");
+ b0rk(EINVAL, "Too few arguments");
}
diff --git a/util/libreboot-utils/lib/word.c b/util/libreboot-utils/lib/word.c
index f84dae6a..6563e67a 100644
--- a/util/libreboot-utils/lib/word.c
+++ b/util/libreboot-utils/lib/word.c
@@ -63,6 +63,6 @@ check_nvm_bound(size_t c, size_t p)
check_bin(p, "part number");
if (c >= NVM_WORDS)
- err(ECANCELED, "check_nvm_bound: out of bounds %lu",
+ b0rk(ECANCELED, "check_nvm_bound: out of bounds %lu",
(size_t)c);
}
diff --git a/util/libreboot-utils/nvmutil.c b/util/libreboot-utils/nvmutil.c
index da7d40ec..d9b91349 100644
--- a/util/libreboot-utils/nvmutil.c
+++ b/util/libreboot-utils/nvmutil.c
@@ -80,29 +80,29 @@ main(int argc, char *argv[])
if ((us.cmd[i].flags & O_ACCMODE) == O_RDONLY) {
if (unveil(us.f.fname, "r") == -1)
- err(errno, "%s: unveil r", us.f.fname);
+ b0rk(errno, "%s: unveil r", us.f.fname);
} else {
if (unveil(us.f.fname, "rwc") == -1)
- err(errno, "%s: unveil rw", us.f.fname);
+ b0rk(errno, "%s: unveil rw", us.f.fname);
}
if (unveil(us.f.tname, "rwc") == -1)
- err(errno, "unveil rwc: %s", us.f.tname);
+ b0rk(errno, "unveil rwc: %s", us.f.tname);
if (unveil(NULL, NULL) == -1)
- err(errno, "unveil block (rw)");
+ b0rk(errno, "unveil block (rw)");
if (pledge("stdio flock rpath wpath cpath", NULL) == -1)
- err(errno, "pledge (kill unveil)");
+ b0rk(errno, "pledge (kill unveil)");
#elif (OpenBSD) >= 509
if (pledge("stdio flock rpath wpath cpath", NULL) == -1)
- err(errno, "pledge");
+ b0rk(errno, "pledge");
#endif
#endif
if (cmd->run == NULL)
- err(errno, "Command not set");
+ b0rk(errno, "Command not set");
sanitize_command_list();
@@ -121,10 +121,10 @@ main(int argc, char *argv[])
write_to_gbe_bin();
if (exit_cleanup() == -1)
- err(EIO, "%s: close", f->fname);
+ b0rk(EIO, "%s: close", f->fname);
if (f->io_err_gbe_bin)
- err(EIO, "%s: error writing final file");
+ b0rk(EIO, "%s: error writing final file");
free_if_null(&f->tname);