Merge lp:~mxsscott/widelands/warnings into lp:widelands

Proposed by Mark Scott
Status: Merged
Merged at revision: 6482
Proposed branch: lp:~mxsscott/widelands/warnings
Merge into: lp:widelands
Diff against target: 739 lines (+145/-96)
23 files modified
src/compile_diagnostics.h (+41/-0)
src/editor/editorinteractive.cc (+1/-3)
src/graphic/graphic.cc (+19/-28)
src/graphic/graphic.h (+6/-6)
src/graphic/render/gl_surface.cc (+0/-2)
src/graphic/render/sdl_surface.cc (+12/-3)
src/graphic/text/rt_render.cc (+11/-6)
src/graphic/text/sdl_ttf_font_impl.cc (+2/-2)
src/io/filesystem/disk_filesystem.cc (+7/-10)
src/logic/editor_game_base.cc (+1/-1)
src/minizip/unzip.cc (+4/-0)
src/network/internet_gaming.cc (+3/-0)
src/network/nethost.cc (+2/-0)
src/network/network_lan_promotion.cc (+14/-19)
src/s2map.cc (+10/-8)
src/scripting/pluto.cc (+5/-0)
src/ui_basic/listselect.cc (+0/-1)
src/ui_basic/panel.cc (+0/-2)
src/ui_fsmenu/base.cc (+0/-2)
src/ui_fsmenu/internet_lobby.cc (+3/-0)
src/ui_fsmenu/netsetup_lan.cc (+4/-0)
src/wui/waresdisplay.cc (+0/-2)
src/wui/waresqueuedisplay.cc (+0/-1)
To merge this branch: bzr merge lp:~mxsscott/widelands/warnings
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+142035@code.launchpad.net

Description of the change

Fix or suppress GCC warnings visible when compiling with GCC 4.7.2

Specifically:
 * compile_diagnostics.h: Introduce macros GCC_DIAG_OFF and GCC_DIAG_ON that disable and then restore reporting of warnings and errors. Used to disable a certain warning for a specific line of code on GCC 4.6+, and to silence warnings in Pluto and Minizip.

 * gl_surface.cc: Asserts that will never be false because variable is unsigned.
 * panel.cc: Always-true asserts due to unsigned type.

 * editorinteractive.cc: Unused variable
 * listselect.cc: Unused variable
 * waresdisplay.cc: Unused variable
 * waresqueuedisplay.cc: Unused variable
 * graphic.cc: Unused variable and parameter and code that would never be executed.
 * graphic.h: Unused parameter. Reorder members to match constructor initialization list
 * ui_fsmenu/base.cc: Unused variable. pull_section() does have side effects, but in this case it is irrelevant as gr_x() and gr_y() in the initializer list will have the same impact. Suspect this existed before gr_x() and gr_y() were put into the initializer.

 * sdl_surface.cc: cast struct initializers appropriately.
 * rt_render.cc: cast appropriately to avoid signed/unsigned comparison.
 * Question existence / correctness of method - seems to be very similar to Rect::contains() but very slightly different in handling of bottom & right edge.
 * Comment out render() parameter name (unused parameter).
 * Provide initialisation of all struct members.

 * sdl_ttf_font_impl.cc: Change type of variable to avoid signed/unsigned comparison.

 * disk_filesystem.cc: Be specific about the lines to ignore warnings on.

 * scripting/pluto.cc: Suppress warnings about unused-variables (at top of file)

 * minizip/unzip.cc: Suppress warnings about old-style-cast (above the non-modification notice)
 * internet_gaming.cc: Suppress warning about old-style-cast
 * internet_lobby.cc: Suppress warning about old-style-cast
 * network_lan_promotion.cc: Suppress warning about old-style-cast
 * netsetup_lan.cc: Suppress warning about old-style-cast

 * nethost.cc: Add deletion of 'tips' variable, which (a) fixes a memory leak and (b) silences a warning about an unused variable (it isn't really unused, since it registers itself with the loaderUI in its constructor)

 * s2map.cc: Use of setiosflags() instead of hex() and dec() silences the sign promotion warnings

To post a comment you must log in.
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Nice to see someone tackling the remaining warnings. :)

I leave reviewing the code to someone better suited for the task, but here's a few comments:

Could you elaborate a bit more on the warnings which are silenced? For minizip and similar I fully understand since we don't want to diverge from upstream (and ideally shouldn't need to include them), however I wonder about the rest.

Regarding the silencing macro, it seems nice and straight-forward to use. However, the original (http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html) doesn't seem to mention a license nor terms of use for it. Any thoughts on this? At any rate I assume it would be considered a derivate work of the original, which could cause all sorts of problems. Maybe I'm overreacting a bit, but I would like to see that clarified a bit more.

Revision history for this message
SirVer (sirver) wrote :

