Author: cazfi
Date: Mon Apr 20 02:58:18 2015
New Revision: 28819

URL: http://svn.gna.org/viewcvs/freeciv?rev=28819&view=rev
Log:
Fixed warnings from gcc-5 and cppcheck

- Initialize first element of buffers to '\0' before catenating text to them
- Fixed a bug in sdl-clients' where array was referenced via pointer after it 
was out-of-scope
- Cleaned out extra "not" from comparisons of boolean effect values

Patch by Per I. Mathisen <per> and myself

See patch #5994

Modified:
    branches/S2_6/client/gui-gtk-2.0/helpdlg.c
    branches/S2_6/client/gui-gtk-3.0/helpdlg.c
    branches/S2_6/client/gui-sdl/graphics.c
    branches/S2_6/client/gui-sdl2/graphics.c
    branches/S2_6/client/gui-xaw/helpdlg.c
    branches/S2_6/common/city.c
    branches/S2_6/common/improvement.c
    branches/S2_6/common/unittype.c

Modified: branches/S2_6/client/gui-gtk-2.0/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/helpdlg.c?rev=28819&r1=28818&r2=28819&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/helpdlg.c  (original)
+++ branches/S2_6/client/gui-gtk-2.0/helpdlg.c  Mon Apr 20 02:58:18 2015
@@ -1232,6 +1232,7 @@
 
   create_help_page(HELP_EXTRA);
 
+  buf[0] = '\0';
   if (pextra == NULL) {
     strcat(buf, pitem->text);
   } else {

Modified: branches/S2_6/client/gui-gtk-3.0/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/helpdlg.c?rev=28819&r1=28818&r2=28819&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/helpdlg.c  (original)
+++ branches/S2_6/client/gui-gtk-3.0/helpdlg.c  Mon Apr 20 02:58:18 2015
@@ -1257,6 +1257,7 @@
 
   create_help_page(HELP_EXTRA);
 
+  buf[0] = '\0';
   if (pextra == NULL) {
     strcat(buf, pitem->text);
   } else {

Modified: branches/S2_6/client/gui-sdl/graphics.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/graphics.c?rev=28819&r1=28818&r2=28819&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/graphics.c     (original)
+++ branches/S2_6/client/gui-sdl/graphics.c     Mon Apr 20 02:58:18 2015
@@ -393,6 +393,7 @@
                                   SDL_Color * pColor, bool add_alpha)
 {
   SDL_Surface *pNew;
+  SDL_Color color = {255, 255, 255, 128};
 
   if (add_alpha) {
     pNew = create_surf_alpha(w, h, iFlags);
@@ -406,7 +407,6 @@
 
   if (!pColor) {
     /* pColor->unused == ALPHA */
-    SDL_Color color ={255, 255, 255, 128};
     pColor = &color;
   }
 

Modified: branches/S2_6/client/gui-sdl2/graphics.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/graphics.c?rev=28819&r1=28818&r2=28819&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/graphics.c    (original)
+++ branches/S2_6/client/gui-sdl2/graphics.c    Mon Apr 20 02:58:18 2015
@@ -410,6 +410,7 @@
                                    SDL_Color *pColor)
 {
   SDL_Surface *pNew;
+  SDL_Color color = {255, 255, 255, 128};
 
   pNew = create_surf(w, h, iFlags);
 
@@ -419,8 +420,6 @@
 
   if (!pColor) {
     /* pColor->unused == ALPHA */
-    SDL_Color color = {255, 255, 255, 128};
-
     pColor = &color;
   }
 

Modified: branches/S2_6/client/gui-xaw/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-xaw/helpdlg.c?rev=28819&r1=28818&r2=28819&view=diff
==============================================================================
--- branches/S2_6/client/gui-xaw/helpdlg.c      (original)
+++ branches/S2_6/client/gui-xaw/helpdlg.c      Mon Apr 20 02:58:18 2015
@@ -1087,6 +1087,7 @@
   char buf[4096];
   struct extra_type *pextra = extra_type_by_translated_name(title);
 
+  buf[0] = '\0';
   if (pextra == NULL) {
     strcat(buf, pitem->text);
   } else {

Modified: branches/S2_6/common/city.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/city.c?rev=28819&r1=28818&r2=28819&view=diff
==============================================================================
--- branches/S2_6/common/city.c (original)
+++ branches/S2_6/common/city.c Mon Apr 20 02:58:18 2015
@@ -1929,7 +1929,7 @@
 {
   int tithes_bonus = 0;
 
-  if (!get_city_bonus(pcity, EFT_HAPPINESS_TO_GOLD) > 0) {
+  if (get_city_bonus(pcity, EFT_HAPPINESS_TO_GOLD) <= 0) {
     return 0;
   }
 

Modified: branches/S2_6/common/improvement.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/improvement.c?rev=28819&r1=28818&r2=28819&view=diff
==============================================================================
--- branches/S2_6/common/improvement.c  (original)
+++ branches/S2_6/common/improvement.c  Mon Apr 20 02:58:18 2015
@@ -608,7 +608,7 @@
     }
   }
   if (space_part &&
-      (!get_player_bonus(p, EFT_ENABLE_SPACE) > 0
+      (get_player_bonus(p, EFT_ENABLE_SPACE) <= 0
        || p->spaceship.state >= SSHIP_LAUNCHED)) {
     return FALSE;
   }

Modified: branches/S2_6/common/unittype.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unittype.c?rev=28819&r1=28818&r2=28819&view=diff
==============================================================================
--- branches/S2_6/common/unittype.c     (original)
+++ branches/S2_6/common/unittype.c     Mon Apr 20 02:58:18 2015
@@ -926,7 +926,7 @@
   }
 
   if (utype_has_flag(punittype, UTYF_NUCLEAR)
-      && !get_player_bonus(p, EFT_ENABLE_NUKE) > 0) {
+      && get_player_bonus(p, EFT_ENABLE_NUKE) <= 0) {
     return FALSE;
   }
   if (utype_has_flag(punittype, UTYF_NOBUILD)) {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to