From 07c89a8473efd4b1537ec0516430a9165a2801f6 Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Tue, 27 Oct 2020 01:17:49 +0800 Subject: [PATCH] Fix IS_PERIPH_ADDR() and IS_MEMORY_ADDR() macros The macros assume that constants that are compared against "addr" are either unsigned or less than INT_MAX. In some cases it is not true so change costants to unsigned using U32_C macros. The correct solution would be to change teh MEM_ADDR, PMM_BASE, etc. to be unsigned long but currently "U" suffix is appended in various places so the assumption is that those macros use default definition (which is int). Put "addr" into brackets by the way since it could be an expression rather than one variable. Signed-off-by: Zbigniew Bodek Change-Id: Ife9bc5863b4934ecaab64b24faa084b87d7d7ea5 --- kernel/base/include/los_vm_iomap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/base/include/los_vm_iomap.h b/kernel/base/include/los_vm_iomap.h index f73aa89a..1b492510 100644 --- a/kernel/base/include/los_vm_iomap.h +++ b/kernel/base/include/los_vm_iomap.h @@ -46,8 +46,8 @@ enum DmaMemType { DMA_NOCACHE }; -#define IS_PERIPH_ADDR(addr) ((addr >= PERIPH_PMM_BASE) && (addr <= PERIPH_PMM_BASE + PERIPH_PMM_SIZE)) -#define IS_MEMORY_ADDR(addr) ((addr >= DDR_MEM_ADDR) && (addr <= DDR_MEM_ADDR + DDR_MEM_SIZE)) +#define IS_PERIPH_ADDR(addr) (((addr) >= U32_C(PERIPH_PMM_BASE)) && ((addr) <= U32_C(PERIPH_PMM_BASE) + U32_C(PERIPH_PMM_SIZE))) +#define IS_MEMORY_ADDR(addr) (((addr) >= U32_C(DDR_MEM_ADDR)) && ((addr) <= U32_C(DDR_MEM_ADDR) + U32_C(DDR_MEM_SIZE))) /* thread safety */ VOID *LOS_DmaMemAlloc(DMA_ADDR_T *dmaAddr, size_t size, size_t align, enum DmaMemType type);