I only reviewed the code from the technical point of view and from there it looks fine. I am also not concerned about the individual disabling of the warnings in the code - it was all clear to me when I reviewed it.

About the copyright issue - the text seems to have been written/dublicated into the boost wiki as a coding reference for the boost libraries [1]. I therefore feel they are basically part of the c++ folklore and therefore free to use - and we give credit in the code. I am not a lawyer, but as long as no one complains, I think we are golden.

https://svn.boost.org/trac/boost/wiki/Guidelines/WarningsGuidelines

Revision history for this message
Mark Scott (mxsscott) wrote :

In terms of warnings silenced rather than fixed through code change, this was only done where no code change was desirable (the minizip and lua code), or possible (macros from headers outside of Widelands, e.g. GLEW_VERSION_1_4, htons(), ioctl-related constants).

All other warnings were fixed through code change.

Here is a thread from the original author, Jonathan Wakely, who is referenced on the Boost page and on the page I referenced in code:

http://gcc.gnu.org/ml/gcc-help/2011-01/msg00135.html

    > Also, can I steal, with attribution of course, GCC_DIAG_OFF/ON(x)?
    Certainly.

The main difference between that GCC_DIAG_OFF/ON and the one I committed was he has:
  GCC_DIAG_OFF(old-style-cast)

I have:
  GCC_DIAG_OFF("-Wold-style-cast")

Why? My version doesn't get complained at by the CodeCheck (it complained about lack of a space after an operator)

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Awesome.

> only done where no code change was desirable (..) or possible

Fair enough. I won't really expect anyone to track down and fix issues triggered by third party software.

>Here is a thread from the original author, Jonathan Wakely,

Nice. Based on the attribution link, it did seem like the goal was to share the macro with anyone interested, but it is nice to have it explicitly.

