bpo-33012: Add _Py_CAST_FUNC() to cast function ptr#10744
bpo-33012: Add _Py_CAST_FUNC() to cast function ptr#10744vstinner wants to merge 1 commit intopython:masterfrom vstinner:cast_func
Conversation
Use _Py_CAST_FUNC() to cast functions pointers to getter, setter,
destructor, etc.
Change mostly written in gvim using the command:
:%s!(\(inquiry\|destructor\|reprfunc\|getter\|setter
\|releasebufferproc\|getbufferproc\))
\([A-Za-z0-9_]\+\)
!_Py_CAST_FUNC(\1, \2)!g
|
The problem is not in warnings, but in incorrect function signatures. This PR just silences valid compiler warnings. See #10746. |
What do you mean by "incorrect function signature"? Example: Here the warning is that PyGetSetDef expects PyObject* as the first argument of the getter, whereas method_getset uses PyMethodDescrObject*. Is it an invalid signature? Would you prefer to write: which is the "correct" signature? The additional "PyMethodDescrObject *descr = (PyMethodDescrObject *)descr_obj;" doesn't seem to provide any value to the compiler nor to the developer who read/maintain the code.
Right, that's a good fix, but I was too lazy to check each function pointer. |
|
I did not get a warning for |
|
@serhiy-storchaka: Oh wow, I don't understand how it's possible, but almost all GCC warnings are gone. It seems like I didn't try on your latest compiler warning fix. So this PR is completely useless! |
Use _Py_CAST_FUNC() to cast functions pointers to getter, setter,
destructor, etc.
Change mostly written in gvim using the command:
https://bugs.python.org/issue33012