]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_commit: Some README.Coding changes
authorVolker Lendecke <vl@samba.org>
Sun, 19 Oct 2025 09:36:17 +0000 (11:36 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 7 Jan 2026 09:57:41 +0000 (09:57 +0000)
Reduce indentation with early returns

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/modules/vfs_commit.c

index 55d82abb10d2ad95f1c790730d79acff17a19b61..5cedf5f2b82639e298e2393bbb82d01cf80029e9 100644 (file)
@@ -124,10 +124,10 @@ static int commit(
        off_t                   offset,
         ssize_t                                last_write)
 {
-        struct commit_info *c;
+       struct commit_info *c = VFS_FETCH_FSP_EXTENSION(handle, fsp);
+       int ret;
 
-        if ((c = (struct commit_info *)VFS_FETCH_FSP_EXTENSION(handle, fsp))
-           == NULL) {
+       if (c == NULL) {
                return 0;
        }
 
@@ -144,21 +144,26 @@ static int commit(
                return 0;
        }
 
+       if ((offset + last_write) < c->eof) {
+               return 0;
+       }
+
        /* This write hit or went past our cache the file size. */
-       if ((offset + last_write) >= c->eof) {
-               if (commit_do(c, fsp_get_io_fd(fsp)) == -1) {
-                       return -1;
-               }
 
-               /* Hinted mode only commits the first time we hit EOF. */
-               if (c->on_eof == EOF_HINTED) {
-                   c->eof = -1;
-               } else if (c->on_eof == EOF_GROWTH) {
-                   c->eof = offset + last_write;
-               }
+       ret = commit_do(c, fsp_get_io_fd(fsp));
+
+       if (ret == -1) {
+               return -1;
        }
 
-        return 0;
+       /* Hinted mode only commits the first time we hit EOF. */
+       if (c->on_eof == EOF_HINTED) {
+               c->eof = -1;
+       } else if (c->on_eof == EOF_GROWTH) {
+               c->eof = offset + last_write;
+       }
+
+       return 0;
 }
 
 static int commit_connect(