commonlib/lz4_wrapper: Use correct casts to ensure valid calculations

Commit 09f2921b (cbfs: Add LZ4 in-place decompression support for
pre-RAM stages) breaks building cbfstool with gcc (Debian 4.9.2-10)
4.9.2 in Debian 8.3 (jessie) with a 32-bit user space. It works fine
in a 64-bit user space.

/home/joey/src/coreboot/src/commonlib/lz4_wrapper.c:164:18: note: in expansion of macro 'MIN'
    size_t size = MIN((uint32_t)b.size, dst + dstn - out);
/home/joey/src/coreboot/src/commonlib/include/commonlib/helpers.h:29:35: error: signed and unsigned type in conditional expression [-Werror=sign-compare]
 #define MIN(a,b) ((a) < (b) ? (a) : (b))

The problem is arithmetic on void*, so explicitly cast to the wanted
types as suggested by user *redi* in

Change-Id: I85bee25a69c432ef8bb934add7fd2e2e31f03662
Signed-off-by: Paul Menzel <>
Reviewed-by: Aaron Durbin <>
Tested-by: build bot (Jenkins)
1 file changed