From e653d8054fe3c2313944a2a88f3ad7c374bd9b21 Mon Sep 17 00:00:00 2001 From: Erwin Janssen Date: Fri, 9 Sep 2016 03:19:19 +0200 Subject: [PATCH] Use `strcmp` in instead of `gvrender_comparestr`. `bsearch` is used in this function to find a string in a string array. It's not needed to pass the address of `tok` to the function, because `tok` is already a pointer. `gvrender_comparestr` should then cast the values to `(const char)` instead of `*(char**)`, because `s1` and `s2` are strings, not pointers to a string. With this change the function only calls `strcmp`, so passing `strcmp` to `bsearch` has the same effect and `gvrender_comparestr` can be removed. This gets rid of all the `-Wcast-qual` warnings as well. --- lib/gvc/gvrender.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index 8b0455d44..a41f9528a 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -185,11 +185,6 @@ pointf *gvrender_ptf_A(GVJ_t * job, pointf * af, pointf * AF, int n) return AF; } -static int gvrender_comparestr(const void *s1, const void *s2) -{ - return strcmp(*(char**)s1, *(char**)s2); -} - static void gvrender_resolve_color(gvrender_features_t * features, char *name, gvcolor_t * color) { @@ -202,8 +197,8 @@ static void gvrender_resolve_color(gvrender_features_t * features, if (!features->knowncolors || (bsearch - (&tok, features->knowncolors, features->sz_knowncolors, - sizeof(char *), gvrender_comparestr)) == NULL) { + (tok, features->knowncolors, features->sz_knowncolors, + sizeof(char *), (__compar_fn_t) strcmp)) == NULL) { /* if tok was not found in known_colors */ rc = colorxlate(name, color, features->color_type); if (rc != COLOR_OK) { -- 2.40.0