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/lrcplayer.c | |
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/lrcplayer.c')
-rw-r--r-- | apps/plugins/lrcplayer.c | 16 |
1 files changed, 8 insertions, 8 deletions
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(); |