From ae9cb306ef6fb6152452c59b74cd19657ee21498 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 13 Jun 2015 18:53:36 +0200 Subject: [PATCH] WINGs: fix non-portable int conversion for printf in font panel size handling The original code assumed that the (void *) type could be safely converted to an integer for the printf use, but it is not that simple, as pointed by gcc when compiling on 32-bits platforms, where pointers do not match anymore the long (%li) size. The new code now do the conversions by the rules, so the compiler knows what is happening and printf always gets the 'int' it expects. Signed-off-by: Christophe CURIS --- WINGs/wfontpanel.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/WINGs/wfontpanel.c b/WINGs/wfontpanel.c index 2d6f77f7..019c710d 100644 --- a/WINGs/wfontpanel.c +++ b/WINGs/wfontpanel.c @@ -699,8 +699,10 @@ static void typefaceClick(WMWidget * w, void *data) WMClearList(panel->sizLs); WM_ITERATE_ARRAY(face->sizes, size, i) { - if ((uintptr_t)size != 0) { - sprintf(buffer, "%li", (uintptr_t)size); + if (size != NULL) { + int size_int = (int) size; + + sprintf(buffer, "%i", size_int); WMAddListItem(panel->sizLs, buffer); } @@ -798,8 +800,11 @@ static void setFontPanelFontName(FontPanel * panel, const char *family, const ch WM_ITERATE_ARRAY(face->sizes, vsize, i) { char buffer[32]; - if ((uintptr_t)vsize != 0) { - sprintf(buffer, "%li", (uintptr_t)vsize); + + if (vsize != NULL) { + int size_int = (int) vsize; + + sprintf(buffer, "%i", size_int); WMAddListItem(panel->sizLs, buffer); }