mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
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
This commit is contained in:
parent
1245c5fe61
commit
d7871914ac
27 changed files with 69 additions and 66 deletions
|
|
@ -2082,7 +2082,7 @@ void deh_procSounds(DEHFILE *fpin, int fpout, char *line)
|
|||
S_sfx[indexnum].priority = (int)value;
|
||||
else
|
||||
if (!strcasecmp(key,deh_sfxinfo[3])) // Zero 1
|
||||
S_sfx[indexnum].link = (sfxinfo_t *)((long) value);
|
||||
S_sfx[indexnum].link = (sfxinfo_t *)((intptr_t) value);
|
||||
else
|
||||
if (!strcasecmp(key,deh_sfxinfo[4])) // Zero 2
|
||||
S_sfx[indexnum].pitch = (int)value;
|
||||
|
|
@ -2091,7 +2091,7 @@ void deh_procSounds(DEHFILE *fpin, int fpout, char *line)
|
|||
S_sfx[indexnum].volume = (int)value;
|
||||
else
|
||||
if (!strcasecmp(key,deh_sfxinfo[6])) // Zero 4
|
||||
S_sfx[indexnum].data = (void *) ((long) value); // killough 5/3/98: changed cast
|
||||
S_sfx[indexnum].data = (void *) ((intptr_t) value); // killough 5/3/98: changed cast
|
||||
else
|
||||
if (!strcasecmp(key,deh_sfxinfo[7])) // Neg. One 1
|
||||
S_sfx[indexnum].usefulness = (int)value;
|
||||
|
|
|
|||
|
|
@ -807,7 +807,7 @@ void D_DoomMainSetup(void)
|
|||
// for statistics driver
|
||||
extern void* statcopy;
|
||||
|
||||
statcopy = (void*)(long)atoi(myargv[p+1]);
|
||||
statcopy = (void*)(intptr_t)atoi(myargv[p+1]);
|
||||
printf ("External statistics registered.\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = §ors[(unsigned long)ceiling->sector];
|
||||
ceiling->sector = §ors[(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 = §ors[(unsigned long)door->sector];
|
||||
door->sector = §ors[(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 = §ors[(unsigned long)floor->sector];
|
||||
floor->sector = §ors[(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 = §ors[(unsigned long)plat->sector];
|
||||
plat->sector = §ors[(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 = §ors[(unsigned long)flash->sector];
|
||||
flash->sector = §ors[(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 = §ors[(unsigned long)strobe->sector];
|
||||
strobe->sector = §ors[(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 = §ors[(unsigned long)glow->sector];
|
||||
glow->sector = §ors[(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 = §ors[(unsigned long)flicker->sector];
|
||||
flicker->sector = §ors[(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 = §ors[(unsigned long)elevator->sector];
|
||||
elevator->sector = §ors[(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;
|
||||
|
|
|
|||
|
|
@ -252,8 +252,8 @@ void Z_Init(void)
|
|||
|
||||
// Align on cache boundary
|
||||
|
||||
zone = (memblock_t *) ((unsigned long)zonebase + CACHE_ALIGN -
|
||||
((unsigned long)zonebase & (CACHE_ALIGN-1)));
|
||||
zone = (memblock_t *) ((intptr_t)zonebase + CACHE_ALIGN -
|
||||
((intptr_t)zonebase & (CACHE_ALIGN-1)));
|
||||
|
||||
rover = zone; // Rover points to base of zone mem
|
||||
zone->next = zone->prev = zone; // Single node
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue