Skip to content

Commit 8a44e8d

Browse files
committed
daemon: silence warning about casts for kwargs functions
[6/18] Compiling C object src/systemd/_daemon.cpython-313-x86_64-linux-gnu.so.p/_daemon.c.o ../src/systemd/_daemon.c:415:37: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type] 415 | { "notify", (PyCFunction) notify, METH_VARARGS | METH_KEYWORDS, notify__doc__ }, | ^ ../src/systemd/_daemon.c:416:37: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type] 416 | { "_listen_fds", (PyCFunction) listen_fds, METH_VARARGS | METH_KEYWORDS, listen_fds__doc__ }, | ^ ../src/systemd/_daemon.c:417:37: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type] 417 | { "_listen_fds_with_names", (PyCFunction) listen_fds_with_names, | ^ This is a problem in the Python C API… They should have used a union type.
1 parent 031dec9 commit 8a44e8d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/systemd/_daemon.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ static PyObject* is_socket_unix(PyObject *self _unused_, PyObject *args) {
410410
}
411411

412412

413+
DISABLE_WARNING_CAST_FUNCTION_TYPE;
413414
static PyMethodDef methods[] = {
414415
{ "booted", booted, METH_NOARGS, booted__doc__ },
415416
{ "notify", (PyCFunction) notify, METH_VARARGS | METH_KEYWORDS, notify__doc__ },
@@ -424,6 +425,7 @@ static PyMethodDef methods[] = {
424425
{ "_is_socket_unix", is_socket_unix, METH_VARARGS, is_socket_unix__doc__ },
425426
{} /* Sentinel */
426427
};
428+
REENABLE_WARNING;
427429

428430
static struct PyModuleDef module = {
429431
PyModuleDef_HEAD_INIT,

src/systemd/macro.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
_Pragma("GCC diagnostic push"); \
77
_Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"")
88

9+
#define DISABLE_WARNING_CAST_FUNCTION_TYPE \
10+
_Pragma("GCC diagnostic push"); \
11+
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
12+
913
#define REENABLE_WARNING \
1014
_Pragma("GCC diagnostic pop")
1115

0 commit comments

Comments
 (0)