Codebase list alex4 / d318f49
Fix some more compiler warnings. git-svn-id: file:///svn/pkg-games/packages/trunk/alex4@11865 8808ee5c-780a-0410-9abb-a8188df92ce5 Peter Pentchev 13 years ago
4 changed file(s) with 330 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2121 * Convert the copyright file to the DEP 5 candidate format.
2222 * Convert all patch file headers to the DEP 3 format.
2323 * Build with -Werror if the non-standard "werror" build option is set.
24 * Add the compiler-warnings patch to fix some, well, compiler warnings.
2425
2526 -- Peter Pentchev <roam@ringlet.net> Wed, 09 Mar 2011 14:14:04 +0200
2627
0 Description: Fix some compiler warnings.
1 - mark a couple of function parameters as unused
2 - remove a couple of unused function parameters
3 - remove a couple of stray semicolons outside of functions
4 - define _XOPEN_SOURCE for strdup(3)
5 - constify a couple of character pointers
6 - replace some int -> float casts with a multiplication by 1.0
7 Forwarded: no
8 Author: Peter Pentchev <roam@ringlet.net>
9 Last-Update: 2011-03-09
10
11 --- a/src/main.c
12 +++ b/src/main.c
13 @@ -17,13 +17,14 @@
14 * http://www.gnu.org for license information. *
15 **************************************************************/
16
17 -
18 +#define _XOPEN_SOURCE 700
19
20 #include <allegro.h>
21 #include <aldumb.h>
22 #include <string.h>
23 #include <ctype.h>
24
25 +#include "defs.h"
26 #include "timer.h"
27 #include "map.h"
28 #include "control.h"
29 @@ -42,7 +43,6 @@
30
31 #include "../data/data.h"
32
33 -
34 // some game status defines
35 #define GS_OK 1
36 #define GS_GAMEOVER 2
37 @@ -153,7 +153,7 @@
38
39
40 // loggs the text to the text file
41 -void log2file(char *format, ...) {
42 +void log2file(const char *format, ...) {
43 va_list ptr; /* get an arg pointer */
44
45 if (log_fp) {
46 @@ -254,7 +254,7 @@
47
48
49 // shows a little message
50 -void msg_box(char *str) {
51 +void msg_box(const char *str) {
52 if (got_sound) al_pause_duh(dp);
53 alert("Alex 4: Message", NULL, str, "OK", NULL, 0, 0);
54 if (got_sound) al_resume_duh(dp);
55 @@ -306,7 +306,7 @@
56 {
57 sr = dumb_it_start_at_order(duh, n_channels, startorder);
58 dp = al_duh_encapsulate_sigrenderer(sr,
59 - ((float)(get_config_int("sound", "music_volume", 255)) / 255.0),
60 + ((get_config_int("sound", "music_volume", 255) * 1.0) / 255.0),
61 get_config_int("dumb", "buffer_size", 4096),
62 get_config_int("dumb", "sound_freq", 44100));
63 if (!dp) duh_end_sigrenderer(sr); // howto.txt doesn't mention that this is necessary! dumb.txt does ...
64 @@ -565,7 +565,7 @@
65
66
67 // loads a sample from disk
68 -SAMPLE *load_path_sample(char *fname) {
69 +SAMPLE *load_path_sample(const char *fname) {
70 char buf[1024];
71 SAMPLE *s;
72 sprintf(buf, "%s/%s", get_config_string("sound", "sfx_path", "sfx"), fname);
73 @@ -581,7 +581,7 @@
74
75 // counts number of maps
76 // invoked when loading the map datafile
77 -void count_maps_callback(DATAFILE *d) {
78 +void count_maps_callback(DATAFILE *d __unused) {
79 num_levels ++;
80 }
81
82 @@ -1579,7 +1579,7 @@
83
84
85 // tidies up after a map has been used
86 -void deinit_map(Tmap *m) {
87 +void deinit_map(void) {
88 int i;
89
90 // stop any playing sounds
91 @@ -1724,7 +1724,7 @@
92 // starts a new level
93 // level_id < 0 -> load fname
94 // uses datafile map o/w
95 -void new_level(char *fname, int level_id, int draw) {
96 +void new_level(const char *fname, int level_id, int draw) {
97 int tox;
98 int i;
99 int x, y;
100 @@ -2367,7 +2367,7 @@
101
102
103 // play the game!
104 -int play(int level) {
105 +int play(void) {
106 int i;
107 int playing_go_music = 0;
108
109 @@ -2819,8 +2819,8 @@
110 draw_frame(swap_screen, 1);
111 blit_to_screen(swap_screen);
112 fade_in_pal(100);
113 - status = play(-1);
114 - deinit_map(map);
115 + status = play();
116 + deinit_map();
117 }
118 else {
119 log2file(" *** failed");
120 @@ -2877,10 +2877,10 @@
121
122 // actual game starts here
123 show_lets_go();
124 - status = play(level);
125 + status = play();
126 // done playing level
127
128 - deinit_map(map);
129 + deinit_map();
130
131 // act on different outcomes
132 if (status == GS_GAME_DIED) {
133 @@ -3112,7 +3112,7 @@
134 fclose(log_fp);
135
136 return 0;
137 -} END_OF_MAIN();
138 +} END_OF_MAIN()
139
140
141
142 --- /dev/null
143 +++ b/src/defs.h
144 @@ -0,0 +1,12 @@
145 +#ifndef _INCLUDED_DEFS_H
146 +#define _INCLUDED_DEFS_H
147 +
148 +#ifndef __unused
149 +#ifdef __GNUC__
150 +#define __unused __attribute__((unused))
151 +#else /* __GNUC__ */
152 +#define __unused
153 +#endif /* __GNUC__ */
154 +#endif /* __unused */
155 +
156 +#endif /* _INCLUDED */
157 --- a/src/particle.c
158 +++ b/src/particle.c
159 @@ -20,7 +20,7 @@
160
161
162
163 -
164 +#include "defs.h"
165 #include "particle.h"
166
167 // pointer to datafile
168 @@ -92,7 +92,7 @@
169 }
170
171 // updates particle with map
172 -void update_particle_with_map(Tparticle *p, Tmap *m) {
173 +void update_particle_with_map(Tparticle *p, Tmap *m __unused) {
174 update_particle(p);
175
176 /* bouncing algo removed
177 --- a/src/timer.c
178 +++ b/src/timer.c
179 @@ -30,7 +30,7 @@
180 lps = logic_count;
181 logic_count = 0;
182 }
183 -END_OF_FUNCTION(fps_counter);
184 +END_OF_FUNCTION(fps_counter)
185
186
187 // keeps track of internal game speed
188 @@ -38,7 +38,7 @@
189 cycle_count++;
190 game_count++;
191 }
192 -END_OF_FUNCTION(game_counter);
193 +END_OF_FUNCTION(game_counter)
194
195
196 // initiates the timers
197 --- a/src/token.c
198 +++ b/src/token.c
199 @@ -18,7 +18,7 @@
200 **************************************************************/
201
202
203 -
204 +#define _XOPEN_SOURCE 700
205
206 #include <stdio.h>
207 #include <string.h>
208 @@ -32,7 +32,7 @@
209 ////////////////////////////////////////////////////////////////
210
211 // creates a new token
212 -Ttoken *create_token(char *word) {
213 +Ttoken *create_token(const char *word) {
214 Ttoken *tok = malloc(sizeof(Ttoken));
215 if (tok != NULL) {
216 tok->word = strdup(word);
217 --- a/src/main.h
218 +++ b/src/main.h
219 @@ -63,13 +63,13 @@
220 // functions
221 char *get_init_string();
222 void textout_outline_center(BITMAP *bmp, const char *txt, int cx, int y);
223 -void log2file(char *format, ...);
224 +void log2file(const char *format, ...);
225 int do_pause_menu(BITMAP *bg);
226 void take_screenshot(BITMAP *bmp);
227 void set_map(Tmap *m);
228 -void msg_box(char *str);
229 +void msg_box(const char *str);
230 void new_game(int reset_player_data);
231 -void new_level(char *fname, int level_id, int draw);
232 +void new_level(const char *fname, int level_id, int draw);
233 Tactor *get_alex();
234 void draw_frame(BITMAP *bmp, int draw_status_bar);
235 void blit_to_screen(BITMAP *bmp);
236 --- a/src/shooter.c
237 +++ b/src/shooter.c
238 @@ -321,7 +321,7 @@
239 s_stop_music();
240
241 {
242 - s_music_vol = (float)(get_config_int("sound", "music_volume", 255)) / 255.0;
243 + s_music_vol = (get_config_int("sound", "music_volume", 255) * 1.0) / 255.0;
244 s_sr = dumb_it_start_at_order(s_duh, n_channels, startorder);
245 s_dp = al_duh_encapsulate_sigrenderer(s_sr,
246 s_music_vol,
247 --- a/src/edit.c
248 +++ b/src/edit.c
249 @@ -44,7 +44,7 @@
250 }
251
252 // set the path for the current map
253 -void set_edit_path_and_file(char *str) {
254 +void set_edit_path_and_file(const char *str) {
255 strcpy(edit_path_and_file, str);
256 log2file(" edit path set to: <%s>", edit_path_and_file);
257 }
258 --- a/src/edit.h
259 +++ b/src/edit.h
260 @@ -33,7 +33,7 @@
261 // functions
262 void set_edit_mode(int mode);
263 char *get_edit_path_and_file();
264 -void set_edit_path_and_file(char *str);
265 +void set_edit_path_and_file(const char *str);
266 void draw_edit_mode(BITMAP *bmp, Tmap *map, int mx, int my);
267 void update_edit_mode(Tmap *map, BITMAP *bmp, int mx, int my, int mb);
268
269 --- a/src/hisc.c
270 +++ b/src/hisc.c
271 @@ -84,7 +84,7 @@
272 }
273
274 // Resets the table to the values specified
275 -void reset_hisc_table(Thisc *table, char *name, int hi, int lo) {
276 +void reset_hisc_table(Thisc *table, const char *name, int hi, int lo) {
277 int i;
278 int d = (hi-lo)/(MAX_SCORES - 1);
279 int acc = lo;
280 --- a/src/hisc.h
281 +++ b/src/hisc.h
282 @@ -41,7 +41,7 @@
283 int qualify_hisc_table(Thisc *table, Thisc post);
284 void sort_hisc_table(Thisc *table);
285 void enter_hisc_table(Thisc *table, Thisc post);
286 -void reset_hisc_table(Thisc *table, char *name, int hi, int lo);
287 +void reset_hisc_table(Thisc *table, const char *name, int hi, int lo);
288 int load_hisc_table(Thisc *table, PACKFILE *fp);
289 void save_hisc_table(Thisc *table, PACKFILE *fp);
290
291 --- a/src/map.c
292 +++ b/src/map.c
293 @@ -102,7 +102,7 @@
294 }
295
296 // loads one splendind map from disk
297 -Tmap *load_map(char *fname) {
298 +Tmap *load_map(const char *fname) {
299 Tmap *m;
300 FILE *fp;
301 char header[6];
302 --- a/src/map.h
303 +++ b/src/map.h
304 @@ -93,7 +93,7 @@
305 // functions
306 Tmap *create_map(int w, int h);
307 void destroy_map(Tmap *m);
308 -Tmap *load_map(char *fname);
309 +Tmap *load_map(const char *fname);
310 Tmap *load_map_from_memory(void *mem);
311 int save_map(Tmap *m, char *fname);
312 void change_map_size(Tmap *m, int dw, int dh, int dir_flags);
313 --- a/src/token.h
314 +++ b/src/token.h
315 @@ -32,7 +32,7 @@
316
317
318 // functions
319 -Ttoken *create_token(char *word);
320 +Ttoken *create_token(const char *word);
321 void destroy_token(Ttoken *t);
322 void flush_tokens(Ttoken *head);
323 void insert_token(Ttoken *list, Ttoken *t);
22 save-some-cpu-cycles.patch
33 allegro-4.2.patch
44 fsf-address.patch
5 compiler-warnings.patch
66 CPPFLAGS:= $(shell dpkg-buildflags --get CPPFLAGS)
77 LDFLAGS:= $(shell dpkg-buildflags --get LDFLAGS)
88
9 CFLAGS+= -Wall
9 CFLAGS+= -Wall -W -Wbad-function-cast \
10 -Wcast-align -Wcast-qual -Wchar-subscripts -Winline \
11 -Wnested-externs -Wpointer-arith \
12 -Wredundant-decls -Wwrite-strings
1013 ifneq (,$(filter werror,$(DEB_BUILD_OPTIONS)))
1114 CFLAGS+= -Werror
1215 endif