summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-10-10 08:11:14 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-11 16:46:25 +0200
commitb6c514bd1c2e13955ddd6a26df2c33ae74f17d0b (patch)
treec15bcedb9f2f15e41abc69f4bad3a06a92ae7add /commands
parent15111afb387482035fc64ca5b621ec6c933ac7f8 (diff)
downloadbarebox-b6c514bd1c2e13955ddd6a26df2c33ae74f17d0b.tar.gz
treewide: replace errno_str() with %m printf format specifier
Both errno_str() and printf("%m" end up calling strerror(). %m is more convenient to use, so switch over all instances to it. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061122.2084009-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/cat.c2
-rw-r--r--commands/edit.c4
-rw-r--r--commands/flash.c8
-rw-r--r--commands/ls.c3
-rw-r--r--commands/mkdir.c2
-rw-r--r--commands/rm.c2
-rw-r--r--commands/rmdir.c2
7 files changed, 11 insertions, 12 deletions
diff --git a/commands/cat.c b/commands/cat.c
index 17c31ed083..503520dc64 100644
--- a/commands/cat.c
+++ b/commands/cat.c
@@ -40,7 +40,7 @@ static int do_cat(int argc, char *argv[])
fd = open(argv[args], O_RDONLY);
if (fd < 0) {
err = 1;
- printf("could not open %s: %s\n", argv[args], errno_str());
+ printf("could not open %s: %m\n", argv[args]);
goto out;
}
diff --git a/commands/edit.c b/commands/edit.c
index 12695d39e4..dea383aae7 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -185,7 +185,7 @@ static int edit_read_file(const char *path)
if (!stat(path, &s)) {
filebuffer = read_file(path, NULL);
if (!filebuffer) {
- printf("could not read %s: %s\n", path, errno_str());
+ printf("could not read %s: %m\n", path);
return -1;
}
@@ -249,7 +249,7 @@ static int save_file(const char *path)
fd = open(path, O_WRONLY | O_TRUNC | O_CREAT);
if (fd < 0) {
- printf("could not open file for writing: %s\n", errno_str());
+ printf("could not open file for writing: %m\n");
return fd;
}
diff --git a/commands/flash.c b/commands/flash.c
index 3d7c8fd577..5b7060aead 100644
--- a/commands/flash.c
+++ b/commands/flash.c
@@ -25,7 +25,7 @@ static int do_flerase(int argc, char *argv[])
filename = argv[1];
if (stat(filename, &s)) {
- printf("stat %s: %s\n", filename, errno_str());
+ printf("stat %s: %m\n", filename);
return 1;
}
@@ -33,7 +33,7 @@ static int do_flerase(int argc, char *argv[])
fd = open(filename, O_WRONLY);
if (fd < 0) {
- printf("open %s: %s\n", filename, errno_str());
+ printf("open %s: %m\n", filename);
return 1;
}
@@ -89,7 +89,7 @@ static int do_protect(int argc, char *argv[])
prot = 0;
if (stat(filename, &s)) {
- printf("stat %s: %s\n", filename, errno_str());
+ printf("stat %s: %m\n", filename);
return 1;
}
@@ -97,7 +97,7 @@ static int do_protect(int argc, char *argv[])
fd = open(filename, O_WRONLY);
if (fd < 0) {
- printf("open %s: %s\n", filename, errno_str());
+ printf("open %s: %m\n", filename);
return 1;
}
diff --git a/commands/ls.c b/commands/ls.c
index 1192aed971..09a20e0a23 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -164,8 +164,7 @@ static int do_ls(int argc, char *argv[])
while (o < argc) {
ret = stat(argv[o], &s);
if (ret) {
- printf("%s: %s: %s\n", argv[0],
- argv[o], errno_str());
+ printf("%s: %s: %m\n", argv[0], argv[o]);
o++;
exitcode = COMMAND_ERROR;
continue;
diff --git a/commands/mkdir.c b/commands/mkdir.c
index e7153b8732..01fc0b083b 100644
--- a/commands/mkdir.c
+++ b/commands/mkdir.c
@@ -37,7 +37,7 @@ static int do_mkdir(int argc, char *argv[])
ret = mkdir(argv[optind], 0);
}
if (ret) {
- printf("could not create %s: %s\n", argv[optind], errno_str());
+ printf("could not create %s: %m\n", argv[optind]);
return 1;
}
optind++;
diff --git a/commands/rm.c b/commands/rm.c
index ba52b185cb..be5c192221 100644
--- a/commands/rm.c
+++ b/commands/rm.c
@@ -37,7 +37,7 @@ static int do_rm(int argc, char *argv[])
else
ret = unlink(argv[i]);
if (ret) {
- printf("could not remove %s: %s\n", argv[i], errno_str());
+ printf("could not remove %s: %m\n", argv[i]);
return 1;
}
i++;
diff --git a/commands/rmdir.c b/commands/rmdir.c
index 9b2938a556..44793ca56e 100644
--- a/commands/rmdir.c
+++ b/commands/rmdir.c
@@ -14,7 +14,7 @@ static int do_rmdir(int argc, char *argv[])
while (i < argc) {
if (rmdir(argv[i])) {
- printf("could not remove %s: %s\n", argv[i], errno_str());
+ printf("could not remove %s: %m\n", argv[i]);
return 1;
}
i++;