summaryrefslogtreecommitdiff
path: root/src/Color.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Color.c')
-rw-r--r--src/Color.c14
1 files changed, 7 insertions, 7 deletions
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;
}