Menu

fig2dev Merge Request #1: Specify argument types in function prototypes (merged)

Merging...

Merged

Something went wrong. Please, merge manually

Checking if merge is possible...

Something went wrong. Please, merge manually

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 Mario Haustein Mario Haustein

Specify argument types in function prototypes

Modern C standards require full prototypes. This commit fixes the bug
reported in https://bugs.gentoo.org/944153.

2025-01-30 21:36:48 Tree

Discussion

  • tkl

    tkl - 2025-01-31

    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?

     
    • Mario Haustein

      Mario Haustein - 2025-01-31

      Good to know; In the development version, especially in xfig, there are
      plenty of incomplete prototypes. Until now, gcc and clang only warn.

      I am already working on this issue and was naive enough to think it is just a quick fix, ...

      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);

      ... 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 ;)

      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?

      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.

       
  • tkl

    tkl - 2025-01-31
    • Status: open --> merged
     
  • tkl

    tkl - 2025-01-31

    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,

    I believe, on lines 80 and 81 in fi2dev/dev/genlatex.c, a dot (.) should be added to the definitions of THICK_LDOT and THIN_LDOT: "\small." and "\tiny." instead of "\small" and "\tiny" .

    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.

     
    • Mario Haustein

      Mario Haustein - 2025-02-02

      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.

       
  • tkl

    tkl - 2025-02-03

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.