Skip to content

Commit a2e52d3

Browse files
committed
pybind: fix callback function type compatibility for GCC 14/15
The callback function types in Cython source files were inconsistent with the corresponding librados and librgw API declarations, causing build failures with GCC 14 and 15. GCC 14 introduced stricter pointer type checking and no longer allows implicit casting between incompatible pointer types. This resulted in -Wincompatible-pointer-types errors where char** arguments were passed to functions expecting const char* const*. Example error: ``` rados.c: In function ‘__pyx_pf_5rados_12OmapIterator_4__next__’: rados.c:32423:76: error: passing argument 2 of ‘__pyx_f_5rados_rados_omap_get_next’ from incompatible pointer type [-Wincompatible-pointer-types] 32423 | __pyx_t_1 = __pyx_f_5rados_rados_omap_get_next(__pyx_v_self->ctx, (&__pyx_v_key_), (&__pyx_v_val_), (&__pyx_v_len_)); if (unlikely(__pyx_t_1 == ((int)-1) && __Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 1394, __pyx_L4_error) | ~^~~~~~~~~~~~~~ | | | char ** rados.c:9172:141: note: expected ‘const char * const*’ but argument is of type ‘char **’ 9172 | static int __pyx_f_5rados_rados_omap_get_next(CYTHON_UNUSED __pyx_t_5rados_rados_omap_iter_t __pyx_v_iter, CYTHON_UNUSED char const *const *__pyx_v_key, CYTHON_UNUSED char const *const *__pyx_v_val, CYTHON_UNUSED size_t *__pyx_v_len) { | ^ rados.c:32423:93: error: passing argument 3 of ‘__pyx_f_5rados_rados_omap_get_next’ from incompatible pointer type [-Wincompatible-pointer-types] 32423 | __pyx_t_1 = __pyx_f_5rados_rados_omap_get_next(__pyx_v_self->ctx, (&__pyx_v_key_), (&__pyx_v_val_), (&__pyx_v_len_)); if (unlikely(__pyx_t_1 == ((int)-1) && __Pyx_ErrOccurredWithGIL())) __PYX_ERR(0, 1394, __pyx_L4_error) | ~^~~~~~~~~~~~~~ | | | char ** rados.c:9172:187: note: expected ‘const char * const*’ but argument is of type ‘char **’ 9172 | static int __pyx_f_5rados_rados_omap_get_next(CYTHON_UNUSED __pyx_t_5rados_rados_omap_iter_t __pyx_v_iter, CYTHON_UNUSED char const *const *__pyx_v_key, CYTHON_UNUSED char const *const *__pyx_v_val, CYTHON_UNUSED size_t *__pyx_v_len) { | ^ error: command '/usr/bin/gcc' failed with exit code 1` ``` This change corrects the mock function implementations used during Sphinx documentation builds to match the actual API signatures. The public API remains unchanged to avoid requiring a major version bump. See also https://gcc.gnu.org/gcc-14/porting_to.html#incompatible-pointer-types Signed-off-by: Kefu Chai <[email protected]>
1 parent 668dc29 commit a2e52d3

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/pybind/rados/mock_rados.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ cdef nogil:
441441
pass
442442
void rados_read_op_set_flags(rados_read_op_t read_op, int flags):
443443
pass
444-
int rados_omap_get_next(rados_omap_iter_t iter, const char * const* key, const char * const* val, size_t * len):
444+
int rados_omap_get_next(rados_omap_iter_t iter, char ** key, char ** val, size_t * len):
445445
pass
446446
void rados_omap_get_end(rados_omap_iter_t iter):
447447
pass

src/pybind/rgw/c_rgw.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ cdef extern from "rados/rgw_file.h" nogil:
102102

103103
int rgw_readdir(rgw_fs *fs,
104104
rgw_file_handle *parent_fh, uint64_t *offset,
105-
bool (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
105+
int (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
106106
void *cb_arg, bool *eof, uint32_t flags) except? -9000
107107

108108
int rgw_getattr(rgw_fs *fs,

src/pybind/rgw/mock_rgw.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ cdef nogil:
116116

117117
int rgw_readdir(rgw_fs *fs,
118118
rgw_file_handle *parent_fh, uint64_t *offset,
119-
libcpp.bool (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
119+
int (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
120120
void *cb_arg, libcpp.bool *eof, uint32_t flags) except? -9000:
121121
pass
122122

src/pybind/rgw/rgw.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ cdef make_ex(ret, msg):
166166
return Error(msg + (": error code %d" % ret))
167167

168168

169-
cdef bint readdir_cb(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) \
169+
cdef int readdir_cb(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) \
170170
except? -9000 with gil:
171171
if exc.PyErr_Occurred():
172-
return False
172+
return 0
173173
(<object>arg)(name, offset, flags)
174-
return True
174+
return 1
175175

176176

177177
class LibCephFSStateError(Error):

0 commit comments

Comments
 (0)