helper/log: Fix build issue on MSYS2 and Cygwin
On MSYS2 (native) and Cygwin, the mallinfo struct uses 'size_t' instead
of 'int', which leads to a compile-time error with the current code.
Update the preprocessor logic so that Cygwin and MSYS2 builds use
the 'size_t' format specifier.
Checkpatch-ignore: COMMIT_LOG_LONG_LINE
Build error on MSYS2:
../src/helper/log.c: In function 'get_free_memory_space':
../src/helper/log.c:78:45: error: format '%d' expects argument of type 'int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
78 | snprintf(s, MEM_STR_LEN, " %d", info.fordblks);
| ~^ ~~~~~~~~~~~~~
| | |
| int size_t {aka long unsigned int}
| %ld
Change-Id: I18d772facba6426ab627fb45a6d50bfc19ec9c05
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/9479
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
This commit is contained in:
committed by
Antonio Borneo
parent
3d83e9546e
commit
b80f554fd9
@@ -75,7 +75,11 @@ static void get_free_memory_space(char *s)
|
||||
#elif defined(HAVE_MALLINFO)
|
||||
if (LOG_LEVEL_IS(LOG_LVL_DEBUG_MALLOC)) {
|
||||
struct mallinfo info = mallinfo();
|
||||
#if IS_CYGWIN
|
||||
snprintf(s, MEM_STR_LEN, " %zu", info.fordblks);
|
||||
#else
|
||||
snprintf(s, MEM_STR_LEN, " %d", info.fordblks);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user