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.zip rockbox-d7871914acd2ed77f43344e36e08944524a67d9e.tar.gz rockbox-d7871914acd2ed77f43344e36e08944524a67d9e.tar.bz2 rockbox-d7871914acd2ed77f43344e36e08944524a67d9e.tar.xz | |
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 392e78e..c7f3696 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) c = rb->utf8seek(cr.str, 1); w = 1; #else - c = ((long)rb->utf8decode(cr.str, &ch) - (long)cr.str); + c = ((intptr_t)rb->utf8decode(cr.str, &ch) - (intptr_t)cr.str); if (rb->is_diacritic(ch, NULL)) w = 0; else @@ -885,7 +885,7 @@ static bool parse_lrc_line(char *line, off_t file_offset) lrc_line->time_start = (time/10)*10; lrc_line->old_time_start = lrc_line->time_start; add_lrc_line(lrc_line, NULL); - file_offset += (long)tagend - (long)str; + file_offset += (intptr_t)tagend - (intptr_t)str; str = tagend; } if (!first_lrc_line) @@ -908,7 +908,7 @@ static bool parse_lrc_line(char *line, off_t file_offset) if (!tagend) break; *tagend = 0; time = get_time_value(tagstart+1, false, - file_offset + ((long)tagstart - (long)str)); + file_offset + ((intptr_t)tagstart - (intptr_t)str)); *tagend++ = '>'; if (time < 0) { @@ -923,7 +923,7 @@ static bool parse_lrc_line(char *line, off_t file_offset) return false; nword++; } - file_offset += (long)tagend - (long)str; + file_offset += (intptr_t)tagend - (intptr_t)str; tagstart = str = tagend; time_start = time; } @@ -1159,7 +1159,7 @@ static int unsynchronize(char* tag, int len, bool *ff_found) } } if(ff_found) *ff_found = _ff_found; - return (long)wp - (long)tag; + return (intptr_t)wp - (intptr_t)tag; } static int read_unsynched(int fd, void *buf, int len, bool *ff_found) @@ -1471,7 +1471,7 @@ static void parse_id3v2(int fd) utf_decode = rb->utf16BEdecode; } } - bytesread -= (long)p - (long)tag; + bytesread -= (intptr_t)p - (intptr_t)tag; tag = p; while ( bytesread > 0 @@ -1529,7 +1529,7 @@ static void parse_id3v2(int fd) lrc_line->old_time_start = -1; if(is_crlf) p += chsiz; } - bytesread -= (long)p - (long)tag; + bytesread -= (intptr_t)p - (intptr_t)tag; tag = p; if(!add_lrc_line(lrc_line, utf8line)) break; @@ -2922,7 +2922,7 @@ enum plugin_status plugin_start(const void* parameter) #endif lrc_buffer = rb->plugin_get_buffer(&lrc_buffer_size); - lrc_buffer = (void *)(((long)lrc_buffer+3)&~3); /* 4 bytes aligned */ + lrc_buffer = ALIGN_UP(lrc_buffer, 4); /* 4 bytes aligned */ lrc_buffer_size = (lrc_buffer_size - 4)&~3; reset_current_data(); |