From: Matthew Fernandez Date: Sun, 29 Jan 2023 01:39:17 +0000 (-0800) Subject: gvpr colorxlate: use a char pointer for 'p' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c31fe81297410058d59f997be039878a053850ba;p=graphviz gvpr colorxlate: use a char pointer for 'p' It is not clear why this was an `unsigned char*`. Nothing in this function relies on unsigned semantics. Making it a `const char*` allows dropping various casts. --- diff --git a/lib/gvpr/actions.c b/lib/gvpr/actions.c index 14a201611..227490ff9 100644 --- a/lib/gvpr/actions.c +++ b/lib/gvpr/actions.c @@ -1047,7 +1047,6 @@ static int colorxlate(char *str, gvcolor_t * color, color_type_t target_type) { static hsvrgbacolor_t *last; - unsigned char *p; hsvrgbacolor_t fake; unsigned char c; double H, S, V, A, R, G, B; @@ -1059,13 +1058,12 @@ int colorxlate(char *str, gvcolor_t * color, color_type_t target_type) rc = COLOR_OK; for (; *str == ' '; str++); /* skip over any leading whitespace */ - p = (unsigned char *) str; + const char *p = str; /* test for rgb value such as: "#ff0000" or rgba value such as "#ff000080" */ a = 255; /* default alpha channel value=opaque in case not supplied */ - if (*p == '#' - && sscanf((char *) p, "#%2x%2x%2x%2x", &r, &g, &b, &a) >= 3) { + if (*p == '#' && sscanf(p, "#%2x%2x%2x%2x", &r, &g, &b, &a) >= 3) { switch (target_type) { case HSVA_DOUBLE: R = (double) r / 255.0;