Thanks again for your work on the warnings.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'src/compile_diagnostics.h'
2--- src/compile_diagnostics.h 1970-01-01 00:00:00 +0000
3+++ src/compile_diagnostics.h 2013-01-06 13:38:25 +0000
4@@ -0,0 +1,41 @@
5+/*
6+ * Copyright (C) 2013 by the Widelands Development Team
7+ *
8+ * This program is free software; you can redistribute it and/or
9+ * modify it under the terms of the GNU General Public License
10+ * as published by the Free Software Foundation; either version 2
11+ * of the License, or (at your option) any later version.
12+ *
13+ * This program is distributed in the hope that it will be useful,
14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ * GNU General Public License for more details.
17+ *
18+ * You should have received a copy of the GNU General Public License
19+ * along with this program; if not, write to the Free Software
20+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21+ *
22+ */
23+#ifndef COMPILE_DIAGNOSTICS_H
24+#define COMPILE_DIAGNOSTICS_H
25+
26+/* Macros for disabling GCC warnings and errors
27+ * From http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html and
28+ * slightly modified to remove support entirely for GCC < 4.6 because we'll
29+ * use in the middle of functions.
30+ */
31+#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
32+# define GCC_DIAG_STR(s) #s
33+# define GCC_DIAG_JOINSTR(x, y) GCC_DIAG_STR(x ## y)
34+# define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
35+# define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
36+# define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
37+ GCC_DIAG_PRAGMA(ignored x)
38+# define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
39+#else
40+# define GCC_DIAG_OFF(x)
41+# define GCC_DIAG_ON(x)
42+#endif
43+
44+
45+#endif
46
47=== modified file 'src/editor/editorinteractive.cc'
48--- src/editor/editorinteractive.cc 2012-12-14 20:09:35 +0000
49+++ src/editor/editorinteractive.cc 2013-01-06 13:38:25 +0000
50@@ -128,10 +128,8 @@
51 if (Widelands::Coords const sp = map.get_starting_pos(p)) {
52 const IPicture* pic = g_gr->imgcache().load(PicMod_Game, fname);
53 assert(pic);
54- uint32_t w = pic->get_w();
55- uint32_t h = pic->get_h();
56 map.overlay_manager().register_overlay
57- (sp, pic, 8, Point(w / 2, STARTING_POS_HOTSPOT_Y));
58+ (sp, pic, 8, Point(pic->get_w() / 2, STARTING_POS_HOTSPOT_Y));
59 }
60 }
61
62
63=== modified file 'src/graphic/graphic.cc'
64--- src/graphic/graphic.cc 2012-12-16 17:06:00 +0000
65+++ src/graphic/graphic.cc 2013-01-06 13:38:25 +0000
66@@ -1,5 +1,5 @@
67 /*
68- * Copyright (C) 2002-2004, 2006-2012 by the Widelands Development Team
69+ * Copyright (C) 2002-2004, 2006-2013 by the Widelands Development Team
70 *
71 * This program is free software; you can redistribute it and/or
72 * modify it under the terms of the GNU General Public License
73@@ -17,6 +17,7 @@
74 *
75 */
76
77+#include "compile_diagnostics.h"
78 #include "graphic.h"
79
80 #include "build_info.h"
81@@ -242,7 +243,9 @@
82 log("Graphics: OpenGL: Multitexture capabilities ");
83 log(m_caps.gl.multitexture ? "sufficient\n" : "insufficient, only basic terrain rendering possible\n");
84
85+GCC_DIAG_OFF("-Wold-style-cast")
86 m_caps.gl.blendequation = GLEW_VERSION_1_4 || GLEW_ARB_imaging;
87+GCC_DIAG_ON ("-Wold-style-cast")
88 }
89 #endif
90
91@@ -466,7 +469,6 @@
92
93 // First step: compute scaling factors
94 Rect srcrect = Rect(Point(0, 0), src->get_w(), src->get_h());
95- Rect destrect = Rect(Point(0, 0), w, h);
96
97 // Second step: get source material
98 SDL_Surface * srcsdl = 0;
99@@ -483,7 +485,7 @@
100
101 // Third step: perform the zoom and placement
102 SDL_Surface * zoomed = zoomSurface
103- (srcsdl, double(destrect.w) / srcsdl->w, double(destrect.h) / srcsdl->h, 1);
104+ (srcsdl, double(w) / srcsdl->w, double(h) / srcsdl->h, 1);
105 if (free_source)
106 SDL_FreeSurface(srcsdl);
107
108@@ -492,39 +494,28 @@
109 SDL_Surface * placed = SDL_CreateRGBSurface
110 (SDL_SWSURFACE, w, h,
111 fmt.BitsPerPixel, fmt.Rmask, fmt.Gmask, fmt.Bmask, fmt.Amask);
112- SDL_Rect srcrc = {0, 0, zoomed->w, zoomed->h};
113- SDL_Rect dstrc = {destrect.x, destrect.y};
114+ SDL_Rect srcrc =
115+ {0, 0,
116+ static_cast<Uint16>(zoomed->w), static_cast<Uint16>(zoomed->h)
117+ }; // For some reason SDL_Surface and SDL_Rect express w,h in different types
118+ SDL_Rect dstrc = {0, 0, 0, 0};
119 SDL_SetAlpha(zoomed, 0, 0);
120- SDL_BlitSurface(zoomed, &srcrc, placed, &dstrc);
121+ SDL_BlitSurface(zoomed, &srcrc, placed, &dstrc); // Updates dstrc
122
123 Uint32 fillcolor = SDL_MapRGBA(zoomed->format, 0, 0, 0, 255);
124
125- if (destrect.x > 0) {
126- dstrc.x = 0;
127- dstrc.y = destrect.y;
128- dstrc.w = destrect.x;
129- dstrc.h = zoomed->h;
130- SDL_FillRect(placed, &dstrc, fillcolor);
131- }
132- if (destrect.x + zoomed->w < placed->w) {
133- dstrc.x = destrect.x + zoomed->w;
134- dstrc.y = destrect.y;
135- dstrc.w = placed->w - destrect.x - zoomed->w;
136- dstrc.h = zoomed->h;
137- SDL_FillRect(placed, &dstrc, fillcolor);
138- }
139- if (destrect.y > 0) {
140- dstrc.x = 0;
141+ if (zoomed->w < placed->w) {
142+ dstrc.x = zoomed->w;
143 dstrc.y = 0;
144- dstrc.w = placed->w;
145- dstrc.h = destrect.y;
146+ dstrc.w = placed->w - zoomed->w;
147+ dstrc.h = zoomed->h;
148 SDL_FillRect(placed, &dstrc, fillcolor);
149 }
150- if (destrect.y + zoomed->h < placed->h) {
151+ if (zoomed->h < placed->h) {
152 dstrc.x = 0;
153- dstrc.y = destrect.y + zoomed->h;
154+ dstrc.y = zoomed->h;
155 dstrc.w = placed->w;
156- dstrc.h = placed->h - destrect.y - zoomed->h;
157+ dstrc.h = placed->h - zoomed->h;
158 SDL_FillRect(placed, &dstrc, fillcolor);
159 }
160
161@@ -857,7 +848,7 @@
162 /**
163 * Load all animations that are registered with the AnimationManager
164 */
165-void Graphic::load_animations(UI::ProgressWindow & loader_ui) {
166+void Graphic::load_animations() {
167 assert(m_animations.empty());
168
169 m_animations.reserve(g_anim.get_nranimations());
170
171=== modified file 'src/graphic/graphic.h'
172--- src/graphic/graphic.h 2012-12-31 11:21:15 +0000
173+++ src/graphic/graphic.h 2013-01-06 13:38:25 +0000
174@@ -132,7 +132,7 @@
175 void animate_maptextures(uint32_t time);
176 void reset_texture_animation_reminder();
177
178- void load_animations(UI::ProgressWindow & loader_ui);
179+ void load_animations();
180 void ensure_animation_loaded(uint32_t anim);
181 AnimationGfx::Index nr_frames(uint32_t anim = 0);
182 uint32_t get_animation_frametime(uint32_t anim) const;
183@@ -177,15 +177,15 @@
184 bool m_update_fullscreen;
185 /// stores which features the current renderer has
186 GraphicCaps m_caps;
187+ Road_Textures * m_roadtextures;
188+ const IPicture* m_edgetexture;
189+ std::vector<Texture *> m_maptextures;
190+ std::vector<AnimationGfx *> m_animations;
191+
192 /// The class that gets images from disk.
193 boost::scoped_ptr<IImageLoader> img_loader_;
194 // The cache holding the images.
195 boost::scoped_ptr<ImageCache> img_cache_;
196-
197- Road_Textures * m_roadtextures;
198- const IPicture* m_edgetexture;
199- std::vector<Texture *> m_maptextures;
200- std::vector<AnimationGfx *> m_animations;
201 };
202
203 extern Graphic * g_gr;
204
205=== modified file 'src/graphic/render/gl_surface.cc'
206--- src/graphic/render/gl_surface.cc 2012-12-15 18:40:59 +0000
207+++ src/graphic/render/gl_surface.cc 2013-01-06 13:38:25 +0000
208@@ -83,8 +83,6 @@
209 void GLSurface::fill_rect(const Rect& rc, const RGBAColor clr) {
210 assert(rc.x >= 0);
211 assert(rc.y >= 0);
212- assert(rc.w >= 0);
213- assert(rc.h >= 0);
214 assert(g_opengl);
215 glDisable(GL_TEXTURE_2D);
216 glDisable(GL_BLEND);
217
218=== modified file 'src/graphic/render/sdl_surface.cc'
219--- src/graphic/render/sdl_surface.cc 2012-12-14 22:09:16 +0000
220+++ src/graphic/render/sdl_surface.cc 2013-01-06 13:38:25 +0000
221@@ -183,7 +183,10 @@
222 assert(rc.h >= 1);
223 const uint32_t color = clr.map(format());
224
225- SDL_Rect r = {rc.x, rc.y, rc.w, rc.h};
226+ SDL_Rect r = {
227+ static_cast<Sint16>(rc.x), static_cast<Sint16>(rc.y),
228+ static_cast<Uint16>(rc.w), static_cast<Uint16>(rc.h)
229+ };
230 SDL_FillRect(m_surface, &r, color);
231 }
232
233@@ -330,8 +333,14 @@
234 (const Point& dst, const IPicture* src, const Rect& srcrc, Composite cm)
235 {
236 const SDLSurface* sdlsurf = static_cast<const SDLSurface*>(src);
237- SDL_Rect srcrect = {srcrc.x, srcrc.y, srcrc.w, srcrc.h};
238- SDL_Rect dstrect = {dst.x, dst.y, 0, 0};
239+ SDL_Rect srcrect = {
240+ static_cast<Sint16>(srcrc.x), static_cast<Sint16>(srcrc.y),
241+ static_cast<Uint16>(srcrc.w), static_cast<Uint16>(srcrc.h)
242+ };
243+ SDL_Rect dstrect = {
244+ static_cast<Sint16>(dst.x), static_cast<Sint16>(dst.y),
245+ 0, 0
246+ };
247
248 bool alpha;
249 uint8_t alphaval;
250
251=== modified file 'src/graphic/text/rt_render.cc'
252--- src/graphic/text/rt_render.cc 2012-12-27 17:44:37 +0000
253+++ src/graphic/text/rt_render.cc 2013-01-06 13:38:25 +0000
254@@ -72,13 +72,17 @@
255 };
256
257 struct Reference {
258- Rect dim;
259+ Rect dim; // w & h are uint32_t; x & y are int32_t
260 string ref;
261
262+ // Why isn't Rect::contains() suitable?
263+ // There is a small difference...
264+ // Rect::contains() excludes the bottom and right edges.
265+ // Reference::contains() includes the bottom and right edges
266 inline bool contains(int16_t x, int16_t y) const {
267- if (dim.x <= x and x <= dim.x + dim.w and dim.y <= y and y <= dim.y + dim.h)
268- return true;
269- return false;
270+ return
271+ dim.x <= x && x <= dim.x + static_cast<int32_t>(dim.w) &&
272+ dim.y <= y && y <= dim.y + static_cast<int32_t>(dim.h);
273 }
274 };
275
276@@ -393,7 +397,7 @@
277 virtual uint32_t height() {return 0;}
278 virtual uint32_t width() {return INFINITE_WIDTH; }
279 virtual uint32_t hotspot_y() {return 0;}
280- virtual IBlitableSurface* render(IGraphic& gr) {
281+ virtual IBlitableSurface* render(IGraphic& /* gr */) {
282 assert(false); // This should never be called
283 }
284 virtual bool is_non_mandatory_space() {return true;}
285@@ -962,7 +966,8 @@
286
287 NodeStyle default_fs = {
288 "DejaVuSerif", 16,
289- RGBColor(0, 0, 0), IFont::DEFAULT, 0, HALIGN_LEFT, VALIGN_BOTTOM
290+ RGBColor(0, 0, 0), IFont::DEFAULT, 0, HALIGN_LEFT, VALIGN_BOTTOM,
291+ ""
292 };
293
294 if (!width)
295
296=== modified file 'src/graphic/text/sdl_ttf_font_impl.cc'
297--- src/graphic/text/sdl_ttf_font_impl.cc 2012-12-16 19:08:53 +0000
298+++ src/graphic/text/sdl_ttf_font_impl.cc 2013-01-06 13:38:25 +0000
299@@ -96,8 +96,8 @@
300 // the only compatible way to do it using SDL 1.2. SDL 2.0 offers more
301 // functionality but is not yet released.
302 Uint8 sr, sg, sb, sa, dr, dg, db, da, outa, outr = 0, outg = 0, outb = 0;
303- for (uint32_t y = 0; y < tsurf->h; ++y) {
304- for (uint32_t x = 0; x < tsurf->w; ++x) {
305+ for (int y = 0; y < tsurf->h; ++y) {
306+ for (int x = 0; x < tsurf->w; ++x) {
307 size_t sidx = (y * tsurf->pitch + 4 * x) / 4;
308 size_t didx = ((y + SHADOW_OFFSET) * text_surface->pitch + (x + SHADOW_OFFSET) * 4) / 4;
309
310
311=== modified file 'src/io/filesystem/disk_filesystem.cc'
312--- src/io/filesystem/disk_filesystem.cc 2012-09-21 21:36:07 +0000
313+++ src/io/filesystem/disk_filesystem.cc 2013-01-06 13:38:25 +0000
314@@ -16,6 +16,7 @@
315 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
316 *
317 */
318+#include "compile_diagnostics.h"
319
320 #include "disk_filesystem.h"
321
322@@ -425,12 +426,6 @@
323 return data;
324 }
325
326-#ifndef _MSC_VER
327-/// \note The MAP_FAILED macro from glibc uses old-style cast. We can not fix
328-/// this ourselves, so we temporarily turn the error into a warning. It is
329-/// turned back into an error after this function.
330-#pragma GCC diagnostic warning "-Wold-style-cast"
331-#endif
332 void * RealFSImpl::fastLoad
333 (const std::string & fname, size_t & length, bool & fast)
334 {
335@@ -455,22 +450,24 @@
336 data = mmap(0, length, PROT_READ, MAP_PRIVATE, file, 0);
337
338 //if mmap doesn't work for some strange reason try the old way
339- if (data == MAP_FAILED)
340+GCC_DIAG_OFF("-Wold-style-cast")
341+ if (data == MAP_FAILED) {
342+GCC_DIAG_ON("-Wold-style-cast")
343 return Load(fname, length);
344+ }
345
346 fast = true;
347
348 assert(data);
349+GCC_DIAG_OFF("-Wold-style-cast")
350 assert(data != MAP_FAILED);
351+GCC_DIAG_ON("-Wold-style-cast")
352
353 close(file);
354
355 return data;
356 #endif
357 }
358-#ifndef _MSC_VER
359-#pragma GCC diagnostic error "-Wold-style-cast"
360-#endif
361
362 /**
363 * Write the given block of memory to the repository.
364
365=== modified file 'src/logic/editor_game_base.cc'
366--- src/logic/editor_game_base.cc 2012-09-21 21:36:07 +0000
367+++ src/logic/editor_game_base.cc 2013-01-06 13:38:25 +0000
368@@ -287,7 +287,7 @@
369
370 // TODO: load player graphics? (maybe)
371
372- g_gr->load_animations(loader_ui);
373+ g_gr->load_animations();
374 }
375
376 /**
377
378=== modified file 'src/minizip/unzip.cc'
379--- src/minizip/unzip.cc 2012-04-07 15:12:06 +0000
380+++ src/minizip/unzip.cc 2013-01-06 13:38:25 +0000
381@@ -1,3 +1,7 @@
382+/* Don't want to modify the minizip/zlib sources, so lets silence the warnings */
383+#include "compile_diagnostics.h"
384+GCC_DIAG_OFF("-Wold-style-cast")
385+
386 /*
387 ================================================================================
388
389
390=== modified file 'src/network/internet_gaming.cc'
391--- src/network/internet_gaming.cc 2013-01-01 18:05:49 +0000
392+++ src/network/internet_gaming.cc 2013-01-06 13:38:25 +0000
393@@ -19,6 +19,7 @@
394
395 #include "internet_gaming.h"
396
397+#include "compile_diagnostics.h"
398 #include "i18n.h"
399 #include "io/filesystem/layered_filesystem.h"
400 #include "internet_gaming_messages.h"
401@@ -106,7 +107,9 @@
402 IPaddress peer;
403 if (hostent * const he = gethostbyname(m_meta.c_str())) {
404 peer.host = (reinterpret_cast<in_addr *>(he->h_addr_list[0]))->s_addr;
405+GCC_DIAG_OFF("-Wold-style-cast")
406 peer.port = htons(m_port);
407+GCC_DIAG_ON("-Wold-style-cast")
408 } else
409 throw warning
410 (_("Connection problem"), "%s", _("Widelands has not been able to connect to the metaserver."));
411
412=== modified file 'src/network/nethost.cc'
413--- src/network/nethost.cc 2013-01-05 18:43:00 +0000
414+++ src/network/nethost.cc 2013-01-06 13:38:25 +0000
415@@ -895,6 +895,8 @@
416 d->settings.savegame ? Widelands::Game::Loaded : d->settings.scenario ?
417 Widelands::Game::NewMPScenario : Widelands::Game::NewNonScenario);
418
419+ delete tips;
420+
421 // if this is an internet game, tell the metaserver that the game is done.
422 if (m_internet)
423 InternetGaming::ref().set_game_done();
424
425=== modified file 'src/network/network_lan_promotion.cc'
426--- src/network/network_lan_promotion.cc 2012-02-15 21:25:34 +0000
427+++ src/network/network_lan_promotion.cc 2013-01-06 13:38:25 +0000
428@@ -1,5 +1,5 @@
429 /*
430- * Copyright (C) 2004-2010 by the Widelands Development Team
431+ * Copyright (C) 2004-2010,2013 by the Widelands Development Team
432 *
433 * This program is free software; you can redistribute it and/or
434 * modify it under the terms of the GNU General Public License
435@@ -20,6 +20,7 @@
436 #include "network_lan_promotion.h"
437
438 #include "build_info.h"
439+#include "compile_diagnostics.h"
440 #include "constants.h"
441
442 #include "container_iterate.h"
443@@ -48,6 +49,8 @@
444
445 for (int32_t i = 0; ifnames[i].if_index; ++i) {
446 strncpy (ifr.ifr_name, ifnames[i].if_name, IFNAMSIZ);
447+
448+GCC_DIAG_OFF("-Wold-style-cast")
449 if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0)
450 continue;
451
452@@ -56,6 +59,7 @@
453
454 if (ioctl(sock, SIOCGIFBRDADDR, &ifr) < 0)
455 continue;
456+GCC_DIAG_ON("-Wold-style-cast")
457
458 broadcast_addresses.push_back
459 (reinterpret_cast<sockaddr_in *>(&ifr.ifr_broadaddr)
460@@ -75,39 +79,34 @@
461 closesocket (sock);
462 }
463
464-/// \note The INADDR_ANY macro from glibc uses old-style cast. We can not fix
465-/// this ourselves, so we temporarily turn the error into a warning. It is
466-/// turned back into an error after this function.
467-#pragma GCC diagnostic warning "-Wold-style-cast"
468 void LAN_Base::bind (uint16_t port)
469 {
470 sockaddr_in addr;
471+
472+GCC_DIAG_OFF("-Wold-style-cast")
473 addr.sin_family = AF_INET;
474 addr.sin_addr.s_addr = INADDR_ANY;
475 addr.sin_port = htons(port);
476+GCC_DIAG_ON("-Wold-style-cast")
477
478 ::bind (sock, reinterpret_cast<sockaddr *>(&addr), sizeof(addr));
479 }
480-#pragma GCC diagnostic error "-Wold-style-cast"
481
482-/// \note The FD_SET macro from glibc uses old-style cast. We can not fix this
483-/// ourselves, so we temporarily turn the error into a warning. It is turned
484-/// back into an error after this function.
485-#pragma GCC diagnostic warning "-Wold-style-cast"
486 bool LAN_Base::avail ()
487 {
488 fd_set fds;
489 timeval tv;
490
491+GCC_DIAG_OFF("-Wold-style-cast")
492 FD_ZERO(&fds);
493 FD_SET(sock, &fds);
494+GCC_DIAG_ON("-Wold-style-cast")
495
496 tv.tv_sec = 0;
497 tv.tv_usec = 0;
498
499 return select(sock + 1, &fds, 0, 0, &tv) == 1;
500 }
501-#pragma GCC diagnostic error "-Wold-style-cast"
502
503 ssize_t LAN_Base::recv
504 (void * const buf, size_t const len, sockaddr_in * const addr)
505@@ -135,9 +134,6 @@
506 sizeof(sockaddr_in));
507 }
508
509-// FIXME Document why this pragma is needed and what is done about it (see how
510-// FIXME other uses of this pragmas are documented).
511-#pragma GCC diagnostic warning "-Wold-style-cast"
512 void LAN_Base::broadcast
513 (void const * const buf, size_t const len, uint16_t const port)
514 {
515@@ -145,7 +141,9 @@
516 sockaddr_in addr;
517 addr.sin_family = AF_INET;
518 addr.sin_addr.s_addr = *i.current;
519+GCC_DIAG_OFF("-Wold-style-cast")
520 addr.sin_port = htons(port);
521+GCC_DIAG_ON("-Wold-style-cast")
522
523 sendto
524 (sock,
525@@ -156,7 +154,6 @@
526 sizeof(addr));
527 }
528 }
529-#pragma GCC diagnostic error "-Wold-style-cast"
530
531 /*** class LAN_Game_Promoter ***/
532
533@@ -240,9 +237,6 @@
534 }
535
536
537-// FIXME Document why this pragma is needed and what is done about it (see how
538-// FIXME other uses of this pragmas are documented).
539-#pragma GCC diagnostic warning "-Wold-style-cast"
540 void LAN_Game_Finder::run ()
541 {
542 while (avail()) {
543@@ -267,8 +261,10 @@
544 for (wl_const_range<std::list<Net_Open_Game *> > i(opengames);; ++i)
545 if (i.empty()) {
546 opengames.push_back (new Net_Open_Game);
547+GCC_DIAG_OFF("-Wold-style-cast")
548 opengames.back()->address = addr.sin_addr.s_addr;
549 opengames.back()->port = htons(WIDELANDS_PORT);
550+GCC_DIAG_ON("-Wold-style-cast")
551 opengames.back()->info = info;
552 callback (GameOpened, opengames.back(), userdata);
553 break;
554@@ -280,7 +276,6 @@
555 }
556 }
557 }
558-#pragma GCC diagnostic error "-Wold-style-cast"
559
560 void LAN_Game_Finder::set_callback
561 (void (* const cb)(int32_t, Net_Open_Game const *, void *), void * const ud)
562
563=== modified file 'src/s2map.cc'
564--- src/s2map.cc 2012-09-21 21:36:07 +0000
565+++ src/s2map.cc 2013-01-06 13:38:25 +0000
566@@ -31,14 +31,12 @@
567 #include "wexception.h"
568
569 #include <iostream>
570+#include <iomanip>
571
572 using std::cerr;
573+using std::endl;
574 using std::ios;
575-using std::endl;
576-
577-// TEMP
578-#define hex ios::hex
579-#define dec ios::dec
580+using std::setiosflags;
581
582 // this is a detail of S2 maps
583 #define CRITTER_PER_DEFINITION 1
584@@ -328,9 +326,11 @@
585 default:
586 c = 7;
587 cerr
588- << "ERROR: Unknown texture1: " << hex << c << dec << " ("
589+ << "ERROR: Unknown texture1: "
590+ << setiosflags(ios::hex) << c
591+ << setiosflags(ios::dec) << " ("
592 << x << "," << y << ") (defaults to water!)" << endl;
593- break;
594+ break;
595 }
596 f->set_terrain_d(c);
597 }
598@@ -380,7 +380,9 @@
599 default:
600 c = 7;
601 cerr
602- << "ERROR: Unknown texture1: " << hex << c << dec << " ("
603+ << "ERROR: Unknown texture1: "
604+ << setiosflags(ios::hex) << c
605+ << setiosflags(ios::dec) << " ("
606 << x << "," << y << ") (defaults to water!)" << endl;
607 break;
608 }
609
610=== modified file 'src/scripting/pluto.cc'
611--- src/scripting/pluto.cc 2012-09-21 21:36:07 +0000
612+++ src/scripting/pluto.cc 2013-01-06 13:38:25 +0000
613@@ -27,6 +27,11 @@
614
615 #include "pluto.h"
616
617+// Widelands: silence warnings about unused variables, usually because they
618+//are only used in conditional asserts
619+#include "compile_diagnostics.h"
620+GCC_DIAG_OFF("-Wunused-variable")
621+
622
623 // Forward declarated from lua_impl.h. So we do not need to include it
624 int luna_restore_object(lua_State * L);
625
626=== modified file 'src/ui_basic/listselect.cc'
627--- src/ui_basic/listselect.cc 2012-12-16 14:29:46 +0000
628+++ src/ui_basic/listselect.cc 2013-01-06 13:38:25 +0000
629@@ -411,7 +411,6 @@
630
631 // Now draw pictures
632 if (er.pic) {
633- uint32_t w = er.pic->get_w();
634 uint32_t h = er.pic->get_h();
635 dst.blit(Point(1, y + (get_lineheight() - h) / 2), er.pic);
636 }
637
638=== modified file 'src/ui_basic/panel.cc'
639--- src/ui_basic/panel.cc 2013-01-04 09:59:13 +0000
640+++ src/ui_basic/panel.cc 2013-01-06 13:38:25 +0000
641@@ -305,8 +305,6 @@
642 if (_desired_w == w && _desired_h == h)
643 return;
644
645- assert(w >= 0);
646- assert(h >= 0);
647 assert(w < 3000);
648 assert(h < 3000);
649
650
651=== modified file 'src/ui_fsmenu/base.cc'
652--- src/ui_fsmenu/base.cc 2012-12-15 15:18:49 +0000
653+++ src/ui_fsmenu/base.cc 2013-01-06 13:38:25 +0000
654@@ -54,8 +54,6 @@
655 : UI::Panel(0, 0, 0, gr_x(), gr_y()),
656 d(new Data)
657 {
658- Section & s = g_options.pull_section("global");
659-
660 // Load background graphics
661 char buffer[256];
662 snprintf(buffer, sizeof(buffer), "pics/%s", bgpic);
663
664=== modified file 'src/ui_fsmenu/internet_lobby.cc'
665--- src/ui_fsmenu/internet_lobby.cc 2012-12-13 10:41:22 +0000
666+++ src/ui_fsmenu/internet_lobby.cc 2013-01-06 13:38:25 +0000
667@@ -21,6 +21,7 @@
668
669 #include <boost/bind.hpp>
670
671+#include "compile_diagnostics.h"
672 #include "constants.h"
673 #include "graphic/graphic.h"
674 #include "i18n.h"
675@@ -399,7 +400,9 @@
676 IPaddress peer;
677 if (hostent * const he = gethostbyname(ip.c_str())) {
678 peer.host = (reinterpret_cast<in_addr *>(he->h_addr_list[0]))->s_addr;
679+GCC_DIAG_OFF("-Wold-style-cast")
680 peer.port = htons(WIDELANDS_PORT);
681+GCC_DIAG_ON("-Wold-style-cast")
682 } else {
683 // Actually the game is not done, but that way we are again listed as in the lobby
684 InternetGaming::ref().set_game_done();
685
686=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
687--- src/ui_fsmenu/netsetup_lan.cc 2012-12-13 10:41:22 +0000
688+++ src/ui_fsmenu/netsetup_lan.cc 2013-01-06 13:38:25 +0000
689@@ -18,6 +18,8 @@
690 */
691
692 #include "netsetup_lan.h"
693+
694+#include "compile_diagnostics.h"
695 #include "constants.h"
696 #include "graphic/graphic.h"
697 #include "i18n.h"
698@@ -156,7 +158,9 @@
699
700 if (hostent * const he = gethostbyname(host.c_str())) {
701 addr = (reinterpret_cast<in_addr *>(he->h_addr_list[0]))->s_addr;
702+GCC_DIAG_OFF("-Wold-style-cast")
703 port = htons(WIDELANDS_PORT);
704+GCC_DIAG_ON("-Wold-style-cast")
705 return true;
706 } else
707 return false;
708
709=== modified file 'src/wui/waresdisplay.cc'
710--- src/wui/waresdisplay.cc 2012-12-27 17:44:37 +0000
711+++ src/wui/waresdisplay.cc 2013-01-06 13:38:25 +0000
712@@ -246,7 +246,6 @@
713 ware_selected(id) ? "pics/ware_list_bg_selected.png"
714 : "pics/ware_list_bg.png");
715 uint32_t w = bgpic->get_w();
716- uint32_t h = bgpic->get_h();
717
718 dst.blit(p, bgpic);
719
720@@ -410,7 +409,6 @@
721 // draw a background
722 const IPicture* pic = g_gr->imgcache().load (PicMod_Game, "pics/ware_list_bg.png");
723 uint32_t w = pic->get_w();
724- uint32_t h = pic->get_h();
725
726 dst.blit(p, pic);
727
728
729=== modified file 'src/wui/waresqueuedisplay.cc'
730--- src/wui/waresqueuedisplay.cc 2012-12-13 10:41:22 +0000
731+++ src/wui/waresqueuedisplay.cc 2013-01-06 13:38:25 +0000
732@@ -64,7 +64,6 @@
733 m_icon_grey = g_gr->create_grayed_out_pic(m_icon);
734 m_icon_grey = g_gr->create_changed_luminosity_pic(m_icon_grey, 0.65);
735
736- uint32_t pw = m_max_fill_indicator->get_w();
737 uint32_t ph = m_max_fill_indicator->get_h();
738
739 uint32_t priority_button_height = show_only ? 0 : 3 * PriorityButtonSize;

Subscribers

People subscribed via source and target branches

to status/vote changes: