Separating the indenation from the real patch made review easier.
* src/util/util.c (virFileOpenAs): Whitespace changes.
---
v3: new patch. 'git diff -b' first, then real patch:
diff --git a/src/util/util.c b/src/util/util.c
index 137cdb9..8d00ded 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1403,8 +1403,7 @@ static int virDirCreateNoFork(const char *path, mode_t mode, uid_t
uid, gid_t gi
struct stat st;
if ((mkdir(path, mode) < 0)
- && !((errno == EEXIST) && (flags &
VIR_DIR_CREATE_ALLOW_EXIST)))
- {
+ && !((errno == EEXIST) && (flags &
VIR_DIR_CREATE_ALLOW_EXIST))) {
ret = -errno;
virReportSystemError(errno, _("failed to create directory
'%s'"),
path);
@@ -1480,7 +1479,6 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
* following dance avoids problems caused by root-squashing
* NFS servers. */
- {
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) < 0) {
ret = -errno;
virReportSystemError(errno,
@@ -1500,7 +1498,6 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
- }
forkRet = virFork(&pid);
@@ -1510,7 +1507,6 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
}
if (pid) { /* parent */
- {
VIR_FORCE_CLOSE(pair[1]);
do {
@@ -1533,7 +1529,6 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
cmsg->cmsg_type == SCM_RIGHTS) {
memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
}
- }
/* wait for child to complete, and retrieve its exit code */
while ((waitret = waitpid(pid, &status, 0) == -1)
@@ -1612,7 +1607,6 @@ parenterror:
path, mode);
goto childerror;
}
- {
VIR_FORCE_CLOSE(pair[0]);
memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
@@ -1625,7 +1619,6 @@ parenterror:
VIR_FORCE_CLOSE(pair[1]);
goto childerror;
}
- }
ret = 0;
childerror:
src/util/util.c | 101 +++++++++++++++++++++++++-----------------------------
1 files changed, 47 insertions(+), 54 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 137cdb9..8d00ded 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1403,8 +1403,7 @@ static int virDirCreateNoFork(const char *path, mode_t mode, uid_t
uid, gid_t gi
struct stat st;
if ((mkdir(path, mode) < 0)
- && !((errno == EEXIST) && (flags &
VIR_DIR_CREATE_ALLOW_EXIST)))
- {
+ && !((errno == EEXIST) && (flags &
VIR_DIR_CREATE_ALLOW_EXIST))) {
ret = -errno;
virReportSystemError(errno, _("failed to create directory
'%s'"),
path);
@@ -1480,28 +1479,26 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
* following dance avoids problems caused by root-squashing
* NFS servers. */
- {
- if (socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) < 0) {
- ret = -errno;
- virReportSystemError(errno,
- _("failed to create socket needed for
'%s'"),
- path);
- return ret;
- }
-
- memset(&msg, 0, sizeof(msg));
- iov.iov_base = &dummy;
- iov.iov_len = 1;
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
- msg.msg_control = buf;
- msg.msg_controllen = sizeof(buf);
- cmsg = CMSG_FIRSTHDR(&msg);
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ if (socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) < 0) {
+ ret = -errno;
+ virReportSystemError(errno,
+ _("failed to create socket needed for
'%s'"),
+ path);
+ return ret;
}
+ memset(&msg, 0, sizeof(msg));
+ iov.iov_base = &dummy;
+ iov.iov_len = 1;
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = buf;
+ msg.msg_controllen = sizeof(buf);
+ cmsg = CMSG_FIRSTHDR(&msg);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+
forkRet = virFork(&pid);
if (pid < 0) {
@@ -1510,29 +1507,27 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
}
if (pid) { /* parent */
- {
- VIR_FORCE_CLOSE(pair[1]);
-
- do {
- ret = recvmsg(pair[0], &msg, 0);
- } while (ret < 0 && errno == EINTR);
-
- if (ret < 0) {
- ret = -errno;
- VIR_FORCE_CLOSE(pair[0]);
- while ((waitret = waitpid(pid, NULL, 0) == -1)
- && (errno == EINTR));
- goto parenterror;
- }
+ VIR_FORCE_CLOSE(pair[1]);
+
+ do {
+ ret = recvmsg(pair[0], &msg, 0);
+ } while (ret < 0 && errno == EINTR);
+
+ if (ret < 0) {
+ ret = -errno;
VIR_FORCE_CLOSE(pair[0]);
+ while ((waitret = waitpid(pid, NULL, 0) == -1)
+ && (errno == EINTR));
+ goto parenterror;
+ }
+ VIR_FORCE_CLOSE(pair[0]);
- /* See if fd was transferred. */
- cmsg = CMSG_FIRSTHDR(&msg);
- if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(fd)) &&
- cmsg->cmsg_level == SOL_SOCKET &&
- cmsg->cmsg_type == SCM_RIGHTS) {
- memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
- }
+ /* See if fd was transferred. */
+ cmsg = CMSG_FIRSTHDR(&msg);
+ if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(fd)) &&
+ cmsg->cmsg_level == SOL_SOCKET &&
+ cmsg->cmsg_type == SCM_RIGHTS) {
+ memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
}
/* wait for child to complete, and retrieve its exit code */
@@ -1612,19 +1607,17 @@ parenterror:
path, mode);
goto childerror;
}
- {
- VIR_FORCE_CLOSE(pair[0]);
- memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+ VIR_FORCE_CLOSE(pair[0]);
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
- do {
- ret = sendmsg(pair[1], &msg, 0);
- } while (ret < 0 && errno == EINTR);
+ do {
+ ret = sendmsg(pair[1], &msg, 0);
+ } while (ret < 0 && errno == EINTR);
- if (ret < 0) {
- ret = -errno;
- VIR_FORCE_CLOSE(pair[1]);
- goto childerror;
- }
+ if (ret < 0) {
+ ret = -errno;
+ VIR_FORCE_CLOSE(pair[1]);
+ goto childerror;
}
ret = 0;
--
1.7.4