[systemd-devel] [PATCH] tmpfiles: remember errno before it might be overwritten
Michael Olbrich
m.olbrich at pengutronix.de
Thu Apr 30 11:34:56 PDT 2015
---
I'm not sure if this is really necessary right now, but that might change
in the future. Saving errno before calling another function is always a
good idea.
Michael
src/tmpfiles/tmpfiles.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index d574254e0fb8..218d55051410 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -1279,13 +1279,15 @@ static int create_item(Item *i) {
mac_selinux_create_file_prepare(i->path, S_IFLNK);
r = symlink(resolved, i->path);
+ if (r < 0)
+ r = -errno;
mac_selinux_create_file_clear();
if (r < 0) {
_cleanup_free_ char *x = NULL;
- if (errno != EEXIST)
- return log_error_errno(errno, "symlink(%s, %s) failed: %m", resolved, i->path);
+ if (r != -EEXIST)
+ return log_error_errno(r, "symlink(%s, %s) failed: %m", resolved, i->path);
r = readlink_malloc(i->path, &x);
if (r < 0 || !streq(resolved, x)) {
--
2.1.4
More information about the systemd-devel
mailing list