summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-11-01 11:43:34 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-11-03 22:04:39 +0900
commitfe573a798da7924aca78eaa8e76a462686071335 (patch)
treed521d1ad9d3d76804accd3ed2659ea58863b3783
parent857403952075508d45e7996f4445a2140e158409 (diff)
downloadsystemd-fe573a798da7924aca78eaa8e76a462686071335.tar.gz
fs-util: let's avoid unnecessary strerror()
strerror() is not thread safe. Let's avoid it where it is easy hence. (Ideally we'd not use it at all anymore, but that's sometimes a bit nasty, not in this case though, where it is very easy to avoid) Follow-up for: 27c3112dcbd1b5f171c36c32550d9c6331375b0b
-rw-r--r--src/basic/fs-util.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index 9d2cff0d24..6e6fa20053 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -662,15 +662,12 @@ int inotify_add_watch_fd(int fd, int what, uint32_t mask) {
}
int inotify_add_watch_and_warn(int fd, const char *pathname, uint32_t mask) {
- if (inotify_add_watch(fd, pathname, mask) < 0) {
- const char *reason;
+ if (inotify_add_watch(fd, pathname, mask) < 0) {
if (errno == ENOSPC)
- reason = "inotify watch limit reached";
- else
- reason = strerror_safe(errno);
+ return log_error_errno(errno, "Failed to add a watch for %s: inotify watch limit reached", pathname);
- return log_error_errno(errno, "Failed to add a watch for %s: %s", pathname, reason);
+ return log_error_errno(errno, "Failed to add a watch for %s: %m", pathname);
}
return 0;