[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH v2 2/2] ash: avoid GLIBC'ism %m
From: Johannes Schindelin <johannes.schindelin () gmx ! de>
Date: 2017-07-19 21:34:25
Message-ID: 4f32bf966c9a9e4046ccb4dbc1e4b3a437e5a9db.1500500023.git.johannes.schindelin () gmx ! de
[Download RAW message or body]
GLIBC's printf() family supports the extension where the placeholder %m
is interpolated to strerror(errno).
This is not portable. So don't use it. (It was only used in ash's source
code to begin with.)
Let's use the newly-introduced ash_perror_msg_and_raise_error() helper
function instead.
Helped-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
shell/ash.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/shell/ash.c b/shell/ash.c
index c21b25ab7..51d13e537 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3826,7 +3826,7 @@ static void
xtcsetpgrp(int fd, pid_t pgrp)
{
if (tcsetpgrp(fd, pgrp))
- ash_msg_and_raise_error("can't set tty process group (%m)");
+ ash_perror_msg_and_raise_error("can't set tty process group");
}
/*
@@ -5359,7 +5359,7 @@ savefd(int from)
err = newfd < 0 ? errno : 0;
if (err != EBADF) {
if (err)
- ash_msg_and_raise_error("%d: %m", from);
+ ash_perror_msg_and_raise_error("%d", from);
close(from);
fcntl(newfd, F_SETFD, FD_CLOEXEC);
}
@@ -5374,7 +5374,7 @@ dup2_or_raise(int from, int to)
newfd = (from != to) ? dup2(from, to) : to;
if (newfd < 0) {
/* Happens when source fd is not open: try "echo >&99" */
- ash_msg_and_raise_error("%d: %m", from);
+ ash_perror_msg_and_raise_error("%d", from);
}
return newfd;
}
@@ -5505,7 +5505,7 @@ redirect(union node *redir, int flags)
/* "echo >&10" and 10 is a fd opened to a sh script? */
if (is_hidden_fd(sv, right_fd)) {
errno = EBADF; /* as if it is closed */
- ash_msg_and_raise_error("%d: %m", right_fd);
+ ash_perror_msg_and_raise_error("%d", right_fd);
}
newfd = -1;
} else {
@@ -5539,7 +5539,7 @@ redirect(union node *redir, int flags)
if (newfd >= 0)
close(newfd);
errno = i;
- ash_msg_and_raise_error("%d: %m", fd);
+ ash_perror_msg_and_raise_error("%d", fd);
/* NOTREACHED */
}
/* EBADF: it is not open - good, remember to close it */
--
2.13.3.windows.1.13.gaf0c2223da0
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic