<!DOCTYPE html><html dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><head><body><div><div><br><blockquote>---- Original Message ----<br>
From: "Kir Kolyshkin" <kir@openvz.org><br>
To: criu@openvz.org<br>CC: xemul@parallels.com, "Kir Kolyshkin" <kir@openvz.org>, "Shawn Landden" <shawn@churchofgit.com><br>
Sent: Thu, Dec 19, 2013, 01:24 PM<br>
Subject: [PATCH 1/3] sd-daemon.c: whitespace cleanup<br><br><br>We use tabs for indentation.<br><br>Also, s/fd ++/fd++/<br><br></blockquote><span>I didn't write this code, it is imported from systemd, and IMHO we should keep the style the way it was in the original. </span><br><blockquote>Cc: Shawn Landden <<a target="_blank" href="mailto:shawn@churchofgit.com">shawn@churchofgit.com</a>><br>Signed-off-by: Kir Kolyshkin <<a target="_blank" href="mailto:kir@openvz.org">kir@openvz.org</a>><br>---<br>sd-daemon.c | 149 ++++++++++++++++++++++++++++++------------------------------<br>1 file changed, 74 insertions(+), 75 deletions(-)<br><br>diff --git a/sd-daemon.c b/sd-daemon.c<br>index 653fbf5..3558aaf 100644<br>--- a/sd-daemon.c<br>+++ b/sd-daemon.c<br>@@ -49,84 +49,83 @@<br>_sd_export_ int sd_listen_fds(int unset_environment) {<br><br>#if defined(DISABLE_SYSTEMD) || !defined(__linux__)<br>- return 0;<br>+ return 0;<br>#else<br>- int r, fd;<br>- const char *e;<br>- char *p = NULL;<br>- unsigned long l;<br>-<br>- e = getenv("LISTEN_PID");<br>- if (!e) {<br>- r = 0;<br>- goto finish;<br>- }<br>-<br>- errno = 0;<br>- l = strtoul(e, &p, 10);<br>-<br>- if (errno > 0) {<br>- r = -errno;<br>- goto finish;<br>- }<br>-<br>- if (!p || p == e || *p || l <= 0) {<br>- r = -EINVAL;<br>- goto finish;<br>- }<br>-<br>- /* Is this for us? */<br>- if (getpid() != (pid_t) l) {<br>- r = 0;<br>- goto finish;<br>- }<br>-<br>- e = getenv("LISTEN_FDS");<br>- if (!e) {<br>- r = 0;<br>- goto finish;<br>- }<br>-<br>- errno = 0;<br>- l = strtoul(e, &p, 10);<br>-<br>- if (errno > 0) {<br>- r = -errno;<br>- goto finish;<br>- }<br>-<br>- if (!p || p == e || *p) {<br>- r = -EINVAL;<br>- goto finish;<br>- }<br>-<br>- for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {<br>- int flags;<br>-<br>- flags = fcntl(fd, F_GETFD);<br>- if (flags < 0) {<br>- r = -errno;<br>- goto finish;<br>- }<br>-<br>- if (flags & FD_CLOEXEC)<br>- continue;<br>-<br>- if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {<br>- r = -errno;<br>- goto finish;<br>- }<br>- }<br>-<br>- r = (int) l;<br>+ int r, fd;<br>+ const char *e;<br>+ char *p = NULL;<br>+ unsigned long l;<br>+<br>+ e = getenv("LISTEN_PID");<br>+ if (!e) {<br>+ r = 0;<br>+ goto finish;<br>+ }<br>+<br>+ errno = 0;<br>+ l = strtoul(e, &p, 10);<br>+<br>+ if (errno > 0) {<br>+ r = -errno;<br>+ goto finish;<br>+ }<br>+<br>+ if (!p || p == e || *p || l <= 0) {<br>+ r = -EINVAL;<br>+ goto finish;<br>+ }<br>+<br>+ /* Is this for us? */<br>+ if (getpid() != (pid_t) l) {<br>+ r = 0;<br>+ goto finish;<br>+ }<br>+<br>+ e = getenv("LISTEN_FDS");<br>+ if (!e) {<br>+ r = 0;<br>+ goto finish;<br>+ }<br>+<br>+ errno = 0;<br>+ l = strtoul(e, &p, 10);<br>+<br>+ if (errno > 0) {<br>+ r = -errno;<br>+ goto finish;<br>+ }<br>+<br>+ if (!p || p == e || *p) {<br>+ r = -EINVAL;<br>+ goto finish;<br>+ }<br>+<br>+ for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int)l; fd++) {<br>+ int flags;<br>+<br>+ flags = fcntl(fd, F_GETFD);<br>+ if (flags < 0) {<br>+ r = -errno;<br>+ goto finish;<br>+ }<br>+<br>+ if (flags & FD_CLOEXEC)<br>+ continue;<br>+<br>+ if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {<br>+ r = -errno;<br>+ goto finish;<br>+ }<br>+ }<br>+<br>+ r = (int) l;<br><br>finish:<br>- if (unset_environment) {<br>- unsetenv("LISTEN_PID");<br>- unsetenv("LISTEN_FDS");<br>- }<br>+ if (unset_environment) {<br>+ unsetenv("LISTEN_PID");<br>+ unsetenv("LISTEN_FDS");<br>+ }<br><br>- return r;<br>+ return r;<br>#endif<br>}<br>-<br>-- <br>1.8.1.4</blockquote></div></div></body></html>