File: compiler-warnings.patch

package info (click to toggle)
alex4 1.1-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,184 kB
  • sloc: ansic: 6,322; makefile: 27
file content (325 lines) | stat: -rw-r--r-- 8,379 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
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);