alex4 (1.1-5) compiler-warnings.patch

Summary

 src/defs.h     |   12 ++++++++++++
 src/edit.c     |    2 +-
 src/edit.h     |    2 +-
 src/hisc.c     |    2 +-
 src/hisc.h     |    2 +-
 src/main.c     |   30 +++++++++++++++---------------
 src/main.h     |    6 +++---
 src/map.c      |    2 +-
 src/map.h      |    2 +-
 src/particle.c |    4 ++--
 src/shooter.c  |    2 +-
 src/timer.c    |    4 ++--
 src/token.c    |    4 ++--
 src/token.h    |    2 +-
 14 files changed, 44 insertions(+), 32 deletions(-)

    
download this patch

Patch contents

Description: Fix some compiler warnings.
 - mark a couple of function parameters as unused
 - remove a couple of unused function parameters
 - remove a couple of stray semicolons outside of functions
 - define _XOPEN_SOURCE for strdup(3)
 - constify a couple of character pointers
 - replace some int -> float casts with a multiplication by 1.0
Forwarded: no
Author: Peter Pentchev <roam@ringlet.net>
Last-Update: 2011-03-09

--- a/src/main.c
+++ b/src/main.c
@@ -17,13 +17,14 @@
  *    http://www.gnu.org for license information.             *
  **************************************************************/
  
- 
+#define _XOPEN_SOURCE	700
  
 #include <allegro.h>
 #include <aldumb.h>
 #include <string.h>
 #include <ctype.h>
 
+#include "defs.h"
 #include "timer.h"
 #include "map.h"
 #include "control.h"
@@ -42,7 +43,6 @@
 
 #include "../data/data.h"
 
-
 // some game status defines
 #define GS_OK				1
 #define GS_GAMEOVER			2
@@ -153,7 +153,7 @@
 
 
 // loggs the text to the text file
