]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind: fix callback function type compatibility for GCC 14/15
authorKefu Chai <tchaikov@gmail.com>
Wed, 25 Jun 2025 11:58:42 +0000 (19:58 +0800)
committerKefu Chai <tchaikov@gmail.com>
Wed, 25 Jun 2025 13:02:09 +0000 (21:02 +0800)
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 <tchaikov@gmail.com>
src/pybind/rados/mock_rados.pxi
src/pybind/rgw/c_rgw.pxd
src/pybind/rgw/mock_rgw.pxi
src/pybind/rgw/rgw.pyx

index 36f5aad7d0a6f69d94c008519039e843bf014eb6..d040df6782e85d2556aae8cc636d8c06e40d740f 100644 (file)
@@ -441,7 +441,7 @@ cdef nogil:
         pass
     void rados_read_op_set_flags(rados_read_op_t read_op, int flags):
         pass
-    int rados_omap_get_next(rados_omap_iter_t iter, const char * const* key, const char * const* val, size_t * len):
+    int rados_omap_get_next(rados_omap_iter_t iter, char ** key, char ** val, size_t * len):
         pass
     void rados_omap_get_end(rados_omap_iter_t iter):
         pass
index 988b67b0ef912d2a5502b4932bb8e630416b202d..4654460ed6495071c694bee8411a6d53a0ffbf51 100644 (file)
@@ -102,7 +102,7 @@ cdef extern from "rados/rgw_file.h" nogil:
 
     int rgw_readdir(rgw_fs *fs,
                     rgw_file_handle *parent_fh, uint64_t *offset,
-                    bool (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
+                    int (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
                     void *cb_arg, bool *eof, uint32_t flags) except? -9000
 
     int rgw_getattr(rgw_fs *fs,
index 806d4df75de05c42b3eacf0dc304faf3d535235e..d19ce777875e3082f472396833dec1b9cefa7dd6 100644 (file)
@@ -116,7 +116,7 @@ cdef nogil:
 
     int rgw_readdir(rgw_fs *fs,
                     rgw_file_handle *parent_fh, uint64_t *offset,
-                    libcpp.bool (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
+                    int (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
                     void *cb_arg, libcpp.bool *eof, uint32_t flags) except? -9000:
         pass
 
index d210a70bbb8e3c9f58b7909b619a4adf243d71c6..6da956e2d96f9b5ac75d448eec34bb9921dd58ea 100644 (file)
@@ -166,12 +166,12 @@ cdef make_ex(ret, msg):
         return Error(msg + (": error code %d" % ret))
 
 
-cdef bint readdir_cb(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) \
+cdef int readdir_cb(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) \
 except? -9000 with gil:
     if exc.PyErr_Occurred():
-        return False
+        return 0
     (<object>arg)(name, offset, flags)
-    return True
+    return 1
 
 
 class LibCephFSStateError(Error):