]> xenbits.xensource.com Git - libvirt.git/commitdiff
virfile: Modernize definition of virFileOpenForked/virFileOpenForceOwnerMode/virFileO...
authorPeter Krempa <pkrempa@redhat.com>
Wed, 22 May 2024 15:30:50 +0000 (17:30 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 23 May 2024 12:32:24 +0000 (14:32 +0200)
Declare one argument per line and one variable per line and use boolean
operators at the end of the line rather than at the beginning.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/util/virfile.c

index c769f7d65031810999b925929ddf0c06e9c78f59..f66ecd29a2aff6b515b4a36e138e9ce7488eeed9 100644 (file)
@@ -2330,8 +2330,12 @@ virFileAccessibleAs(const char *path, int mode,
  * opened as "fd" if it's not correct AND the flags say it should be
  * forced. */
 static int
-virFileOpenForceOwnerMode(const char *path, int fd, mode_t mode,
-                          uid_t uid, gid_t gid, unsigned int flags)
+virFileOpenForceOwnerMode(const char *path,
+                          int fd,
+                          mode_t mode,
+                          uid_t uid,
+                          gid_t gid,
+                          unsigned int flags)
 {
     int ret = 0;
     struct stat st;
@@ -2381,11 +2385,16 @@ virFileOpenForceOwnerMode(const char *path, int fd, mode_t mode,
  * buildVol backend function expects the file to be deleted on error.
  */
 static int
-virFileOpenForked(const char *path, int openflags, mode_t mode,
-                  uid_t uid, gid_t gid, unsigned int flags)
+virFileOpenForked(const char *path,
+                  int openflags,
+                  mode_t mode,
+                  uid_t uid,
+                  gid_t gid,
+                  unsigned int flags)
 {
     pid_t pid;
-    int status = 0, ret = 0;
+    int status = 0;
+    int ret = 0;
     int recvfd_errno = 0;
     int fd = -1;
     int pair[2] = { -1, -1 };
@@ -2546,10 +2555,15 @@ virFileOpenForked(const char *path, int openflags, mode_t mode,
  * expects the file to be deleted on error.
  */
 int
-virFileOpenAs(const char *path, int openflags, mode_t mode,
-              uid_t uid, gid_t gid, unsigned int flags)
+virFileOpenAs(const char *path,
+              int openflags,
+              mode_t mode,
+              uid_t uid,
+              gid_t gid,
+              unsigned int flags)
 {
-    int ret = 0, fd = -1;
+    int ret = 0;
+    int fd = -1;
     bool created = false;
 
     /* allow using -1 to mean "current value" */
@@ -2563,9 +2577,9 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
     if (!(flags & (VIR_FILE_OPEN_NOFORK|VIR_FILE_OPEN_FORK)))
         flags |= VIR_FILE_OPEN_NOFORK|VIR_FILE_OPEN_FORK;
 
-    if ((flags & VIR_FILE_OPEN_NOFORK)
-        || (geteuid() != 0)
-        || ((uid == 0) && (gid == 0))) {
+    if ((flags & VIR_FILE_OPEN_NOFORK) ||
+        (geteuid() != 0) ||
+        ((uid == 0) && (gid == 0))) {
 
         if ((fd = open(path, openflags, mode)) < 0) {
             ret = -errno;