Menu

#762 GTK3V2MAIN: clean up a few compiler warnings

Next Release
closed-fixed
nobody
None
V5.3.1GA
Linux
5
5 days ago
2026-08-31
No

A few compiler warnings showed up doing a clean build of branch GTK3V2MAIN (changeset: 7093:63c3c83c41c1, Aug 31 09:27:28 2026). None of these appear to be real bugs, just noise. I believe the attached patch resolves all of them.

[  1%] Building C object app/wlib/gtk3lib/wrapbox/CMakeFiles/wrapbox.dir/eggwrapbox.c.o
app/wlib/gtk3lib/wrapbox/eggwrapbox.c: In function egg_wrap_box_size_allocate:
app/wlib/gtk3lib/wrapbox/eggwrapbox.c:1353:49: warning: comparison of integer expressions of different signedness: gint {aka int} and guint {aka unsigned int} [-Wsign-compare]
 1353 |                 for (line_count = 0; line_count < array->len; line_count++) {
      |                                                 ^
app/wlib/gtk3lib/wrapbox/eggwrapbox.c:1379:39: warning: comparison of integer expressions of different signedness: gint {aka int} and guint {aka unsigned int} [-Wsign-compare]
 1379 |                         for (i = 0; i < line_array->len; i++) {
      |                                       ^
app/wlib/gtk3lib/wrapbox/eggwrapbox.c: In function egg_wrap_box_reorder_child:
app/wlib/gtk3lib/wrapbox/eggwrapbox.c:2619:52: warning: comparison of integer expressions of different signedness: gint {aka int} and guint {aka unsigned int} [-Wsign-compare]
 2619 |         if (g_list_position (priv->children, list) != index) {
      |                                                    ^~
...
[ 79%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/cselect.c.o
app/bin/cselect.c: In function CmdRotate:
app/bin/cselect.c:2074:31: warning: unused variable pos1 [-Wunused-variable]
 2074 |                         coOrd pos1 = pos;
      |                               ^~~~
...
[ 81%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/cturnout.c.o
app/bin/cturnout.c: In function CreateNewTurnout:
app/bin/cturnout.c:170:37: warning: passing argument 2 of FormatCompoundTitle discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
  170 |                                     title);
      |                                     ^~~~~
In file included from app/bin/cturnout.c:28:
app/bin/compound.h:133:33: note: expected char * but argument is of type const char *
  133 | void FormatCompoundTitle( long, char *);
      |                                 ^~~~~~
...
[ 82%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/cars/carcommit.c.o
app/bin/cars/carcommit.c: In function CommitStaged:
app/bin/cars/carcommit.c:150:63: warning: passing argument 7 of CarPartNew discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
  150 |                                    plan->options, plan->type, &plan->dim, plan->color );
      |                                                               ^~~~~~~~~~
In file included from app/bin/cars/carcommit.c:40:
app/bin/cars/carsprivate.h:144:75: note: expected carDim_p {aka struct carDim_s * const} but argument is of type const carDim_t * {aka const struct carDim_s *}
  144 |                      char *title, long options, long type, const carDim_p dim, wDrawColor color);
      |                                                            ~~~~~~~~~~~~~~~^~~
...
[ 83%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/cars/careditdlg.c.o
app/bin/cars/careditdlg.c: In function CarDlgUpdate:
app/bin/cars/careditdlg.c:2282:56: warning: passing argument 3 of FormLoadMessage discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
 2282 |                         FormLoadMessage( pg, I_CD_MSG, CarDlgCommitSummary() );
      |                                                        ^~~~~~~~~~~~~~~~~~~~~
In file included from app/bin/cars/careditdlg.c:34:
app/bin/include/form.h:27:54: note: expected char * but argument is of type const char *
   27 | void FormLoadMessage(paramGroup_p pg, int inx, char* message);
      |                                                ~~~~~~^~~~~~~
app/bin/cars/careditdlg.c: At top level:
app/bin/cars/careditdlg.c:187:14: warning: multinumLabels defined but not used [-Wunused-variable]
  187 | static char *multinumLabels[] = { N_("Sequential"), N_("Repeated"), NULL };
      |              ^~~~~~~~~~~~~~
...
[ 89%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/macro.c.o
app/bin/macro.c: In function ParamPlayback:
app/bin/macro.c:2010:25: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
 2010 |                         switch (p->type) {
      |                         ^~~~~~
app/bin/macro.c: In function ParamCheck:
app/bin/macro.c:2285:17: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
 2285 |                 switch (p->type) {
      |                 ^~~~~~
...
[ 94%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/form/checkinputs.c.o
app/bin/form/checkinputs.c: In function FormUpdate:
app/bin/form/checkinputs.c:369:17: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
  369 |                 switch (p->type) {
      |                 ^~~~~~
...
[ 94%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/form/defaultvalues.c.o
app/bin/form/defaultvalues.c: In function FormLoadDefaultValues:
app/bin/form/defaultvalues.c:160:25: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
  160 |                         switch (p->type) {
      |                         ^~~~~~
app/bin/form/defaultvalues.c: In function FormSaveDefaultValues:
app/bin/form/defaultvalues.c:240:17: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
  240 |                 switch (p->type) {
      |                 ^~~~~~
app/bin/form/defaultvalues.c: In function FormUpdatePrefs:
app/bin/form/defaultvalues.c:310:25: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
  310 |                         switch ( p->type ) {
      |                         ^~~~~~
...
[ 94%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/form/fetchdata.c.o
app/bin/form/fetchdata.c: In function FormFetchData:
app/bin/form/fetchdata.c:64:17: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
   64 |                 switch (p->type) {
      |                 ^~~~~~
app/bin/form/fetchdata.c: In function FormIntRestore:
app/bin/form/fetchdata.c:165:17: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
  165 |                 switch (p->type) {
      |                 ^~~~~~
app/bin/form/fetchdata.c: In function FormIntSave:
app/bin/form/fetchdata.c:272:25: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
  272 |                         switch (p->type) {
      |                         ^~~~~~
...
[ 95%] Building C object app/bin/CMakeFiles/xtrkcad-lib.dir/form/loadcontrols.c.o
app/bin/form/loadcontrols.c: In function FormLoadSingleControl:
app/bin/form/loadcontrols.c:71:9: warning: enumeration value PD_EXPANDER not handled in switch [-Wswitch]
   71 |         switch (p->type) {
      |         ^~~~~~
...
[ 96%] Building C object app/wlib/gtk3lib/wrapbox/CMakeFiles/testwrapbox.dir/testwrapbox.c.o
app/wlib/gtk3lib/wrapbox/testwrapbox.c: In function populate_wrapbox_wrappy:
app/wlib/gtk3lib/wrapbox/testwrapbox.c:88:23: warning: comparison of integer expressions of different signedness: gint {aka int} and long unsigned int [-Wsign-compare]
   88 |         for (i = 0; i < G_N_ELEMENTS (strings); i++) {
      |                       ^
1 Attachments

Discussion

  • John R. Jackson

    John R. Jackson - 2026-09-01
    • Operating System: Windows --> Linux
     
  • Allen D Byrne

    Allen D Byrne - 2026-09-01

    Thanks for the patch -- this is genuinely useful: the app/bin portion completely clears out every currently-tracked compiler-warnings category in our CI report (all 10 -Wswitch, all 3 -Wdiscarded-qualifiers, and both -Wunused-variable findings), and the wrapbox portion clears -Wsign-compare too. Worth landing.

    A couple of small tweaks would make it a bit cleaner before merging:

    • careditdlg.c and cturnout.c: use the existing CAST_AWAY_CONST macro (common.h) instead of a bare (char *) cast, for consistency with how this is already done elsewhere in the codebase.
    • carcommit.c: the cast can just be (carDim_p) -- carDim_p is already a const pointer type, so the extra const is redundant.
    • cselect.c and careditdlg.c: pos1 and multinumLabels are both fully unused, so it'd be cleaner to just delete those two lines rather than comment them out.

    None of these are blockers -- happy to fold them into my fork when this lands.

     

    Last edit: Allen D Byrne 2026-09-01
  • John R. Jackson

    John R. Jackson - 2026-09-01

    Thanks for the suggested changes. The attached "v02" version of the patch incorporates all of them with the exception of commenting out the pos1 variable in cselect.c. I left that change because pos1 is used 33 lines after the declaration in some other code that's already commented out. Not sure why that (commented out) code is there there, but if anyone ever re-enables it they are going to need the pos1 variable, so it can also just be re-enabled.

     
  • Allen D Byrne

    Allen D Byrne - 2026-09-02

    First, anything deleted can always be revived from repo history and nothing is truly lost.
    Second leaving commented code in place just causes future issues if whoever commented out never maintains it as active development.
    One thing you could do is maybe move the declaration into the comments or just comment the declaration in place.

     
  • John R. Jackson

    John R. Jackson - 2026-09-03

    The scope of this report is cleaning up compilation issues, not cleaning up commented out code.

    One thing you could do is .. just comment the declaration in place.

    That's what I did do. I stuck "//" in front of the "pos1" declaraction so the unused variable compiler warning would go away.

    I've attached a "v03" version of the patch which moves the "pos1" declaraction near the commented out code and also comments out the declaration (ala "v02"). Take your pick between "v02" or "v03" (or apply the patch then fix "pos1" and the commented out code however you want). The goal is to make the compiler stop whining, and any of these will get the job done.

     
  • Allen D Byrne

    Allen D Byrne - 2026-09-05

    That's fine, just adding the comment eliminates the QA warning yet doesn't make a determination on the code - is acceptable practice as far as I'm concerned. Please merge it in.

    As far as commented code is concerned it is the bane of any long term project. Eventually the reason is forgotten. A separate issue.

    Allen

     
  • Martin Fischer

    Martin Fischer - 5 days ago
    • status: open --> closed-fixed
     

Anonymous
Anonymous

Add attachments
Cancel