From ea28ca1a2cce8e0d8e5a1f620a809384ed276c37 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Fri, 9 Sep 2022 16:51:01 -0400 Subject: use casts to reduce compiler warnings (no object change) Signed-off-by: Thomas E. Dickey --- src/Color.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Color.c') diff --git a/src/Color.c b/src/Color.c index 671d60b..1c48136 100644 --- a/src/Color.c +++ b/src/Color.c @@ -52,21 +52,21 @@ XRenderParseColor(Display *dpy, char *spec, XRenderColor *def) return 0; } c = *spec++; - *pShort <<= 4; + *pShort = (unsigned short) (*pShort << 4); if (c >= '0' && c <= '9') - *pShort |= c - '0'; + *pShort = (unsigned short) (*pShort | (c - '0')); /* assume string in lowercase else if (c >= 'A' && c <= 'F') *pShort |= c - ('A' - 10); */ else if (c >= 'a' && c <= 'f') - *pShort |= c - ('a' - 10); + *pShort = (unsigned short) (*pShort | (c - ('a' - 10))); else return 0; } if (n == 0) return 0; if (n < 4) { - *pShort = ((unsigned long)*pShort * 0xFFFF) / ((1 << n*4) - 1); + *pShort = (unsigned short) (((unsigned long)*pShort * 0xFFFF) / (unsigned long) ((1 << n*4) - 1)); } } def->red = elements[0]; @@ -87,8 +87,8 @@ XRenderParseColor(Display *dpy, char *spec, XRenderColor *def) def->blue = coreColor.blue; def->alpha = 0xffff; } - def->red = (def->red * def->alpha) / 0xffffU; - def->green = (def->green * def->alpha) / 0xffffU; - def->blue = (def->blue * def->alpha) / 0xffffU; + def->red = (unsigned short) ((unsigned) (def->red * def->alpha) / 0xffffU); + def->green = (unsigned short) ((unsigned) (def->green * def->alpha) / 0xffffU); + def->blue = (unsigned short) ((unsigned) (def->blue * def->alpha) / 0xffffU); return 1; } -- cgit v1.2.1