diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2017-01-16 00:10:38 +0100 |
---|---|---|
committer | Gerrit Rockbox <gerrit@rockbox.org> | 2017-02-04 17:24:47 +0100 |
commit | d7871914acd2ed77f43344e36e08944524a67d9e (patch) | |
tree | 7bcef243d9b53c3703c305b8a5f9f8a8488eabfb /apps/plugins | |
parent | 1245c5fe61f6ca8e1980a33a8b8f7ea4322829fd (diff) | |
download | rockbox-d7871914acd2ed77f43344e36e08944524a67d9e.tar.gz rockbox-d7871914acd2ed77f43344e36e08944524a67d9e.zip |
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')
-rw-r--r-- | apps/plugins/doom/d_deh.c | 4 | ||||
-rw-r--r-- | apps/plugins/doom/d_main.c | 2 | ||||
-rw-r--r-- | apps/plugins/doom/p_saveg.c | 30 | ||||
-rw-r--r-- | apps/plugins/doom/z_zone.c | 4 | ||||
-rw-r--r-- | apps/plugins/goban/util.c | 4 | ||||
-rw-r--r-- | apps/plugins/lib/simple_viewer.c | 2 | ||||
-rw-r--r-- | apps/plugins/lib/strncpy.c | 3 | ||||
-rw-r--r-- | apps/plugins/lrcplayer.c | 16 | ||||
-rw-r--r-- | apps/plugins/mikmod/mikmod_internals.h | 2 | ||||
-rw-r--r-- | apps/plugins/solitaire.c | 2 | ||||
-rw-r--r-- | apps/plugins/zxbox/snapshot.c | 2 | ||||
-rw-r--r-- | apps/plugins/zxbox/tapefile.c | 2 | ||||
-rw-r--r-- | apps/plugins/zxbox/z80.c | 2 |
13 files changed, 38 insertions, 37 deletions
diff --git a/apps/plugins/doom/d_deh.c b/apps/plugins/doom/d_deh.c index abdaeae9ae..1a399e3b49 100644 --- a/apps/plugins/doom/d_deh.c +++ b/apps/plugins/doom/d_deh.c | |||
@@ -2082,7 +2082,7 @@ void deh_procSounds(DEHFILE *fpin, int fpout, char *line) | |||
2082 | S_sfx[indexnum].priority = (int)value; | 2082 | S_sfx[indexnum].priority = (int)value; |
2083 | else | 2083 | else |
2084 | if (!strcasecmp(key,deh_sfxinfo[3])) // Zero 1 | 2084 | if (!strcasecmp(key,deh_sfxinfo[3])) // Zero 1 |
2085 | S_sfx[indexnum].link = (sfxinfo_t *)((long) value); | 2085 | S_sfx[indexnum].link = (sfxinfo_t *)((intptr_t) value); |
2086 | else | 2086 | else |
2087 | if (!strcasecmp(key,deh_sfxinfo[4])) // Zero 2 | 2087 | if (!strcasecmp(key,deh_sfxinfo[4])) // Zero 2 |
2088 | S_sfx[indexnum].pitch = (int)value; | 2088 | S_sfx[indexnum].pitch = (int)value; |
@@ -2091,7 +2091,7 @@ void deh_procSounds(DEHFILE *fpin, int fpout, char *line) | |||
2091 | S_sfx[indexnum].volume = (int)value; | 2091 | S_sfx[indexnum].volume = (int)value; |
2092 | else | 2092 | else |
2093 | if (!strcasecmp(key,deh_sfxinfo[6])) // Zero 4 | 2093 | if (!strcasecmp(key,deh_sfxinfo[6])) // Zero 4 |
2094 | S_sfx[indexnum].data = (void *) ((long) value); // killough 5/3/98: changed cast | 2094 | S_sfx[indexnum].data = (void *) ((intptr_t) value); // killough 5/3/98: changed cast |
2095 | else | 2095 | else |
2096 | if (!strcasecmp(key,deh_sfxinfo[7])) // Neg. One 1 | 2096 | if (!strcasecmp(key,deh_sfxinfo[7])) // Neg. One 1 |
2097 | S_sfx[indexnum].usefulness = (int)value; | 2097 | S_sfx[indexnum].usefulness = (int)value; |
diff --git a/apps/plugins/doom/d_main.c b/apps/plugins/doom/d_main.c index be45e6a37e..1afeffa502 100644 --- a/apps/plugins/doom/d_main.c +++ b/apps/plugins/doom/d_main.c | |||
@@ -807,7 +807,7 @@ void D_DoomMainSetup(void) | |||
807 | // for statistics driver | 807 | // for statistics driver |
808 | extern void* statcopy; | 808 | extern void* statcopy; |
809 | 809 | ||
810 | statcopy = (void*)(long)atoi(myargv[p+1]); | 810 | statcopy = (void*)(intptr_t)atoi(myargv[p+1]); |
811 | printf ("External statistics registered.\n"); | 811 | printf ("External statistics registered.\n"); |
812 | } | 812 | } |
813 | 813 | ||
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; | |||
44 | 44 | ||
45 | // Pads save_p to a 4-byte boundary | 45 | // Pads save_p to a 4-byte boundary |
46 | // so that the load/save works on SGI&Gecko. | 46 | // so that the load/save works on SGI&Gecko. |
47 | #define PADSAVEP() do { save_p += (4 - ((unsigned long) save_p & 3)) & 3; } while (0) | 47 | #define PADSAVEP() do { save_p += (4 - ((intptr_t) save_p & 3)) & 3; } while (0) |
48 | // | 48 | // |
49 | // P_ArchivePlayers | 49 | // P_ArchivePlayers |
50 | // | 50 | // |
@@ -95,7 +95,7 @@ void P_UnArchivePlayers (void) | |||
95 | for (j=0 ; j<NUMPSPRITES ; j++) | 95 | for (j=0 ; j<NUMPSPRITES ; j++) |
96 | if (players[i]. psprites[j].state) | 96 | if (players[i]. psprites[j].state) |
97 | players[i]. psprites[j].state = | 97 | players[i]. psprites[j].state = |
98 | &states[ (unsigned long)players[i].psprites[j].state ]; | 98 | &states[ (intptr_t)players[i].psprites[j].state ]; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
@@ -270,7 +270,7 @@ void P_ThinkerToIndex(void) | |||
270 | number_of_thinkers = 0; | 270 | number_of_thinkers = 0; |
271 | for (th = thinkercap.next ; th != &thinkercap ; th=th->next) | 271 | for (th = thinkercap.next ; th != &thinkercap ; th=th->next) |
272 | if (th->function == P_MobjThinker) | 272 | if (th->function == P_MobjThinker) |
273 | th->prev = (thinker_t *)(long)(++number_of_thinkers); | 273 | th->prev = (thinker_t *)(intptr_t)(++number_of_thinkers); |
274 | } | 274 | } |
275 | 275 | ||
276 | // phares 9/13/98: Moved this code outside of P_ArchiveThinkers so the | 276 | // phares 9/13/98: Moved this code outside of P_ArchiveThinkers so the |
@@ -448,10 +448,10 @@ void P_UnArchiveThinkers (void) | |||
448 | PADSAVEP(); | 448 | PADSAVEP(); |
449 | memcpy (mobj, save_p, sizeof(mobj_t)); | 449 | memcpy (mobj, save_p, sizeof(mobj_t)); |
450 | save_p += sizeof(mobj_t); | 450 | save_p += sizeof(mobj_t); |
451 | mobj->state = states + (unsigned long) mobj->state; | 451 | mobj->state = states + (intptr_t) mobj->state; |
452 | 452 | ||
453 | if (mobj->player) | 453 | if (mobj->player) |
454 | (mobj->player = &players[(unsigned long) mobj->player - 1]) -> mo = mobj; | 454 | (mobj->player = &players[(intptr_t) mobj->player - 1]) -> mo = mobj; |
455 | 455 | ||
456 | P_SetThingPosition (mobj); | 456 | P_SetThingPosition (mobj); |
457 | mobj->info = &mobjinfo[mobj->type]; | 457 | mobj->info = &mobjinfo[mobj->type]; |
@@ -770,7 +770,7 @@ void P_UnArchiveSpecials (void) | |||
770 | ceiling_t *ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL); | 770 | ceiling_t *ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL); |
771 | memcpy (ceiling, save_p, sizeof(*ceiling)); | 771 | memcpy (ceiling, save_p, sizeof(*ceiling)); |
772 | save_p += sizeof(*ceiling); | 772 | save_p += sizeof(*ceiling); |
773 | ceiling->sector = §ors[(unsigned long)ceiling->sector]; | 773 | ceiling->sector = §ors[(intptr_t)ceiling->sector]; |
774 | ceiling->sector->ceilingdata = ceiling; //jff 2/22/98 | 774 | ceiling->sector->ceilingdata = ceiling; //jff 2/22/98 |
775 | 775 | ||
776 | if (ceiling->thinker.function) | 776 | if (ceiling->thinker.function) |
@@ -787,10 +787,10 @@ void P_UnArchiveSpecials (void) | |||
787 | vldoor_t *door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL); | 787 | vldoor_t *door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL); |
788 | memcpy (door, save_p, sizeof(*door)); | 788 | memcpy (door, save_p, sizeof(*door)); |
789 | save_p += sizeof(*door); | 789 | save_p += sizeof(*door); |
790 | door->sector = §ors[(unsigned long)door->sector]; | 790 | door->sector = §ors[(intptr_t)door->sector]; |
791 | 791 | ||
792 | //jff 1/31/98 unarchive line remembered by door as well | 792 | //jff 1/31/98 unarchive line remembered by door as well |
793 | door->line = (long)door->line!=-1? &lines[(unsigned long)door->line] : NULL; | 793 | door->line = (intptr_t)door->line!=-1? &lines[(intptr_t)door->line] : NULL; |
794 | 794 | ||
795 | door->sector->ceilingdata = door; //jff 2/22/98 | 795 | door->sector->ceilingdata = door; //jff 2/22/98 |
796 | door->thinker.function = T_VerticalDoor; | 796 | door->thinker.function = T_VerticalDoor; |
@@ -804,7 +804,7 @@ void P_UnArchiveSpecials (void) | |||
804 | floormove_t *floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL); | 804 | floormove_t *floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL); |
805 | memcpy (floor, save_p, sizeof(*floor)); | 805 | memcpy (floor, save_p, sizeof(*floor)); |
806 | save_p += sizeof(*floor); | 806 | save_p += sizeof(*floor); |
807 | floor->sector = §ors[(unsigned long)floor->sector]; | 807 | floor->sector = §ors[(intptr_t)floor->sector]; |
808 | floor->sector->floordata = floor; //jff 2/22/98 | 808 | floor->sector->floordata = floor; //jff 2/22/98 |
809 | floor->thinker.function = T_MoveFloor; | 809 | floor->thinker.function = T_MoveFloor; |
810 | P_AddThinker (&floor->thinker); | 810 | P_AddThinker (&floor->thinker); |
@@ -817,7 +817,7 @@ void P_UnArchiveSpecials (void) | |||
817 | plat_t *plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL); | 817 | plat_t *plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL); |
818 | memcpy (plat, save_p, sizeof(*plat)); | 818 | memcpy (plat, save_p, sizeof(*plat)); |
819 | save_p += sizeof(*plat); | 819 | save_p += sizeof(*plat); |
820 | plat->sector = §ors[(unsigned long)plat->sector]; | 820 | plat->sector = §ors[(intptr_t)plat->sector]; |
821 | plat->sector->floordata = plat; //jff 2/22/98 | 821 | plat->sector->floordata = plat; //jff 2/22/98 |
822 | 822 | ||
823 | if (plat->thinker.function) | 823 | if (plat->thinker.function) |
@@ -834,7 +834,7 @@ void P_UnArchiveSpecials (void) | |||
834 | lightflash_t *flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL); | 834 | lightflash_t *flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL); |
835 | memcpy (flash, save_p, sizeof(*flash)); | 835 | memcpy (flash, save_p, sizeof(*flash)); |
836 | save_p += sizeof(*flash); | 836 | save_p += sizeof(*flash); |
837 | flash->sector = §ors[(unsigned long)flash->sector]; | 837 | flash->sector = §ors[(intptr_t)flash->sector]; |
838 | flash->thinker.function = T_LightFlash; | 838 | flash->thinker.function = T_LightFlash; |
839 | P_AddThinker (&flash->thinker); | 839 | P_AddThinker (&flash->thinker); |
840 | break; | 840 | break; |
@@ -846,7 +846,7 @@ void P_UnArchiveSpecials (void) | |||
846 | strobe_t *strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL); | 846 | strobe_t *strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL); |
847 | memcpy (strobe, save_p, sizeof(*strobe)); | 847 | memcpy (strobe, save_p, sizeof(*strobe)); |
848 | save_p += sizeof(*strobe); | 848 | save_p += sizeof(*strobe); |
849 | strobe->sector = §ors[(unsigned long)strobe->sector]; | 849 | strobe->sector = §ors[(intptr_t)strobe->sector]; |
850 | strobe->thinker.function = T_StrobeFlash; | 850 | strobe->thinker.function = T_StrobeFlash; |
851 | P_AddThinker (&strobe->thinker); | 851 | P_AddThinker (&strobe->thinker); |
852 | break; | 852 | break; |
@@ -858,7 +858,7 @@ void P_UnArchiveSpecials (void) | |||
858 | glow_t *glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL); | 858 | glow_t *glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL); |
859 | memcpy (glow, save_p, sizeof(*glow)); | 859 | memcpy (glow, save_p, sizeof(*glow)); |
860 | save_p += sizeof(*glow); | 860 | save_p += sizeof(*glow); |
861 | glow->sector = §ors[(unsigned long)glow->sector]; | 861 | glow->sector = §ors[(intptr_t)glow->sector]; |
862 | glow->thinker.function = T_Glow; | 862 | glow->thinker.function = T_Glow; |
863 | P_AddThinker (&glow->thinker); | 863 | P_AddThinker (&glow->thinker); |
864 | break; | 864 | break; |
@@ -870,7 +870,7 @@ void P_UnArchiveSpecials (void) | |||
870 | fireflicker_t *flicker = Z_Malloc (sizeof(*flicker), PU_LEVEL, NULL); | 870 | fireflicker_t *flicker = Z_Malloc (sizeof(*flicker), PU_LEVEL, NULL); |
871 | memcpy (flicker, save_p, sizeof(*flicker)); | 871 | memcpy (flicker, save_p, sizeof(*flicker)); |
872 | save_p += sizeof(*flicker); | 872 | save_p += sizeof(*flicker); |
873 | flicker->sector = §ors[(unsigned long)flicker->sector]; | 873 | flicker->sector = §ors[(intptr_t)flicker->sector]; |
874 | flicker->thinker.function = T_FireFlicker; | 874 | flicker->thinker.function = T_FireFlicker; |
875 | P_AddThinker (&flicker->thinker); | 875 | P_AddThinker (&flicker->thinker); |
876 | break; | 876 | break; |
@@ -883,7 +883,7 @@ void P_UnArchiveSpecials (void) | |||
883 | elevator_t *elevator = Z_Malloc (sizeof(*elevator), PU_LEVEL, NULL); | 883 | elevator_t *elevator = Z_Malloc (sizeof(*elevator), PU_LEVEL, NULL); |
884 | memcpy (elevator, save_p, sizeof(*elevator)); | 884 | memcpy (elevator, save_p, sizeof(*elevator)); |
885 | save_p += sizeof(*elevator); | 885 | save_p += sizeof(*elevator); |
886 | elevator->sector = §ors[(unsigned long)elevator->sector]; | 886 | elevator->sector = §ors[(intptr_t)elevator->sector]; |
887 | elevator->sector->floordata = elevator; //jff 2/22/98 | 887 | elevator->sector->floordata = elevator; //jff 2/22/98 |
888 | elevator->sector->ceilingdata = elevator; //jff 2/22/98 | 888 | elevator->sector->ceilingdata = elevator; //jff 2/22/98 |
889 | elevator->thinker.function = T_MoveElevator; | 889 | elevator->thinker.function = T_MoveElevator; |
diff --git a/apps/plugins/doom/z_zone.c b/apps/plugins/doom/z_zone.c index df00d6a9d7..d2b6111b60 100644 --- a/apps/plugins/doom/z_zone.c +++ b/apps/plugins/doom/z_zone.c | |||
@@ -252,8 +252,8 @@ void Z_Init(void) | |||
252 | 252 | ||
253 | // Align on cache boundary | 253 | // Align on cache boundary |
254 | 254 | ||
255 | zone = (memblock_t *) ((unsigned long)zonebase + CACHE_ALIGN - | 255 | zone = (memblock_t *) ((intptr_t)zonebase + CACHE_ALIGN - |
256 | ((unsigned long)zonebase & (CACHE_ALIGN-1))); | 256 | ((intptr_t)zonebase & (CACHE_ALIGN-1))); |
257 | 257 | ||
258 | rover = zone; // Rover points to base of zone mem | 258 | rover = zone; // Rover points to base of zone mem |
259 | zone->next = zone->prev = zone; // Single node | 259 | zone->next = zone->prev = zone; // Single node |
diff --git a/apps/plugins/goban/util.c b/apps/plugins/goban/util.c index bb78316346..206606a4bb 100644 --- a/apps/plugins/goban/util.c +++ b/apps/plugins/goban/util.c | |||
@@ -73,7 +73,7 @@ void metadata_summary (void) | |||
73 | void * | 73 | void * |
74 | align_buffer (void *buffer, size_t * buffer_size) | 74 | align_buffer (void *buffer, size_t * buffer_size) |
75 | { | 75 | { |
76 | unsigned int wasted = (-(long) buffer) & 3; | 76 | unsigned int wasted = (-(intptr_t) buffer) & 3; |
77 | 77 | ||
78 | if (!buffer || !buffer_size) | 78 | if (!buffer || !buffer_size) |
79 | { | 79 | { |
@@ -88,7 +88,7 @@ align_buffer (void *buffer, size_t * buffer_size) | |||
88 | 88 | ||
89 | *buffer_size -= wasted; | 89 | *buffer_size -= wasted; |
90 | 90 | ||
91 | return (void *) (((char *) buffer) + wasted); | 91 | return PTR_ADD(buffer, wasted); |
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | ||
diff --git a/apps/plugins/lib/simple_viewer.c b/apps/plugins/lib/simple_viewer.c index 06cc9c1a71..6927d84a96 100644 --- a/apps/plugins/lib/simple_viewer.c +++ b/apps/plugins/lib/simple_viewer.c | |||
@@ -69,7 +69,7 @@ static const char* get_next_line(const char *text, struct view_info *info) | |||
69 | w = 1; | 69 | w = 1; |
70 | #else | 70 | #else |
71 | unsigned short ch; | 71 | unsigned short ch; |
72 | n = ((long)rb->utf8decode(ptr, &ch) - (long)ptr); | 72 | n = ((intptr_t)rb->utf8decode(ptr, &ch) - (intptr_t)ptr); |
73 | if (rb->is_diacritic(ch, NULL)) | 73 | if (rb->is_diacritic(ch, NULL)) |
74 | w = 0; | 74 | w = 0; |
75 | else | 75 | else |
diff --git a/apps/plugins/lib/strncpy.c b/apps/plugins/lib/strncpy.c index 1b552ee15c..9ad3594287 100644 --- a/apps/plugins/lib/strncpy.c +++ b/apps/plugins/lib/strncpy.c | |||
@@ -41,13 +41,14 @@ QUICKREF | |||
41 | #include <limits.h> | 41 | #include <limits.h> |
42 | #include "plugin.h" | 42 | #include "plugin.h" |
43 | #include "_ansi.h" | 43 | #include "_ansi.h" |
44 | #include <stdint.h> | ||
44 | 45 | ||
45 | /*SUPPRESS 560*/ | 46 | /*SUPPRESS 560*/ |
46 | /*SUPPRESS 530*/ | 47 | /*SUPPRESS 530*/ |
47 | 48 | ||
48 | /* Nonzero if either X or Y is not aligned on a "long" boundary. */ | 49 | /* Nonzero if either X or Y is not aligned on a "long" boundary. */ |
49 | #define ROCKBOX_UNALIGNED(X, Y) \ | 50 | #define ROCKBOX_UNALIGNED(X, Y) \ |
50 | (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) | 51 | (((uintptr_t)X & (sizeof (long) - 1)) | ((uintptr_t)Y & (sizeof (long) - 1))) |
51 | 52 | ||
52 | #if LONG_MAX == 2147483647L | 53 | #if LONG_MAX == 2147483647L |
53 | #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) | 54 | #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) |
diff --git a/apps/plugins/lrcplayer.c b/apps/plugins/lrcplayer.c index 392e78e77f..c7f36968a1 100644 --- a/apps/plugins/lrcplayer.c +++ b/apps/plugins/lrcplayer.c | |||
@@ -545,7 +545,7 @@ static struct lrc_brpos *calc_brpos(struct lrc_line *lrc_line, int i) | |||
545 | c = rb->utf8seek(cr.str, 1); | 545 | c = rb->utf8seek(cr.str, 1); |
546 | w = 1; | 546 | w = 1; |
547 | #else | 547 | #else |
548 | c = ((long)rb->utf8decode(cr.str, &ch) - (long)cr.str); | 548 | c = ((intptr_t)rb->utf8decode(cr.str, &ch) - (intptr_t)cr.str); |
549 | if (rb->is_diacritic(ch, NULL)) | 549 | if (rb->is_diacritic(ch, NULL)) |
550 | w = 0; | 550 | w = 0; |
551 | else | 551 | else |
@@ -885,7 +885,7 @@ static bool parse_lrc_line(char *line, off_t file_offset) | |||
885 | lrc_line->time_start = (time/10)*10; | 885 | lrc_line->time_start = (time/10)*10; |
886 | lrc_line->old_time_start = lrc_line->time_start; | 886 | lrc_line->old_time_start = lrc_line->time_start; |
887 | add_lrc_line(lrc_line, NULL); | 887 | add_lrc_line(lrc_line, NULL); |
888 | file_offset += (long)tagend - (long)str; | 888 | file_offset += (intptr_t)tagend - (intptr_t)str; |
889 | str = tagend; | 889 | str = tagend; |
890 | } | 890 | } |
891 | if (!first_lrc_line) | 891 | if (!first_lrc_line) |
@@ -908,7 +908,7 @@ static bool parse_lrc_line(char *line, off_t file_offset) | |||
908 | if (!tagend) break; | 908 | if (!tagend) break; |
909 | *tagend = 0; | 909 | *tagend = 0; |
910 | time = get_time_value(tagstart+1, false, | 910 | time = get_time_value(tagstart+1, false, |
911 | file_offset + ((long)tagstart - (long)str)); | 911 | file_offset + ((intptr_t)tagstart - (intptr_t)str)); |
912 | *tagend++ = '>'; | 912 | *tagend++ = '>'; |
913 | if (time < 0) | 913 | if (time < 0) |
914 | { | 914 | { |
@@ -923,7 +923,7 @@ static bool parse_lrc_line(char *line, off_t file_offset) | |||
923 | return false; | 923 | return false; |
924 | nword++; | 924 | nword++; |
925 | } | 925 | } |
926 | file_offset += (long)tagend - (long)str; | 926 | file_offset += (intptr_t)tagend - (intptr_t)str; |
927 | tagstart = str = tagend; | 927 | tagstart = str = tagend; |
928 | time_start = time; | 928 | time_start = time; |
929 | } | 929 | } |
@@ -1159,7 +1159,7 @@ static int unsynchronize(char* tag, int len, bool *ff_found) | |||
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | if(ff_found) *ff_found = _ff_found; | 1161 | if(ff_found) *ff_found = _ff_found; |
1162 | return (long)wp - (long)tag; | 1162 | return (intptr_t)wp - (intptr_t)tag; |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | static int read_unsynched(int fd, void *buf, int len, bool *ff_found) | 1165 | static int read_unsynched(int fd, void *buf, int len, bool *ff_found) |
@@ -1471,7 +1471,7 @@ static void parse_id3v2(int fd) | |||
1471 | utf_decode = rb->utf16BEdecode; | 1471 | utf_decode = rb->utf16BEdecode; |
1472 | } | 1472 | } |
1473 | } | 1473 | } |
1474 | bytesread -= (long)p - (long)tag; | 1474 | bytesread -= (intptr_t)p - (intptr_t)tag; |
1475 | tag = p; | 1475 | tag = p; |
1476 | 1476 | ||
1477 | while ( bytesread > 0 | 1477 | while ( bytesread > 0 |
@@ -1529,7 +1529,7 @@ static void parse_id3v2(int fd) | |||
1529 | lrc_line->old_time_start = -1; | 1529 | lrc_line->old_time_start = -1; |
1530 | if(is_crlf) p += chsiz; | 1530 | if(is_crlf) p += chsiz; |
1531 | } | 1531 | } |
1532 | bytesread -= (long)p - (long)tag; | 1532 | bytesread -= (intptr_t)p - (intptr_t)tag; |
1533 | tag = p; | 1533 | tag = p; |
1534 | if(!add_lrc_line(lrc_line, utf8line)) | 1534 | if(!add_lrc_line(lrc_line, utf8line)) |
1535 | break; | 1535 | break; |
@@ -2922,7 +2922,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
2922 | #endif | 2922 | #endif |
2923 | 2923 | ||
2924 | lrc_buffer = rb->plugin_get_buffer(&lrc_buffer_size); | 2924 | lrc_buffer = rb->plugin_get_buffer(&lrc_buffer_size); |
2925 | lrc_buffer = (void *)(((long)lrc_buffer+3)&~3); /* 4 bytes aligned */ | 2925 | lrc_buffer = ALIGN_UP(lrc_buffer, 4); /* 4 bytes aligned */ |
2926 | lrc_buffer_size = (lrc_buffer_size - 4)&~3; | 2926 | lrc_buffer_size = (lrc_buffer_size - 4)&~3; |
2927 | 2927 | ||
2928 | reset_current_data(); | 2928 | reset_current_data(); |
diff --git a/apps/plugins/mikmod/mikmod_internals.h b/apps/plugins/mikmod/mikmod_internals.h index acd514ad39..78d7b52045 100644 --- a/apps/plugins/mikmod/mikmod_internals.h +++ b/apps/plugins/mikmod/mikmod_internals.h | |||
@@ -703,7 +703,7 @@ extern int Voice_Stopped_internal(SBYTE); | |||
703 | 703 | ||
704 | /*========== SIMD mixing helper functions =============*/ | 704 | /*========== SIMD mixing helper functions =============*/ |
705 | 705 | ||
706 | #define IS_ALIGNED_16(ptr) (!(((int)(ptr)) & 15)) | 706 | #define IS_ALIGNED_16(ptr) (!(((intptr_t)(ptr)) & 15)) |
707 | 707 | ||
708 | /* Altivec helper function */ | 708 | /* Altivec helper function */ |
709 | #if defined HAVE_ALTIVEC | 709 | #if defined HAVE_ALTIVEC |
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c index b5e982d208..b476fa11b4 100644 --- a/apps/plugins/solitaire.c +++ b/apps/plugins/solitaire.c | |||
@@ -1547,7 +1547,7 @@ static int load_game( void ) | |||
1547 | return -1; | 1547 | return -1; |
1548 | 1548 | ||
1549 | retval = 0; /* Assume good case */ | 1549 | retval = 0; /* Assume good case */ |
1550 | if( ( rb->lseek( fd, -sizeof( int ), SEEK_END ) == -((ssize_t)sizeof( int ))-1 ) | 1550 | if( ( rb->lseek( fd, -(off_t)sizeof( int ), SEEK_END ) == -((ssize_t)sizeof( int ))-1 ) |
1551 | || ( rb->read( fd, &checksum, sizeof( int ) ) < ((ssize_t)sizeof( int )) ) | 1551 | || ( rb->read( fd, &checksum, sizeof( int ) ) < ((ssize_t)sizeof( int )) ) |
1552 | || ( rb->lseek( fd, 0, SEEK_SET ) == -1 ) | 1552 | || ( rb->lseek( fd, 0, SEEK_SET ) == -1 ) |
1553 | || save_read( fd, &cur_card, sizeof( int ), &checksum ) | 1553 | || save_read( fd, &cur_card, sizeof( int ), &checksum ) |
diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c index 468f46667e..74845bac8e 100644 --- a/apps/plugins/zxbox/snapshot.c +++ b/apps/plugins/zxbox/snapshot.c | |||
@@ -362,7 +362,7 @@ static void read_compressed_data(SNFILE *fp, byte *start, unsigned size, | |||
362 | GET_DATA(ch); | 362 | GET_DATA(ch); |
363 | if(p + times > end) { | 363 | if(p + times > end) { |
364 | put_msg("Warning: Repeat parameter too large in snapshot"); | 364 | put_msg("Warning: Repeat parameter too large in snapshot"); |
365 | times = (int) ((long) end - (long) p); | 365 | times = (int) ((intptr_t) end - (intptr_t) p); |
366 | } | 366 | } |
367 | for(j = 0; j < times; j++) *p++ = ch; | 367 | for(j = 0; j < times; j++) *p++ = ch; |
368 | } | 368 | } |
diff --git a/apps/plugins/zxbox/tapefile.c b/apps/plugins/zxbox/tapefile.c index b030f8dab9..054cae1aba 100644 --- a/apps/plugins/zxbox/tapefile.c +++ b/apps/plugins/zxbox/tapefile.c | |||
@@ -216,7 +216,7 @@ static struct tzxblock tzxb[NUMBLOCKID] = { | |||
216 | }; | 216 | }; |
217 | 217 | ||
218 | 218 | ||
219 | #define PTRDIFF(pe, ps) ((int) (((long) (pe) - (long) (ps)) / sizeof(*pe))) | 219 | #define PTRDIFF(pe, ps) pe - ps |
220 | 220 | ||
221 | static char tzxheader[] = {'Z','X','T','a','p','e','!',0x1A}; | 221 | static char tzxheader[] = {'Z','X','T','a','p','e','!',0x1A}; |
222 | 222 | ||
diff --git a/apps/plugins/zxbox/z80.c b/apps/plugins/zxbox/z80.c index f6f1de7468..683584f471 100644 --- a/apps/plugins/zxbox/z80.c +++ b/apps/plugins/zxbox/z80.c | |||
@@ -48,7 +48,7 @@ static byte *a64kmalloc(int num64ksegs) | |||
48 | /*exit(1);*/ | 48 | /*exit(1);*/ |
49 | } | 49 | } |
50 | 50 | ||
51 | return (byte *) (( (long) bigmem & ~((long) 0xFFFF)) + 0x10000); | 51 | return (byte *) (( (intptr_t) bigmem & ~((intptr_t) 0xFFFF)) + 0x10000); |
52 | } | 52 | } |
53 | 53 | ||
54 | 54 | ||