wcolorpanel.c Removed hsbInit warnings
commit1f80c820917e67f2adb072d1864dbfb9b1732b3a
authorRodolfo García Peñas (kix) <kix@kix.es>
Wed, 19 Jun 2019 19:10:58 +0000 (19 21:10 +0200)
committerCarlos R. Mafra <crmafra@gmail.com>
Thu, 20 Jun 2019 21:04:31 +0000 (20 22:04 +0100)
tree6e4a71b084b6181f06745713d0374c46cf5432a2
parentfb5f6c30c01ecf6f4e92d7ac6a6054fc83777345
wcolorpanel.c Removed hsbInit warnings

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