From 6df57a4e8bbc383f5844cdd9a9dd25d349714def Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 21 Oct 2020 17:04:26 -0700 Subject: [PATCH] remove unnecessary casts of calloc() return value calloc returns a void* which, in C, implicitly coerces to every other pointer type. --- cmd/tools/ccomps.c | 2 +- cmd/tools/gc.c | 2 +- cmd/tools/gml2gv.c | 2 +- cmd/tools/graph_generator.c | 4 ++-- cmd/tools/graphml2gv.c | 4 ++-- cmd/tools/gv2gxl.c | 2 +- cmd/tools/gxl2gv.c | 4 ++-- cmd/tools/tred.c | 2 +- lib/cgraph/agxbuf.c | 2 +- lib/common/ellipse.c | 4 ++-- lib/pathplan/visibility.c | 2 +- lib/xdot/xdot.c | 6 +++--- plugin/core/gvrender_core_json.c | 2 +- plugin/pango/gvgetfontlist_pango.c | 2 +- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmd/tools/ccomps.c b/cmd/tools/ccomps.c index 76e6c3a02..9ff360b7f 100644 --- a/cmd/tools/ccomps.c +++ b/cmd/tools/ccomps.c @@ -23,7 +23,7 @@ #include #include -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) #define NEW(t) malloc(sizeof(t)) typedef struct { diff --git a/cmd/tools/gc.c b/cmd/tools/gc.c index ce0c2de0d..30be271b9 100644 --- a/cmd/tools/gc.c +++ b/cmd/tools/gc.c @@ -25,7 +25,7 @@ #include #define NEW(t) malloc(sizeof(t)) -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) #include #include diff --git a/cmd/tools/gml2gv.c b/cmd/tools/gml2gv.c index 34e0057ea..b2146325b 100644 --- a/cmd/tools/gml2gv.c +++ b/cmd/tools/gml2gv.c @@ -22,7 +22,7 @@ #include -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) static int Verbose; static char* gname = ""; diff --git a/cmd/tools/graph_generator.c b/cmd/tools/graph_generator.c index a0f747b3a..faf11992d 100644 --- a/cmd/tools/graph_generator.c +++ b/cmd/tools/graph_generator.c @@ -290,8 +290,8 @@ constructSierpinski(int v1, int v2, int v3, int depth, vtx_data* graph) } -#define NEW(t) (t*)calloc((1),sizeof(t)) -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define NEW(t) calloc((1),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) void makeSierpinski(int depth, edgefn ef) { diff --git a/cmd/tools/graphml2gv.c b/cmd/tools/graphml2gv.c index 447b9e4d3..da32439c1 100644 --- a/cmd/tools/graphml2gv.c +++ b/cmd/tools/graphml2gv.c @@ -56,14 +56,14 @@ struct slist { }; #define NEW(t) malloc(sizeof(t)) -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) /* Round x up to next multiple of y, which is a power of 2 */ #define ROUND2(x,y) (((x) + ((y)-1)) & ~((y)-1)) static void pushString(slist ** stk, const char *s) { int sz = ROUND2(sizeof(slist) + strlen(s), sizeof(void *)); - slist *sp = (slist *) N_NEW(sz, char); + slist *sp = N_NEW(sz, char); strcpy(sp->buf, s); sp->next = *stk; *stk = sp; diff --git a/cmd/tools/gv2gxl.c b/cmd/tools/gv2gxl.c index 02bfbbba4..1e0b600d3 100644 --- a/cmd/tools/gv2gxl.c +++ b/cmd/tools/gv2gxl.c @@ -18,7 +18,7 @@ #define SMALLBUF 128 #define NEW(t) malloc(sizeof(t)) -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) #define EMPTY(s) ((s == 0) || (*s == '\0')) #define SLEN(s) (sizeof(s)-1) diff --git a/cmd/tools/gxl2gv.c b/cmd/tools/gxl2gv.c index 0ed306766..c34adfc63 100644 --- a/cmd/tools/gxl2gv.c +++ b/cmd/tools/gxl2gv.c @@ -49,14 +49,14 @@ struct slist { }; #define NEW(t) malloc(sizeof(t)) -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) /* Round x up to next multiple of y, which is a power of 2 */ #define ROUND2(x,y) (((x) + ((y)-1)) & ~((y)-1)) static void pushString(slist ** stk, const char *s) { int sz = ROUND2(sizeof(slist) + strlen(s), sizeof(void *)); - slist *sp = (slist *) N_NEW(sz, char); + slist *sp = N_NEW(sz, char); strcpy(sp->buf, s); sp->next = *stk; *stk = sp; diff --git a/cmd/tools/tred.c b/cmd/tools/tred.c index 3da9ab577..fc4c2f08a 100644 --- a/cmd/tools/tred.c +++ b/cmd/tools/tred.c @@ -28,7 +28,7 @@ #include #define NEW(t) malloc(sizeof(t)) -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) typedef struct { unsigned char on_stack; diff --git a/lib/cgraph/agxbuf.c b/lib/cgraph/agxbuf.c index 92a9927ca..f0155565f 100644 --- a/lib/cgraph/agxbuf.c +++ b/lib/cgraph/agxbuf.c @@ -18,7 +18,7 @@ #include #include -#define N_GNEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_GNEW(n,t) calloc((n),sizeof(t)) /* agxbinit: * Assume if init is non-null, hint = sizeof(init[]) diff --git a/lib/common/ellipse.c b/lib/common/ellipse.c index 4362990ce..be6c99f05 100644 --- a/lib/common/ellipse.c +++ b/lib/common/ellipse.c @@ -58,8 +58,8 @@ #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) -#define NEW(t) ((t*)calloc(1,sizeof(t))) -#define N_NEW(n,t) ((t*)calloc(n,sizeof(t))) +#define NEW(t) calloc(1,sizeof(t)) +#define N_NEW(n,t) calloc(n,sizeof(t)) #define PI 3.14159265358979323846 diff --git a/lib/pathplan/visibility.c b/lib/pathplan/visibility.c index 3a7ecdb91..83afb919d 100644 --- a/lib/pathplan/visibility.c +++ b/lib/pathplan/visibility.c @@ -35,7 +35,7 @@ static array2 allocArray(int V, int extra) COORD *p; arr = malloc((V + extra) * sizeof(COORD *)); - p = (COORD *) calloc(V * V, sizeof(COORD)); + p = calloc(V * V, sizeof(COORD)); for (i = 0; i < V; i++) { arr[i] = p; p += V; diff --git a/lib/xdot/xdot.c b/lib/xdot/xdot.c index f5d65e0a0..6b908eb3e 100644 --- a/lib/xdot/xdot.c +++ b/lib/xdot/xdot.c @@ -15,8 +15,8 @@ #include #include -#define NEW(t) (t*)calloc(1, sizeof(t)) -#define N_NEW(n,t) (t*)calloc((n), sizeof(t)) +#define NEW(t) calloc(1, sizeof(t)) +#define N_NEW(n,t) calloc((n), sizeof(t)) typedef struct { unsigned char *buf; /* start of buffer */ @@ -430,7 +430,7 @@ xdot *parseXDotFOn (char *s, drawfunc_t fns[], int sz, xdot* x) if (initcnt == 0) { bufsz = XDBSIZE; - ops = (char *) calloc(XDBSIZE, sz); + ops = calloc(XDBSIZE, sz); } else { ops = (char*)(x->ops); diff --git a/plugin/core/gvrender_core_json.c b/plugin/core/gvrender_core_json.c index 515aec7d2..104a65ee9 100644 --- a/plugin/core/gvrender_core_json.c +++ b/plugin/core/gvrender_core_json.c @@ -614,7 +614,7 @@ static Dtdisc_t intDisc = { 0 }; -#define NEW(t) (t*)calloc(1,sizeof(t)) +#define NEW(t) calloc(1,sizeof(t)) static int lookup (Dt_t* map, char* name) { diff --git a/plugin/pango/gvgetfontlist_pango.c b/plugin/pango/gvgetfontlist_pango.c index ec99cf21e..c6afc42aa 100644 --- a/plugin/pango/gvgetfontlist_pango.c +++ b/plugin/pango/gvgetfontlist_pango.c @@ -246,7 +246,7 @@ typedef struct { } availfont_t; #define NEW(t) malloc(sizeof(t)) -#define N_NEW(n,t) (t*)calloc((n),sizeof(t)) +#define N_NEW(n,t) calloc((n),sizeof(t)) static PostscriptAlias postscript_alias[] = { #include "ps_font_equiv.h" -- 2.40.0