pcb

gts source do not compile when DEBUG symbol defined

Bug #1659045 reported by Chad Parker on 2017-01-24
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pcb
Medium
Unassigned

Bug Description

When building with the DEBUG symbol defined, the gts sources throw a warning and an error. See below.

-------------
   WARNING
-------------
gcc -DHAVE_CONFIG_H -I. -I.. -I. -DG_LOG_DOMAIN=\"Gts\" -I/opt/local/include -I/opt/local/include -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -D_REENTRANT -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/opt/local/include/pango-1.0 -I/opt/local/include/gio-unix-2.0/ -I/opt/local/include -I/opt/local/include/cairo -I/opt/local/include/atk-1.0 -I/opt/local/include/cairo -I/opt/local/include/pixman-1 -I/opt/local/include/libpng16 -I/opt/local/include -I/opt/local/include/gdk-pixbuf-2.0 -I/opt/local/include/libpng16 -I/opt/local/include/pango-1.0 -I/opt/local/include/harfbuzz -I/opt/local/include -I/opt/local/include/pango-1.0 -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include -I/opt/local/include/freetype2 -D_REENTRANT -I/opt/local/include/gtkglext-1.0 -I/opt/local/lib/gtkglext-1.0/include -I/opt/local/include -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/opt/local/include/pango-1.0 -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/opt/local/include/pango-1.0 -I/opt/local/include/gio-unix-2.0/ -I/opt/local/include -I/opt/local/include/cairo -I/opt/local/include/atk-1.0 -I/opt/local/include/cairo -I/opt/local/include/pixman-1 -I/opt/local/include/libpng16 -I/opt/local/include -I/opt/local/include/gdk-pixbuf-2.0 -I/opt/local/include/libpng16 -I/opt/local/include/pango-1.0 -I/opt/local/include/harfbuzz -I/opt/local/include -I/opt/local/include/pango-1.0 -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include -I/opt/local/include/freetype2 -D_THREAD_SAFE -D_THREAD_SAFE -DPREFIXDIR=\"/usr/local\" -DBINDIR=\"/usr/local/bin\" -DHOST=\"x86_64-apple-darwin15.6.0\" -DPCBLIBDIR=\"/usr/local/share/pcb\" -DPCBTREEDIR=\"/usr/local/share/pcb/newlib\" -DPCBTREEPATH=\"/usr/local/share/pcb/newlib:/usr/local/share/pcb/pcblib-newlib\" -pipe -arch x86_64 -ggdb -DDEBUG -Wall -Wdeclaration-after-statement -MT split.o -MD -MP -MF .deps/split.Tpo -c -o split.o split.c
split.c: In function 'gts_split_collapse':
split.c:609:5: warning: implicit declaration of function 'gts_write_segment' [-Wimplicit-function-declaration]
     gts_write_segment (GTS_SEGMENT (e), GTS_POINT (v), fptr);
     ^~~~~~~~~~~~~~~~~
split.c:614:7: warning: implicit declaration of function 'gts_write_triangle' [-Wimplicit-function-declaration]
       gts_write_triangle (i->data, GTS_POINT (v), fptr);
       ^~~~~~~~~~~~~~~~~~
split.c:651:14: warning: implicit declaration of function 'id' [-Wimplicit-function-declaration]
       cf->f, id (cf->f), CFACE (cf->f)->t, id (CFACE (cf->f)->t));
              ^~
split.c:726:18: warning: variable 'surface' set but not used [-Wunused-but-set-variable]
     GtsSurface * surface = NULL;
                  ^~~~~~~
At top level:
split.c:537:13: warning: 'print_split' defined but not used [-Wunused-function]
 static void print_split (GtsSplit * vs, FILE * fptr)

-------------
    ERROR
-------------