-void log2file(char *format, ...) {
+void log2file(const char *format, ...) {
 	va_list ptr; /* get an arg pointer */
 	
 	if (log_fp) {
@@ -254,7 +254,7 @@
 
 
 // shows a little message
-void msg_box(char *str) {
+void msg_box(const char *str) {
 	if (got_sound) al_pause_duh(dp);
 	alert("Alex 4: Message", NULL, str, "OK", NULL, 0, 0);
 	if (got_sound) al_resume_duh(dp);
@@ -306,7 +306,7 @@
 	{
 		sr = dumb_it_start_at_order(duh, n_channels, startorder);
 		dp = al_duh_encapsulate_sigrenderer(sr,
-			((float)(get_config_int("sound", "music_volume", 255)) / 255.0),
+			((get_config_int("sound", "music_volume", 255) * 1.0) / 255.0),
 			get_config_int("dumb", "buffer_size", 4096),
 			get_config_int("dumb", "sound_freq", 44100));
 		if (!dp) duh_end_sigrenderer(sr); // howto.txt doesn't mention that this is necessary! dumb.txt does ...
@@ -565,7 +565,7 @@
 
 
 // loads a sample from disk
-SAMPLE *load_path_sample(char *fname) {
+SAMPLE *load_path_sample(const char *fname) {
 	char buf[1024];
 	SAMPLE *s;
 	sprintf(buf, "%s/%s", get_config_string("sound", "sfx_path", "sfx"), fname);
@@ -581,7 +581,7 @@
 
 // counts number of maps
 // invoked when loading the map datafile
-void count_maps_callback(DATAFILE *d) {
+void count_maps_callback(DATAFILE *d __unused) {
 	num_levels ++;
 }
 
@@ -1579,7 +1579,7 @@
 
 
 // tidies up after a map has been used
-void deinit_map(Tmap *m) {
+void deinit_map(void) {
 	int i;
 
 	// stop any playing sounds
@@ -1724,7 +1724,7 @@
 // starts a new level
 // level_id < 0 -> load fname
 // uses datafile map o/w
-void new_level(char *fname, int level_id, int draw) {
+void new_level(const char *fname, int level_id, int draw) {
 	int tox;
 	int i;
 	int x, y;
@@ -2367,7 +2367,7 @@
 
 
 // play the game!
-int play(int level) {
+int play(void) {
 	int i;
 	int playing_go_music = 0;
 
@@ -2819,8 +2819,8 @@
 			draw_frame(swap_screen, 1);
 			blit_to_screen(swap_screen);
 			fade_in_pal(100);
-			status = play(-1);
-			deinit_map(map);
+			status = play();
+			deinit_map();
 		}
 		else {
 			log2file(" *** failed");
@@ -2877,10 +2877,10 @@
 
 			// actual game starts here
 			show_lets_go();
-			status = play(level);
+			status = play();
 			// done playing level
 
-			deinit_map(map);
+			deinit_map();
 
 			// act on different outcomes
 			if (status == GS_GAME_DIED) {
@@ -3112,7 +3112,7 @@
 		fclose(log_fp);
 
 	return 0;
-} END_OF_MAIN(); 
+} END_OF_MAIN() 
 
 
 
--- /dev/null
+++ b/src/defs.h
@@ -0,0 +1,12 @@
+#ifndef _INCLUDED_DEFS_H
+#define _INCLUDED_DEFS_H
+
+#ifndef __unused
+#ifdef __GNUC__
+#define __unused __attribute__((unused))
+#else  /* __GNUC__ */
+#define __unused
+#endif /* __GNUC__ */
+#endif /* __unused */
+
+#endif /* _INCLUDED */
--- a/src/particle.c
+++ b/src/particle.c
@@ -20,8 +20,8 @@
  
  
 
-
 #include "particle.h"
+#include "defs.h"
 
 // pointer to datafile
 DATAFILE *data;
@@ -92,7 +92,7 @@
 }
 
 // updates particle with map
-void update_particle_with_map(Tparticle *p, Tmap *m) {
+void update_particle_with_map(Tparticle *p, Tmap *m __unused) {
 	update_particle(p);
 
 	/* bouncing algo removed 
--- a/src/timer.c
+++ b/src/timer.c
@@ -30,7 +30,7 @@
 	lps = logic_count;
 	logic_count = 0;
 }
-END_OF_FUNCTION(fps_counter);
+END_OF_FUNCTION(fps_counter)
 
 
 // keeps track of internal game speed
@@ -38,7 +38,7 @@
 	cycle_count++;
 	game_count++;
 }
-END_OF_FUNCTION(game_counter);
+END_OF_FUNCTION(game_counter)
 
 
 // initiates the timers
--- a/src/token.c
+++ b/src/token.c
@@ -18,7 +18,7 @@
  **************************************************************/
  
  
- 
+#define _XOPEN_SOURCE	700 
 
 #include <stdio.h>
 #include <string.h>
@@ -32,7 +32,7 @@
 ////////////////////////////////////////////////////////////////
 
 // creates a new token
-Ttoken *create_token(char *word) {
+Ttoken *create_token(const char *word) {
     Ttoken *tok = malloc(sizeof(Ttoken));
     if (tok != NULL) {
         tok->word = strdup(word);
--- a/src/main.h
+++ b/src/main.h
@@ -63,13 +63,13 @@
 // functions
 char *get_init_string();
 void textout_outline_center(BITMAP *bmp, const char *txt, int cx, int y);
-void log2file(char *format, ...);
+void log2file(const char *format, ...);
 int do_pause_menu(BITMAP *bg);
 void take_screenshot(BITMAP *bmp);
 void set_map(Tmap *m);
-void msg_box(char *str);
+void msg_box(const char *str);
 void new_game(int reset_player_data);
-void new_level(char *fname, int level_id, int draw);
+void new_level(const char *fname, int level_id, int draw);
 Tactor *get_alex();
 void draw_frame(BITMAP *bmp, int draw_status_bar);
 void blit_to_screen(BITMAP *bmp);
--- a/src/shooter.c
+++ b/src/shooter.c
@@ -321,7 +321,7 @@
 	s_stop_music();
 
 	{
-		s_music_vol = (float)(get_config_int("sound", "music_volume", 255)) / 255.0;
+		s_music_vol = (get_config_int("sound", "music_volume", 255) * 1.0) / 255.0;
 		s_sr = dumb_it_start_at_order(s_duh, n_channels, startorder);
 		s_dp = al_duh_encapsulate_sigrenderer(s_sr, 
 			s_music_vol,
--- a/src/edit.c
+++ b/src/edit.c
@@ -44,7 +44,7 @@
 }
 
 // set the path for the current map
-void set_edit_path_and_file(char *str) {
+void set_edit_path_and_file(const char *str) {
 	strcpy(edit_path_and_file, str);
 	log2file("  edit path set to: <%s>", edit_path_and_file);
 }
--- a/src/edit.h
+++ b/src/edit.h
@@ -33,7 +33,7 @@
 // functions
 void set_edit_mode(int mode);
 char *get_edit_path_and_file();
-void set_edit_path_and_file(char *str);
+void set_edit_path_and_file(const char *str);
 void draw_edit_mode(BITMAP *bmp, Tmap *map, int mx, int my);
 void update_edit_mode(Tmap *map, BITMAP *bmp, int mx, int my, int mb);
 
--- a/src/hisc.c
+++ b/src/hisc.c
@@ -84,7 +84,7 @@
 }
 
 // Resets the table to the values specified
-void reset_hisc_table(Thisc *table, char *name, int hi, int lo) {
+void reset_hisc_table(Thisc *table, const char *name, int hi, int lo) {
 	int i;
 	int d = (hi-lo)/(MAX_SCORES - 1);
 	int acc = lo;
--- a/src/hisc.h
+++ b/src/hisc.h
@@ -41,7 +41,7 @@
 int qualify_hisc_table(Thisc *table, Thisc post);
 void sort_hisc_table(Thisc *table);
 void enter_hisc_table(Thisc *table, Thisc post);
-void reset_hisc_table(Thisc *table, char *name, int hi, int lo);
+void reset_hisc_table(Thisc *table, const char *name, int hi, int lo);
 int load_hisc_table(Thisc *table, PACKFILE *fp);
 void save_hisc_table(Thisc *table, PACKFILE *fp);
 
--- a/src/map.c
+++ b/src/map.c
@@ -102,7 +102,7 @@
 }
 
 // loads one splendind map from disk
-Tmap *load_map(char *fname) {
+Tmap *load_map(const char *fname) {
 	Tmap *m;
 	FILE *fp;
     char header[6];
--- a/src/map.h
+++ b/src/map.h
@@ -93,7 +93,7 @@
 // functions
 Tmap *create_map(int w, int h);
 void destroy_map(Tmap *m);
-Tmap *load_map(char *fname);
+Tmap *load_map(const char *fname);
 Tmap *load_map_from_memory(void *mem);
 int save_map(Tmap *m, char *fname);
 void change_map_size(Tmap *m, int dw, int dh, int dir_flags);
--- a/src/token.h
+++ b/src/token.h
@@ -32,7 +32,7 @@
 
 
 // functions
-Ttoken *create_token(char *word);
+Ttoken *create_token(const char *word);
 void destroy_token(Ttoken *t);
 void flush_tokens(Ttoken *head);
 void insert_token(Ttoken *list, Ttoken *t);