From: Volker Lendecke Date: Sun, 19 Oct 2025 09:36:17 +0000 (+0200) Subject: vfs_commit: Some README.Coding changes X-Git-Tag: tdb-1.4.15~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e196fa4fb3174215843d907e016ded6c9886b35c;p=thirdparty%2Fsamba.git vfs_commit: Some README.Coding changes Reduce indentation with early returns Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c index 55d82abb10d..5cedf5f2b82 100644 --- a/source3/modules/vfs_commit.c +++ b/source3/modules/vfs_commit.c @@ -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(