From: Shachar Sharon Date: Sun, 20 Oct 2024 08:50:13 +0000 (+0300) Subject: vfs_ceph_new: improve mount cache-entry add X-Git-Tag: samba-4.20.8~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a09316d29c0ae97f583196f2624f79cb4a54364;p=thirdparty%2Fsamba.git vfs_ceph_new: improve mount cache-entry add 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 Reviewed-by: Anoop C S Reviewed-by: John Mulligan (cherry picked from commit 866b872cdb2b08a8b5e6a9015cde9b34c4bcdf01) --- diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index 073a51ce94c..2b265f0f80b 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -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; }