]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_ceph_new: improve mount cache-entry add
authorShachar Sharon <ssharon@redhat.com>
Sun, 20 Oct 2024 08:50:13 +0000 (11:50 +0300)
committerJule Anger <janger@samba.org>
Mon, 17 Feb 2025 16:09:09 +0000 (16:09 +0000)
Use boolean return value from cephmount_cache_add, to align code-style
with other caphmount helper functions. Returns false in case of memory
allocation failure, true otherwise (success).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15703

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit 866b872cdb2b08a8b5e6a9015cde9b34c4bcdf01)

source3/modules/vfs_ceph_new.c

index 073a51ce94cf19cfbf8a1b1754ad1c330660fd09..2b265f0f80b9802ad3d043ebae7c3a51c24a12dc 100644 (file)
@@ -178,23 +178,23 @@ static struct cephmount_cached {
        uint64_t fd_index;
 } *cephmount_cached;
 
-static int cephmount_cache_add(const char *cookie,
-                              struct ceph_mount_info *mount,
-                              struct cephmount_cached **out_entry)
+static bool cephmount_cache_add(const char *cookie,
+                               struct ceph_mount_info *mount,
+                               struct cephmount_cached **out_entry)
 {
        struct cephmount_cached *entry = NULL;
 
        entry = talloc_zero(NULL, struct cephmount_cached);
        if (entry == NULL) {
                errno = ENOMEM;
-               return -1;
+               return false;
        }
 
        entry->cookie = talloc_strdup(entry, cookie);
        if (entry->cookie == NULL) {
                talloc_free(entry);
                errno = ENOMEM;
-               return -1;
+               return false;
        }
 
        entry->mount = mount;
@@ -204,7 +204,7 @@ static int cephmount_cache_add(const char *cookie,
        DLIST_ADD(cephmount_cached, entry);
 
        *out_entry = entry;
-       return 0;
+       return true;
 }
 
 static bool cephmount_cache_change_ref(struct cephmount_cached *entry, int n)
@@ -525,8 +525,9 @@ static int vfs_ceph_connect(struct vfs_handle_struct *handle,
                goto connect_fail;
        }
 
-       ret = cephmount_cache_add(cookie, mount, &entry);
-       if (ret != 0) {
+       ok = cephmount_cache_add(cookie, mount, &entry);
+       if (!ok) {
+               ret = -1;
                goto connect_fail;
        }