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 /lib/tlsf/src | |
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 'lib/tlsf/src')
-rw-r--r-- | lib/tlsf/src/tlsf.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/tlsf/src/tlsf.c b/lib/tlsf/src/tlsf.c index 6866f0c9b0..136c4152c0 100644 --- a/lib/tlsf/src/tlsf.c +++ b/lib/tlsf/src/tlsf.c | |||
@@ -54,6 +54,7 @@ | |||
54 | 54 | ||
55 | #include <stdio.h> | 55 | #include <stdio.h> |
56 | #include <string.h> | 56 | #include <string.h> |
57 | #include <stdint.h> | ||
57 | 58 | ||
58 | #ifndef TLSF_USE_LOCKS | 59 | #ifndef TLSF_USE_LOCKS |
59 | #define TLSF_USE_LOCKS (0) | 60 | #define TLSF_USE_LOCKS (0) |
@@ -462,7 +463,7 @@ size_t init_memory_pool(size_t mem_pool_size, void *mem_pool) | |||
462 | return -1; | 463 | return -1; |
463 | } | 464 | } |
464 | 465 | ||
465 | if (((unsigned long) mem_pool & PTR_MASK)) { | 466 | if (((intptr_t) mem_pool & PTR_MASK)) { |
466 | ERROR_MSG("init_memory_pool (): mem_pool must be aligned to a word\n"); | 467 | ERROR_MSG("init_memory_pool (): mem_pool must be aligned to a word\n"); |
467 | return -1; | 468 | return -1; |
468 | } | 469 | } |
@@ -522,7 +523,7 @@ size_t add_new_area(void *area, size_t area_size, void *mem_pool) | |||
522 | lb1 = ptr->end; | 523 | lb1 = ptr->end; |
523 | 524 | ||
524 | /* Merging the new area with the next physically contigous one */ | 525 | /* Merging the new area with the next physically contigous one */ |
525 | if ((unsigned long) ib1 == (unsigned long) lb0 + BHDR_OVERHEAD) { | 526 | if ((uintptr_t) ib1 == (uintptr_t) lb0 + BHDR_OVERHEAD) { |
526 | if (tlsf->area_head == ptr) { | 527 | if (tlsf->area_head == ptr) { |
527 | tlsf->area_head = ptr->next; | 528 | tlsf->area_head = ptr->next; |
528 | ptr = ptr->next; | 529 | ptr = ptr->next; |
@@ -543,7 +544,7 @@ size_t add_new_area(void *area, size_t area_size, void *mem_pool) | |||
543 | 544 | ||
544 | /* Merging the new area with the previous physically contigous | 545 | /* Merging the new area with the previous physically contigous |
545 | one */ | 546 | one */ |
546 | if ((unsigned long) lb1->ptr.buffer == (unsigned long) ib0) { | 547 | if ((intptr_t) lb1->ptr.buffer == (intptr_t) ib0) { |
547 | if (tlsf->area_head == ptr) { | 548 | if (tlsf->area_head == ptr) { |
548 | tlsf->area_head = ptr->next; | 549 | tlsf->area_head = ptr->next; |
549 | ptr = ptr->next; | 550 | ptr = ptr->next; |