From c31fe81297410058d59f997be039878a053850ba Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 28 Jan 2023 17:39:17 -0800 Subject: [PATCH] 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. --- lib/gvpr/actions.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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; -- 2.40.0