Skip to content

Commit 8105818

Browse files
committed
Fixing cppcheck warnings for player.c
1 parent 4fb5bd1 commit 8105818

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SRC_PATH = .
1010
# Space-separated pkg-config libraries used by this project
1111
LIBS = sdl2 SDL2_mixer SDL2_image SDL2_gfx
1212
# General compiler flags
13-
COMPILE_FLAGS = -Wall -Wextra -Wpedantic -Wshadow
13+
COMPILE_FLAGS = -Wall -Wextra -Wpedantic -Wshadow -Wreturn-type -Wint-conversion -Wstrict-aliasing=2 -Wdouble-promotion
1414
# Additional release-specific flags
1515
RCOMPILE_FLAGS = -D NDEBUG -Ofast -g0 -s
1616
# Additional debug-specific flags

src/player.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ reInitPlayer(void)
8686
void
8787
updatePlayer(void)
8888
{
89-
int i;
9089
// unsigned char keydata; // evilo
9190

9291
// int isOnLadder=0; // evilo
@@ -99,9 +98,8 @@ updatePlayer(void)
9998
/* 5 - Dans le vide */
10099
int echelleCollide = -1;
101100
int platformCollide = -1;
102-
int platformCollideBlock = -1;
103101

104-
for (i = 0; i < MAX_LADDER; i++)
102+
for (size_t i = 0; i < MAX_LADDER; i++)
105103
{
106104
/* Si le joueur est sur une base (en bas) --> BAS */
107105
/* Si les pieds du joueur sont en haut de l'echelle --> HAUT */
@@ -129,7 +127,7 @@ updatePlayer(void)
129127
}
130128
}
131129

132-
for (i = 0; i < MAX_PLATFORMS; i++)
130+
for (size_t i = 0; i < MAX_PLATFORMS; i++)
133131
{
134132
if (pform[i].active)
135133
{
@@ -194,8 +192,8 @@ updatePlayer(void)
194192
int sortie = 0;
195193
while (sortie == 0)
196194
{
197-
platformCollideBlock = -1;
198-
for (i = 0; i < MAX_PLATFORMS; i++)
195+
int8_t platformCollideBlock = -1;
196+
for (size_t i = 0; i < MAX_PLATFORMS; i++)
199197
{
200198
if (pform[i].active)
201199
{
@@ -236,8 +234,8 @@ updatePlayer(void)
236234
int sortie = 0;
237235
while (sortie == 0)
238236
{
239-
platformCollideBlock = -1;
240-
for (i = 0; i < MAX_PLATFORMS; i++)
237+
int8_t platformCollideBlock = -1;
238+
for (size_t i = 0; i < MAX_PLATFORMS; i++)
241239
{
242240
if (pform[i].active)
243241
{
@@ -354,7 +352,7 @@ updatePlayer(void)
354352
{
355353
if (player.bonus_freeze == 0)
356354
{
357-
for (i = 0; i < MAX_BALL; i++)
355+
for (size_t i = 0; i < MAX_BALL; i++)
358356
{
359357
if (ball[i].active)
360358
{
@@ -385,7 +383,7 @@ updatePlayer(void)
385383
}
386384

387385
/* Test des collisions avec les bonus */
388-
for (i = 0; i < MAX_BONUS; i++)
386+
for (size_t i = 0; i < MAX_BONUS; i++)
389387
{
390388
if (bonus[i].active)
391389
{

0 commit comments

Comments
 (0)