Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-111178: Avoid calling functions from incompatible pointer types in _tkinter.c #112893

Merged
merged 6 commits into from
Jan 2, 2024

Conversation

chrstphrchvz
Copy link
Contributor

@chrstphrchvz chrstphrchvz commented Dec 9, 2023

Potential compiler warnings eliminated:

./Modules/_tkinter.c:819:18: warning: cast from 'PyObject *(*)(PyTclObject *, void *)' (aka 'struct _object *(*)(PyTclObject *, void *)') to 'getter' (aka 'struct _object *(*)(struct _object *, void *)') converts to incompatible function type [-Wcast-function-type-strict]
  819 |     {"typename", (getter)get_typename, NULL, get_typename__doc__},
      |                  ^~~~~~~~~~~~~~~~~~~~
./Modules/_tkinter.c:820:16: warning: cast from 'PyObject *(*)(PyTclObject *, void *)' (aka 'struct _object *(*)(PyTclObject *, void *)') to 'getter' (aka 'struct _object *(*)(struct _object *, void *)') converts to incompatible function type [-Wcast-function-type-strict]
  820 |     {"string", (getter)PyTclObject_string, NULL,
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_tkinter.c:826:21: warning: cast from 'void (*)(PyTclObject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
  826 |     {Py_tp_dealloc, (destructor)PyTclObject_dealloc},
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_tkinter.c:827:18: warning: cast from 'PyObject *(*)(PyTclObject *)' (aka 'struct _object *(*)(PyTclObject *)') to 'reprfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
  827 |     {Py_tp_repr, (reprfunc)PyTclObject_repr},
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_tkinter.c:828:17: warning: cast from 'PyObject *(*)(PyTclObject *)' (aka 'struct _object *(*)(PyTclObject *)') to 'reprfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict]
  828 |     {Py_tp_str, (reprfunc)PyTclObject_str},
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_tkinter.c:1388:23: warning: cast from 'int (*)(Tkapp_CallEvent *, int)' (aka 'int (*)(struct Tkapp_CallEvent *, int)') to 'Tcl_EventProc *' (aka 'int (*)(struct Tcl_Event *, int)') converts to incompatible function type [-Wcast-function-type-strict]
 1388 |         ev->ev.proc = (Tcl_EventProc*)Tkapp_CallProc;
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_tkinter.c:1666:23: warning: cast from 'int (*)(VarEvent *, int)' (aka 'int (*)(struct VarEvent *, int)') to 'Tcl_EventProc *' (aka 'int (*)(struct Tcl_Event *, int)') converts to incompatible function type [-Wcast-function-type-strict]
 1666 |         ev->ev.proc = (Tcl_EventProc*)var_proc;
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_tkinter.c:2293:23: warning: cast from 'int (*)(CommandEvent *, int)' (aka 'int (*)(struct CommandEvent *, int)') to 'Tcl_EventProc *' (aka 'int (*)(struct Tcl_Event *, int)') converts to incompatible function type [-Wcast-function-type-strict]
 2293 |         ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_tkinter.c:2346:23: warning: cast from 'int (*)(CommandEvent *, int)' (aka 'int (*)(struct CommandEvent *, int)') to 'Tcl_EventProc *' (aka 'int (*)(struct Tcl_Event *, int)') converts to incompatible function type [-Wcast-function-type-strict]
 2346 |         ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@encukou encukou merged commit f637b44 into python:main Jan 2, 2024
34 checks passed
@chrstphrchvz chrstphrchvz deleted the patch-111178-tkinter branch January 2, 2024 23:32
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
…pes in _tkinter.c (pythonGH-112893)

Fix undefined behavior warnings (UBSan  -fsanitize=function).
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…pes in _tkinter.c (pythonGH-112893)

Fix undefined behavior warnings (UBSan  -fsanitize=function).
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…pes in _tkinter.c (pythonGH-112893)

Fix undefined behavior warnings (UBSan  -fsanitize=function).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants