Mario Haustein wants to merge 1 commit from /u/hamarituc/fig2dev/ to master, 2025-02-03
Modern C standards require full prototypes. This commit fixes the bug reported in https://bugs.gentoo.org/944153.
Commit | Date | |
---|---|---|
[ab4eee]
(prototypes)
by
![]() Specify argument types in function prototypes Modern C standards require full prototypes. This commit fixes the bug |
2025-01-30 21:36:48 | Tree |
Good to know; In the development version, especially in xfig, there are plenty of incomplete prototypes. Until now, gcc and clang only warn.
A question, with respect to warnings: Especially in xfig, functions types are often cast to different types, from something. e.g., XtCallbackProc (*)(Widget w, XtPointer client_data, XtPointer call_data) to XtEventHandler (*)(Widget w, XtPointer client_data, XEvent *event, Boolean *continue_to_dispatch) or XtActionProc (*))(Widget w, XEvent *event, String *params, Cardinal *num_params);
To remove these warnings, one has to write quite a lot of wrappers with the correct function signature or cast from (*)(void). However, sometimes the first argument is used, then one would have to do a double cast or use wrappers. Do you have an opinion on how to deal with function cast warnings?
I am already working on this issue and was naive enough to think it is just a quick fix, ...
... but it turned out to be more work as expected. But I will keeping working on it. After using XFig for 19 years it's time to give something back to the code base ;)
Until now I just identified the keyboard and mouse callbacks. Some actions don't require mouse coordinate, some coordinate, but not the state of the shift key and so on.
The current approach of using incomplete prototypes and just passing the required number of argument should be considered harmful as it bypasses all compile type checks. Currently I am focusing on unifying the callback functions to an unique signature and mark unused parameters as such. But it's still more work to do and it requires thorough testing.
Thank you for contributing to xfig / fig2dev. However, take care. On March 20, 2012 I wrote an e-mail to the former maintainer of xfig,
Such humble beginnings. On Dez. 4th, 2014 Brian Smith passed over maintainance of xfig and fig2dev to me.
Sorry, no intention to threat anyone. How far did you proceed? I should add that I also had done some work on function casts, yet unpublished. Unpublished, because it clutters development history, and I wanted to insert such stuff at the end of a release cycle. If you did not yet advance too far, I should bring that code into a decent shape and publish it as a separate branch. Otherwise, I am happy to merge your work.
I pushed my current work under
https://sourceforge.net/u/hamarituc/xfig/ci/prototypes/tree/
It is the result of careful manual code transformations which should not change the runtime-behavior, but fixes compiler warnings related to function prototypes and unused parameters. As the changes are relatively extensive, careful testing should be carried out before merging.
Thank you, very nicely and carefully done. Until now I only had a quick look and noticed that you cared for the shift state, which previously was stored into a global(!) variable. At least canvas_selected() still depends on it, not sure about other functions.
I will test xfig as systematically as possible and will then merge your branch.