gcc -DHAVE_CONFIG_H -I. -I.. -I. -DG_LOG_DOMAIN=\"Gts\" -I/opt/local/include -I/opt/local/include -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -D_REENTRANT -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/opt/local/include/pango-1.0 -I/opt/local/include/gio-unix-2.0/ -I/opt/local/include -I/opt/local/include/cairo -I/opt/local/include/atk-1.0 -I/opt/local/include/cairo -I/opt/local/include/pixman-1 -I/opt/local/include/libpng16 -I/opt/local/include -I/opt/local/include/gdk-pixbuf-2.0 -I/opt/local/include/libpng16 -I/opt/local/include/pango-1.0 -I/opt/local/include/harfbuzz -I/opt/local/include -I/opt/local/include/pango-1.0 -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include -I/opt/local/include/freetype2 -D_REENTRANT -I/opt/local/include/gtkglext-1.0 -I/opt/local/lib/gtkglext-1.0/include -I/opt/local/include -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/opt/local/include/pango-1.0 -I/opt/local/include/gtk-2.0 -I/opt/local/lib/gtk-2.0/include -I/opt/local/include/pango-1.0 -I/opt/local/include/gio-unix-2.0/ -I/opt/local/include -I/opt/local/include/cairo -I/opt/local/include/atk-1.0 -I/opt/local/include/cairo -I/opt/local/include/pixman-1 -I/opt/local/include/libpng16 -I/opt/local/include -I/opt/local/include/gdk-pixbuf-2.0 -I/opt/local/include/libpng16 -I/opt/local/include/pango-1.0 -I/opt/local/include/harfbuzz -I/opt/local/include -I/opt/local/include/pango-1.0 -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include -I/opt/local/include -I/opt/local/include/freetype2 -I/opt/local/include -I/opt/local/include/freetype2 -D_THREAD_SAFE -D_THREAD_SAFE -DPREFIXDIR=\"/usr/local\" -DBINDIR=\"/usr/local/bin\" -DHOST=\"x86_64-apple-darwin15.6.0\" -DPCBLIBDIR=\"/usr/local/share/pcb\" -DPCBTREEDIR=\"/usr/local/share/pcb/newlib\" -DPCBTREEPATH=\"/usr/local/share/pcb/newlib:/usr/local/share/pcb/pcblib-newlib\" -pipe -arch x86_64 -ggdb -DDEBUG -Wall -Wdeclaration-after-statement -MT boolean.o -MD -MP -MF .deps/boolean.Tpo -c -o boolean.o boolean.c
boolean.c: In function 'write_surface_graph':
boolean.c:140:15: error: invalid storage class for function 'add_to_list'
   static void add_to_list (gpointer data, GSList ** l) {
               ^~~~~~~~~~~
boolean.c: In function 'triangulate_loop':
boolean.c:1386:2: warning: implicit declaration of function 'gts_write_triangle' [-Wimplicit-function-declaration]
  gts_write_triangle (GTS_TRIANGLE (f), NULL, fp);
  ^~~~~~~~~~~~~~~~~~
At top level:
boolean.c:628:13: warning: 'write_graph1' defined but not used [-Wunused-function]
 static void write_graph1 (GtsSegment * start, GSList * i,
             ^~~~~~~~~~~~
boolean.c:561:13: warning: 'print_segment' defined but not used [-Wunused-function]
 static void print_segment (GtsSegment * s)
             ^~~~~~~~~~~~~
boolean.c:136:13: warning: 'write_surface_graph' defined but not used [-Wunused-function]
 static void write_surface_graph (GtsSurface * s, FILE * fp)
             ^~~~~~~~~~~~~~~~~~~
make[2]: *** [boolean.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Chad Parker (parker-charles) wrote :

I push a partial fix for this to home/cparker/LP1659045

There are still some compile warnings that I'm not sure what to do with. It looks like there are several functions that were written for debugging but aren't used any longer. If we leave them there then we get the warnings. But they could come in handy some day, so I don't know if we want to delete them.

split.c: In function 'gts_split_collapse':
split.c:735:18: warning: variable 'surface' set but not used [-Wunused-but-set-variable]
     GtsSurface * surface = NULL;
                  ^~~~~~~
At top level:
split.c:546:13: warning: 'print_split' defined but not used [-Wunused-function]
 static void print_split (GtsSplit * vs, FILE * fptr)
             ^~~~~~~~~~~

boolean.c:635:13: warning: 'write_graph1' defined but not used [-Wunused-function]
 static void write_graph1 (GtsSegment * start, GSList * i,
             ^~~~~~~~~~~~
boolean.c:568:13: warning: 'print_segment' defined but not used [-Wunused-function]
 static void print_segment (GtsSegment * s)
             ^~~~~~~~~~~~~
boolean.c:146:13: warning: 'write_surface_graph' defined but not used [-Wunused-function]
 static void write_surface_graph (GtsSurface * s, FILE * fp)
             ^~~~~~~~~~~~~~~~~~~

On Tue, Jan 24, 2017 at 05:36:08PM -0000, Chad Parker wrote:
> I push a partial fix for this to home/cparker/LP1659045
>
> There are still some compile warnings that I'm not sure what to do with.
> It looks like there are several functions that were written for
> debugging but aren't used any longer. If we leave them there then we get
> the warnings. But they could come in handy some day, so I don't know if
> we want to delete them.
>
> split.c: In function 'gts_split_collapse':
> split.c:735:18: warning: variable 'surface' set but not used [-Wunused-but-set-variable]
> GtsSurface * surface = NULL;
> ^~~~~~~
> At top level:
> split.c:546:13: warning: 'print_split' defined but not used [-Wunused-function]
> static void print_split (GtsSplit * vs, FILE * fptr)
> ^~~~~~~~~~~
>
> boolean.c:635:13: warning: 'write_graph1' defined but not used [-Wunused-function]
> static void write_graph1 (GtsSegment * start, GSList * i,
> ^~~~~~~~~~~~
> boolean.c:568:13: warning: 'print_segment' defined but not used [-Wunused-function]
> static void print_segment (GtsSegment * s)
> ^~~~~~~~~~~~~
> boolean.c:146:13: warning: 'write_surface_graph' defined but not used [-Wunused-function]
> static void write_surface_graph (GtsSurface * s, FILE * fp)
> ^~~~~~~~~~~~~~~~~~~
>

According to the KISS principle I usually just delete those unused
artifacts of previously written and removed stuff. If you think
they're useful for debugging, you could use something like the
following construct to preserve them:

#if DEBUG
  print_segment (s);
#endif

--
  Vladimir

Chad Parker (parker-charles) wrote :

That construct was already being used. The problem was that none of the code that was wrapped in the DEBUG conditionals was actually using the functions or variables either.

I've pushed a new commit that removes them entirely. They wont actually be lost. If someone wants them back later, they can always go back in the repository and pull them out of the archive.

home/cparker/LP1659045

Changed in pcb:
status: New → In Progress
Bert Timmerman (bert-timmerman) wrote :

Hi Chad,

Pushed 2 commits to master.

Kind regards,

Bert Timmerman.

Changed in pcb:
milestone: none → pcb-4.0.1
status: In Progress → Fix Committed
importance: Undecided → Medium
Changed in pcb:
milestone: pcb-4.0.1 → pcb-4.1.0
Changed in pcb:
milestone: pcb-4.1.0 → pcb-4.0.1
Changed in pcb:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers