summaryrefslogtreecommitdiff
path: root/apps/plugins/doom/p_saveg.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-01-16 00:10:38 +0100
committerGerrit Rockbox <gerrit@rockbox.org>2017-02-04 17:24:47 +0100
commitd7871914acd2ed77f43344e36e08944524a67d9e (patch)
tree7bcef243d9b53c3703c305b8a5f9f8a8488eabfb /apps/plugins/doom/p_saveg.c
parent1245c5fe61f6ca8e1980a33a8b8f7ea4322829fd (diff)
Fix dangerous casts
On Windows 64-bit, the size of long is 32-bit, thus any pointer to long cast is not valid. In any case, one should use intptr_t and ptrdiff_t when casting to integers. This commit attempts to fix all instances reported by GCC. When relevant, I replaced code by the macros PTR_ADD, ALIGN_UP from system.h Change-Id: I2273b0e8465d3c4689824717ed5afa5ed238a2dc
Diffstat (limited to 'apps/plugins/doom/p_saveg.c')
-rw-r--r--apps/plugins/doom/p_saveg.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/apps/plugins/doom/p_saveg.c b/apps/plugins/doom/p_saveg.c
index a704bfa83c..891b3b0503 100644
--- a/apps/plugins/doom/p_saveg.c
+++ b/apps/plugins/doom/p_saveg.c
@@ -44,7 +44,7 @@ byte *save_p;
// Pads save_p to a 4-byte boundary
// so that the load/save works on SGI&Gecko.
-#define PADSAVEP() do { save_p += (4 - ((unsigned long) save_p & 3)) & 3; } while (0)
+#define PADSAVEP() do { save_p += (4 - ((intptr_t) save_p & 3)) & 3; } while (0)
//
// P_ArchivePlayers
//
@@ -95,7 +95,7 @@ void P_UnArchivePlayers (void)
for (j=0 ; j<NUMPSPRITES ; j++)
if (players[i]. psprites[j].state)
players[i]. psprites[j].state =
- &states[ (unsigned long)players[i].psprites[j].state ];
+ &states[ (intptr_t)players[i].psprites[j].state ];
}
}
@@ -270,7 +270,7 @@ void P_ThinkerToIndex(void)
number_of_thinkers = 0;
for (th = thinkercap.next ; th != &thinkercap ; th=th->next)
if (th->function == P_MobjThinker)
- th->prev = (thinker_t *)(long)(++number_of_thinkers);
+ th->prev = (thinker_t *)(intptr_t)(++number_of_thinkers);
}
// phares 9/13/98: Moved this code outside of P_ArchiveThinkers so the
@@ -448,10 +448,10 @@ void P_UnArchiveThinkers (void)
PADSAVEP();
memcpy (mobj, save_p, sizeof(mobj_t));
save_p += sizeof(mobj_t);
- mobj->state = states + (unsigned long) mobj->state;
+ mobj->state = states + (intptr_t) mobj->state;
if (mobj->player)
- (mobj->player = &players[(unsigned long) mobj->player - 1]) -> mo = mobj;
+ (mobj->player = &players[(intptr_t) mobj->player - 1]) -> mo = mobj;
P_SetThingPosition (mobj);
mobj->info = &mobjinfo[mobj->type];
@@ -770,7 +770,7 @@ void P_UnArchiveSpecials (void)
ceiling_t *ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL);
memcpy (ceiling, save_p, sizeof(*ceiling));
save_p += sizeof(*ceiling);
- ceiling->sector = &sectors[(unsigned long)ceiling->sector];
+ ceiling->sector = &sectors[(intptr_t)ceiling->sector];
ceiling->sector->ceilingdata = ceiling; //jff 2/22/98
if (ceiling->thinker.function)
@@ -787,10 +787,10 @@ void P_UnArchiveSpecials (void)
vldoor_t *door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL);
memcpy (door, save_p, sizeof(*door));
save_p += sizeof(*door);
- door->sector = &sectors[(unsigned long)door->sector];
+ door->sector = &sectors[(intptr_t)door->sector];
//jff 1/31/98 unarchive line remembered by door as well
- door->line = (long)door->line!=-1? &lines[(unsigned long)door->line] : NULL;
+ door->line = (intptr_t)door->line!=-1? &lines[(intptr_t)door->line] : NULL;
door->sector->ceilingdata = door; //jff 2/22/98
door->thinker.function = T_VerticalDoor;
@@ -804,7 +804,7 @@ void P_UnArchiveSpecials (void)
floormove_t *floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL);
memcpy (floor, save_p, sizeof(*floor));
save_p += sizeof(*floor);
- floor->sector = &sectors[(unsigned long)floor->sector];
+ floor->sector = &sectors[(intptr_t)floor->sector];
floor->sector->floordata = floor; //jff 2/22/98
floor->thinker.function = T_MoveFloor;
P_AddThinker (&floor->thinker);
@@ -817,7 +817,7 @@ void P_UnArchiveSpecials (void)
plat_t *plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL);
memcpy (plat, save_p, sizeof(*plat));
save_p += sizeof(*plat);
- plat->sector = &sectors[(unsigned long)plat->sector];
+ plat->sector = &sectors[(intptr_t)plat->sector];
plat->sector->floordata = plat; //jff 2/22/98
if (plat->thinker.function)
@@ -834,7 +834,7 @@ void P_UnArchiveSpecials (void)
lightflash_t *flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL);
memcpy (flash, save_p, sizeof(*flash));
save_p += sizeof(*flash);
- flash->sector = &sectors[(unsigned long)flash->sector];
+ flash->sector = &sectors[(intptr_t)flash->sector];
flash->thinker.function = T_LightFlash;
P_AddThinker (&flash->thinker);
break;
@@ -846,7 +846,7 @@ void P_UnArchiveSpecials (void)
strobe_t *strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL);
memcpy (strobe, save_p, sizeof(*strobe));
save_p += sizeof(*strobe);
- strobe->sector = &sectors[(unsigned long)strobe->sector];
+ strobe->sector = &sectors[(intptr_t)strobe->sector];
strobe->thinker.function = T_StrobeFlash;
P_AddThinker (&strobe->thinker);
break;
@@ -858,7 +858,7 @@ void P_UnArchiveSpecials (void)
glow_t *glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL);
memcpy (glow, save_p, sizeof(*glow));
save_p += sizeof(*glow);
- glow->sector = &sectors[(unsigned long)glow->sector];
+ glow->sector = &sectors[(intptr_t)glow->sector];
glow->thinker.function = T_Glow;
P_AddThinker (&glow->thinker);
break;
@@ -870,7 +870,7 @@ void P_UnArchiveSpecials (void)
fireflicker_t *flicker = Z_Malloc (sizeof(*flicker), PU_LEVEL, NULL);
memcpy (flicker, save_p, sizeof(*flicker));
save_p += sizeof(*flicker);
- flicker->sector = &sectors[(unsigned long)flicker->sector];
+ flicker->sector = &sectors[(intptr_t)flicker->sector];
flicker->thinker.function = T_FireFlicker;
P_AddThinker (&flicker->thinker);
break;
@@ -883,7 +883,7 @@ void P_UnArchiveSpecials (void)
elevator_t *elevator = Z_Malloc (sizeof(*elevator), PU_LEVEL, NULL);
memcpy (elevator, save_p, sizeof(*elevator));
save_p += sizeof(*elevator);
- elevator->sector = &sectors[(unsigned long)elevator->sector];
+ elevator->sector = &sectors[(intptr_t)elevator->sector];
elevator->sector->floordata = elevator; //jff 2/22/98
elevator->sector->ceilingdata = elevator; //jff 2/22/98
elevator->thinker.function = T_MoveElevator;