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/tagcache.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/tagcache.c')
-rw-r--r-- | apps/tagcache.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index df252ca0bc..2b3c7212a2 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -930,7 +930,7 @@ inline static bool str_oneof(const char *str, const char *list) | |||
930 | while (*list) | 930 | while (*list) |
931 | { | 931 | { |
932 | sep = strchr(list, '|'); | 932 | sep = strchr(list, '|'); |
933 | l = sep ? (long)sep - (long)list : (int)strlen(list); | 933 | l = sep ? (intptr_t)sep - (intptr_t)list : (int)strlen(list); |
934 | if ((l==len) && !strncasecmp(str, list, len)) | 934 | if ((l==len) && !strncasecmp(str, list, len)) |
935 | return true; | 935 | return true; |
936 | list += sep ? l + 1 : l; | 936 | list += sep ? l + 1 : l; |
@@ -2362,7 +2362,7 @@ static bool build_numeric_indices(struct tagcache_header *h, int tmpfd) | |||
2362 | /* Avoid processing this entry again. */ | 2362 | /* Avoid processing this entry again. */ |
2363 | idx.flag |= FLAG_RESURRECTED; | 2363 | idx.flag |= FLAG_RESURRECTED; |
2364 | 2364 | ||
2365 | lseek(masterfd, -sizeof(struct index_entry), SEEK_CUR); | 2365 | lseek(masterfd, -(off_t)sizeof(struct index_entry), SEEK_CUR); |
2366 | if (ecwrite_index_entry(masterfd, &idx) != sizeof(struct index_entry)) | 2366 | if (ecwrite_index_entry(masterfd, &idx) != sizeof(struct index_entry)) |
2367 | { | 2367 | { |
2368 | logf("masterfd writeback fail #1"); | 2368 | logf("masterfd writeback fail #1"); |
@@ -3432,7 +3432,7 @@ static int parse_changelog_line(int line_n, char *buf, void *parameters) | |||
3432 | struct index_entry idx; | 3432 | struct index_entry idx; |
3433 | char tag_data[TAG_MAXLEN+32]; | 3433 | char tag_data[TAG_MAXLEN+32]; |
3434 | int idx_id; | 3434 | int idx_id; |
3435 | long masterfd = (long)parameters; | 3435 | long masterfd = (long)(intptr_t)parameters; |
3436 | const int import_tags[] = { tag_playcount, tag_rating, tag_playtime, | 3436 | const int import_tags[] = { tag_playcount, tag_rating, tag_playtime, |
3437 | tag_lastplayed, tag_commitid, tag_lastelapsed, | 3437 | tag_lastplayed, tag_commitid, tag_lastelapsed, |
3438 | tag_lastoffset }; | 3438 | tag_lastoffset }; |
@@ -3526,7 +3526,7 @@ bool tagcache_import_changelog(void) | |||
3526 | 3526 | ||
3527 | filenametag_fd = open_tag_fd(&tch, tag_filename, false); | 3527 | filenametag_fd = open_tag_fd(&tch, tag_filename, false); |
3528 | 3528 | ||
3529 | fast_readline(clfd, buf, sizeof buf, (long *)masterfd, | 3529 | fast_readline(clfd, buf, sizeof buf, (void *)(intptr_t)masterfd, |
3530 | parse_changelog_line); | 3530 | parse_changelog_line); |
3531 | 3531 | ||
3532 | close(clfd); | 3532 | close(clfd); |
@@ -3665,7 +3665,7 @@ static bool delete_entry(long idx_id) | |||
3665 | } | 3665 | } |
3666 | 3666 | ||
3667 | myidx.flag |= FLAG_DELETED; | 3667 | myidx.flag |= FLAG_DELETED; |
3668 | lseek(masterfd, -sizeof(struct index_entry), SEEK_CUR); | 3668 | lseek(masterfd, -(off_t)sizeof(struct index_entry), SEEK_CUR); |
3669 | if (ecwrite_index_entry(masterfd, &myidx) != sizeof(struct index_entry)) | 3669 | if (ecwrite_index_entry(masterfd, &myidx) != sizeof(struct index_entry)) |
3670 | { | 3670 | { |
3671 | logf("delete_entry(): write_error #1"); | 3671 | logf("delete_entry(): write_error #1"); |