From 1f80c820917e67f2adb072d1864dbfb9b1732b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Wed, 19 Jun 2019 21:10:58 +0200 Subject: [PATCH] wcolorpanel.c Removed hsbInit warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch removes these warnings in the hsbInit function. wcolorpanel.c: In function ‘hsbInit’: wcolorpanel.c:3456:16: warning: ‘%u’ directive writing between 1 and 5 bytes into a region of size 4 [-Wformat-overflow=] sprintf(tmp, "%d", value[0]); ^~ wcolorpanel.c:3456:15: note: directive argument in the range [0, 65535] sprintf(tmp, "%d", value[0]); ^~~~ wcolorpanel.c:3456:2: note: ‘sprintf’ output between 2 and 6 bytes into a destination of size 4 sprintf(tmp, "%d", value[0]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ The problem is that the hue variable in the RHSVColor struct. This variable is not an integer, is a shor variable, so using the printf using the "%d" modifier spects an integer. Using a "%hu" prints a unsigned short value. typedef struct RHSVColor { unsigned short hue; /* 0-359 */ unsigned char saturation; /* 0-255 */ unsigned char value; /* 0-255 */ } RHSVColor; --- WINGs/wcolorpanel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index 9977aebd..561c0760 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -3453,7 +3453,7 @@ static void hsbInit(W_ColorPanel * panel) WMSetSliderValue(panel->hsbSaturationS, value[1]); WMSetSliderValue(panel->hsbBrightnessS, value[2]); - sprintf(tmp, "%d", value[0]); + sprintf(tmp, "%hu", value[0]); WMSetTextFieldText(panel->hsbHueT, tmp); sprintf(tmp, "%d", value[1]); WMSetTextFieldText(panel->hsbSaturationT, tmp);