[tecnoballz] 29/56: Fix a slew of compiler warnings and build with -Werror by default.

Markus Koschany apo-guest at moszumanska.debian.org
Fri Jan 30 12:12:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

apo-guest pushed a commit to branch master
in repository tecnoballz.

commit 576177409e12998c3b9f8455c6e3d1ac615455b8
Author: Peter Pentchev <roam at ringlet.net>
Date:   Thu Feb 17 16:01:42 2011 +0000

    Fix a slew of compiler warnings and build with -Werror by default.
---
 debian/changelog                  |   3 +
 debian/patches/032_warnings.patch | 195 ++++++++++++++++++++++++++++++++++++++
 debian/patches/series             |   1 +
 debian/rules                      |   4 +
 4 files changed, 203 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 9fcbf29..d81b0fc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,9 @@ tecnoballz (0.92-4) UNRELEASED; urgency=low
   * Add the 031_honor_cxxflags patch.
   * Use dpkg-buildflags to obtain the default values for CPPFLAGS,
     CXXFLAGS and LDFLAGS.
+  * Add -Werror to the compiler flags unless the non-standard "nowerror"
+    build option is specified.
+  * Add the 032_warnings patch to fix a slew of compiler warnings.
 
  -- Peter Pentchev <roam at ringlet.net>  Thu, 17 Feb 2011 10:35:58 +0200
 
