summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-18 16:42:49 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-18 16:42:49 +0100
commit0897a0be1720aceb04e0b62da23933d10767b585 (patch)
tree04fe920e8c76ccbfc4a09a4bef9c63049a2824d8 /util
parent9a92524a47fa9d1c5102ead99250a86b1a635866 (diff)
util/nvmutil: always print filename in err_if
the previous code size optimisations removed mention of the file name, on file-related err() calls. almost every error the user runs across will be file related, so put the path on err() called from err_if() Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 0d0471a..290808d 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -31,7 +31,6 @@ void setWord(int pos16, int partnum, uint16_t val16);
void xorswap_buf(int partnum);
void writeGbeFile(void);
-#define FILENAME argv[1]
#define COMMAND argv[2]
#define MAC_ADDRESS argv[3]
#define PARTNUM argv[3]
@@ -43,7 +42,7 @@ size_t nf = 128, gbe[2];
uint8_t nvmPartModified[2] = {0, 0}, skipread[2] = {0, 0};
int endian = 1, flags = O_RDWR, rfd, fd, part, gbeFileModified = 0;
-const char *strMac = NULL, *strRMac = "??:??:??:??:??:??";
+const char *strMac = NULL, *strRMac = "??:??:??:??:??:??", *filename = NULL;
typedef struct op {
char *str;
@@ -61,7 +60,7 @@ op_t op[] = {
void (*cmd)(void) = NULL;
#define ERR() errno = errno ? errno : ECANCELED
-#define err_if(x) if (x) err(ERR(), NULL)
+#define err_if(x) if (x) err(ERR(), "%s", filename)
#define xopen(f,l,p) if (opendir(l) != NULL) err(errno = EISDIR, "%s", l); \
if ((f = open(l, p)) == -1) err(ERR(), "%s", l); \
@@ -76,13 +75,14 @@ main(int argc, char *argv[])
{
err_if((errno = argc < 3 ? EINVAL : errno));
flags = (strcmp(COMMAND, "dump") == 0) ? O_RDONLY : flags;
+ filename = argv[1];
#ifdef __OpenBSD__
err_if(unveil("/dev/urandom", "r") == -1);
- err_if(unveil(FILENAME, flags == O_RDONLY ? "r" : "rw") == -1);
+ err_if(unveil(filename, flags == O_RDONLY ? "r" : "rw") == -1);
err_if(pledge(flags == O_RDONLY ? "stdio rpath" : "stdio rpath wpath",
NULL) == -1);
#endif
- openFiles(FILENAME);
+ openFiles(filename);
#ifdef __OpenBSD__
err_if(pledge("stdio", NULL) == -1);
#endif