diff --git a/debian/patches/032_warnings.patch b/debian/patches/032_warnings.patch
new file mode 100644
index 0000000..c227529
--- /dev/null
+++ b/debian/patches/032_warnings.patch
@@ -0,0 +1,195 @@
+Description: Fix some compiler warnings.
+ - constify a couple of char pointers to static strings
+ - remove some unneeded declarations with mismatched types
+ - add some parentheses to disambiguate operations' priority
+ - initialize a loop index to avoid an array[-1] access
+ - add some parentheses to fix a comparison's logic
+Forwarded: no
+Author: Peter Pentchev <roam at ringlet.net>
+Last-Update: 2011-02-17
+
+--- a/src/handler_audio.cc
++++ b/src/handler_audio.cc
+@@ -234,7 +234,7 @@
+       "Mix_QuerySpec return " << Mix_GetError () << std::endl;
+       return;
+     }
+-  char *format = "Unknown";
++  const char *format = "Unknown";
+   switch (format_id)
+     {
+     case AUDIO_U8:
+--- a/src/handler_popup_menu.cc
++++ b/src/handler_popup_menu.cc
+@@ -424,7 +424,7 @@
+           for (j = 0; j < num_of_columns; j++)
+             {
+               unsigned char pixel = cycling_table[color];
+-              char a = *(p++) - 32;
++              a = *(p++) - 32;
+               if (a != 0)
+                 {
+                   b = c[a];
+@@ -509,7 +509,7 @@
+           for (j = 0; j < num_of_columns; j++)
+             {
+               unsigned char pixel = cycling_table[color];
+-              char a = *(p++) - 32;
++              a = *(p++) - 32;
+               if (a != 0)
+                 {
+                   b = c[a];
+--- a/src/handler_resources.cc
++++ b/src/handler_resources.cc
+@@ -45,7 +45,7 @@
+ #endif
+ #endif
+ 
+-char * handler_resources::fnamescore = SCOREFILE;
++const char * handler_resources::fnamescore = SCOREFILE;
+ const char *
+   handler_resources::folder_640 = "hires/";
+ const char *
+@@ -621,7 +621,7 @@
+  * @param fname filename specified by path
+  */
+ char *
+-handler_resources::load_file (char *fname)
++handler_resources::load_file (const char *fname)
+ {
+   return load_file (fname, &last_filesize_loaded);
+ }
+@@ -633,7 +633,7 @@
+  * return a pointer to the file data 
+ */
+ char *
+-handler_resources::load_file (char *fname, Uint32 * fsize)
++handler_resources::load_file (const char *fname, Uint32 * fsize)
+ {
+   /* locate a file under one of the data directories */
+   char *pname = locate_data_file (fname);
+--- a/include/handler_resources.h
++++ b/include/handler_resources.h
+@@ -42,7 +42,7 @@
+     static const char *folderdata;
+     static const char *folder_320;
+     static const char *folder_640;
+-    static char *fnamescore;
++    static const char *fnamescore;
+     static char tmp_filename[512];
+     static char pathstring[512];
+     static const Uint32 TEXTS_OFFSET = 2048;
+@@ -118,8 +118,8 @@
+ 
+   private:
+     char *loadfile_with_lang (const char *const filename, Uint32 * const fsize);
+-    char *load_file (char *fname);
+-    char *load_file (char *fname, Uint32 * fsize);
++    char *load_file (const char *fname);
++    char *load_file (const char *fname, Uint32 * fsize);
+   };
+ 
+ #endif
+--- a/src/lispreader.cc
++++ b/src/lispreader.cc
+@@ -121,7 +121,7 @@
+ static int
+ _scan (lisp_stream_t *stream)
+ {
+-  static char *delims = "\"();";
++  static const char *delims = "\"();";
+ 
+   int c;
+ 
+@@ -549,7 +549,7 @@
+       {
+         struct
+           {
+-            char *name;
++            const char *name;
+             int type;
+           }
+         types[] =
+--- a/src/sprite_display_menu.cc
++++ b/src/sprite_display_menu.cc
+@@ -234,7 +234,7 @@
+               for (j = 0; j < NUM_OF_COLUMNS; j++)
+                 {
+                   unsigned char pixel = color_cycling[color];
+-                  char a = *(p++) - 32;
++                  a = *(p++) - 32;
+                   if (a != 0)
+                     {
+                       b = c[a];
+@@ -335,7 +335,7 @@
+               for (j = 0; j < NUM_OF_COLUMNS; j++)
+                 {
+                   unsigned char pixel = color_cycling[color];
+-                  char a = *(p++) - 32;
++                  a = *(p++) - 32;
+                   if (a != 0)
+                     {
+                       b = c[a];
+--- a/src/sprite_gem.cc
++++ b/src/sprite_gem.cc
+@@ -99,7 +99,7 @@
+   paddle = pad;
+   towards = paddle->get_paddle_number ();
+   speed_of_moving = resolution;
+-  Uint32 h = (random_counter >> 4 + rand_count++) & 7;
++  Uint32 h = (random_counter >> (4 + rand_count++)) & 7;
+   random_counter += xcoord;
+   h = gem_random[h];
+   gem_id = h;
+--- a/src/supervisor_map_editor.cc
++++ b/src/supervisor_map_editor.cc
+@@ -832,7 +832,7 @@
+ #else
+   umask (0002);
+ #endif
+-  char *
++  const char *
+   filename = "edmap.data";
+   Sint32
+   handle = open (filename, O_WRONLY | O_CREAT, 00666);
+--- a/include/supervisor_shop.h
++++ b/include/supervisor_shop.h
+@@ -164,7 +164,7 @@
+     /** Prices of all the available options in the shop */
+     static Uint32 options_prices[];
+     /** Indexes of the texts used for sales confirmation messages */
+-    static char led_index_to_text_index[];
++    static unsigned char led_index_to_text_index[];
+ 
+   public:
+     supervisor_shop ();
+--- a/src/supervisor_shop.cc
++++ b/src/supervisor_shop.cc
+@@ -866,6 +866,7 @@
+         }
+       else
+         {
++	  i = 0;
+           while (available_options_id[i] != sprite_capsule::LEAVE_SHOP)
+             {
+               if (available_options_id[i] == drop_id)
+@@ -1081,7 +1082,7 @@
+ /**
+  * Indexes of the texts used for sales confirmation messages
+  */
+-char
++unsigned char
+ supervisor_shop::led_index_to_text_index[] =
+ {
+   /* S+/F1/F2/RW/B2/B3 */
+--- a/src/tinyxmlparser.cc
++++ b/src/tinyxmlparser.cc
+@@ -354,7 +354,7 @@
+ 	}
+ 	else
+ 	{
+-		while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
++		while ( *p && (IsWhiteSpace( *p ) || *p == '\n' || *p =='\r') )
+ 			++p;
+ 	}
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 1781f23..faddf88 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@
 020_level_data.diff
 030_texts_dir.diff
 031_honor_cxxflags.diff
+032_warnings.patch
diff --git a/debian/rules b/debian/rules
index e07292d..ddb5a60 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,6 +10,10 @@ LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)
 # Warnings
 CXXFLAGS += -Wall -fno-strict-aliasing
 
+ifeq (,$(filter nowerror,$(DEB_BUILD_OPTIONS)))
+	CXXFLAGS+=	-Werror
+endif
+
 export CPPFLAGS CXXFLAGS LDFLAGS
 
 override_dh_auto_configure:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/tecnoballz.git



More information about the Pkg-games-commits mailing list