From 69c20e88c4775989e05feb4031dbf1ee83bd0bad Mon Sep 17 00:00:00 2001 From: Ed J Date: Wed, 18 Dec 2024 16:30:11 +0000 Subject: [PATCH] remove unnecessary casts --- lib/PDL/Core/pdlaffine.c | 2 +- lib/PDL/Core/pdlapi.c | 37 ++++++++++++++++++------------------- lib/PDL/Core/pdlbroadcast.c | 2 +- lib/PDL/Core/pdlconv.c | 2 +- lib/PDL/Core/pdlcore.c | 2 +- lib/PDL/Core/pdlmagic.c | 4 ++-- lib/PDL/Core/pdlutil.c | 26 +++++++++++++------------- 7 files changed, 37 insertions(+), 38 deletions(-) diff --git a/lib/PDL/Core/pdlaffine.c b/lib/PDL/Core/pdlaffine.c index 18b79a2b7..c5c620383 100644 --- a/lib/PDL/Core/pdlaffine.c +++ b/lib/PDL/Core/pdlaffine.c @@ -112,7 +112,7 @@ pdl_transvtable pdl_affine_vtable = { pdl_error pdl_affine_new(pdl *PARENT,pdl *CHILD,PDL_Indx offset,PDL_Indx *dims,PDL_Indx dims_count, PDL_Indx *incs, PDL_Indx incs_count) { pdl_error PDL_err = {0, NULL, 0}; - pdl_trans *trans = (void *)pdl_create_trans(&pdl_affine_vtable); + pdl_trans *trans = pdl_create_trans(&pdl_affine_vtable); pdl_params_affine *params = trans->params; trans->pdls[0] = PARENT; trans->pdls[1] = CHILD; diff --git a/lib/PDL/Core/pdlapi.c b/lib/PDL/Core/pdlapi.c index 28192a7d2..c31e3d8bb 100644 --- a/lib/PDL/Core/pdlapi.c +++ b/lib/PDL/Core/pdlapi.c @@ -145,7 +145,7 @@ pdl *pdl_get_convertedpdl(pdl *old,int type) { pdl_error pdl_allocdata(pdl *it) { pdl_error PDL_err = {0, NULL, 0}; - PDLDEBUG_f(printf("pdl_allocdata %p, %"IND_FLAG", %d\n",(void*)it, it->nvals, + PDLDEBUG_f(printf("pdl_allocdata %p, %"IND_FLAG", %d\n",it, it->nvals, it->datatype)); if(it->nvals < 0) return pdl_make_error(PDL_EUSERERROR, "Tried to allocdata with %"IND_FLAG" values", it->nvals); @@ -206,7 +206,7 @@ pdl* pdl_pdlnew() { it->ntrans_children = 0; it->magic = 0; it->hdrsv = 0; - PDLDEBUG_f(printf("pdl_pdlnew %p (size=%zu)\n",(void*)it,sizeof(pdl))); + PDLDEBUG_f(printf("pdl_pdlnew %p (size=%zu)\n",it,sizeof(pdl))); return it; } @@ -242,7 +242,7 @@ pdl_error pdl_vafftrans_alloc(pdl *it) /* Recursive! */ void pdl_vafftrans_remove(pdl * it, char this_one) { - PDLDEBUG_f(printf("pdl_vafftrans_remove: %p, this_one=%d\n", (void*)it, (int)this_one)); + PDLDEBUG_f(printf("pdl_vafftrans_remove: %p, this_one=%d\n", it, (int)this_one)); PDL_DECL_CHILDLOOP(it); PDL_START_CHILDLOOP(it) pdl_trans *t = PDL_CHILDLOOP_THISCHILD(it); @@ -258,15 +258,15 @@ void pdl_vafftrans_remove(pdl * it, char this_one) to be called when the time is right */ pdl_error pdl__free(pdl *it) { pdl_error PDL_err = {0, NULL, 0}; - PDLDEBUG_f(printf("pdl__free %p\n",(void*)it)); + PDLDEBUG_f(printf("pdl__free %p\n",it)); PDL_CHKMAGIC(it); /* now check if magic is still there */ if (pdl__ismagic(it)) - PDLDEBUG_f(printf("%p is still magic\n",(void*)it);pdl__print_magic(it)); + PDLDEBUG_f(printf("%p is still magic\n",it);pdl__print_magic(it)); it->magicno = 0x42424245; - if (it->dims != it->def_dims) free((void*)it->dims); - if (it->dimincs != it->def_dimincs) free((void*)it->dimincs); - if (it->broadcastids != it->def_broadcastids) free((void*)it->broadcastids); + if (it->dims != it->def_dims) free(it->dims); + if (it->dimincs != it->def_dimincs) free(it->dimincs); + if (it->broadcastids != it->def_broadcastids) free(it->broadcastids); if (it->vafftrans) { pdl_vafftrans_free(it); } @@ -294,7 +294,7 @@ pdl_error pdl__free(pdl *it) { it->hdrsv = 0; } free(it); - PDLDEBUG_f(printf("pdl__free end %p\n",(void*)it)); + PDLDEBUG_f(printf("pdl__free end %p\n",it)); return PDL_err; } @@ -393,7 +393,7 @@ pdl_error pdl_destroytransform(pdl_trans *trans, int ensure, int recurse_count) destbuffer[j]->state &= ~PDL_DESTROYING; /* safe, set by us */ PDL_ACCUMERROR(PDL_err, pdl__destroy_recprotect(destbuffer[j], recurse_count+1)); } - PDLDEBUG_f(printf("pdl_destroytransform leaving %p\n", (void*)trans)); + PDLDEBUG_f(printf("pdl_destroytransform leaving %p\n", trans)); return PDL_err; } @@ -475,7 +475,7 @@ pdl_error pdl__destroy_recprotect(pdl *it, int recurse_count) { trans->vtable->npdls - trans->vtable->nparents > 1, recurse_count+1)); /* Here, this is a child but has no children - fall through to hard_destroy */ PDL_RETERROR(PDL_err, pdl__free(it)); - PDLDEBUG_f(printf("pdl_destroy end %p\n",(void*)it)); + PDLDEBUG_f(printf("pdl_destroy end %p\n",it)); return PDL_err; } @@ -752,7 +752,7 @@ pdl_error pdl_make_trans_mutual(pdl_trans *trans) } PDL_ACCUMERROR(PDL_err, pdl_destroytransform(trans,0,0)); } - PDLDEBUG_f(printf("make_trans_mutual exit %p\n",(void*)trans)); + PDLDEBUG_f(printf("make_trans_mutual exit %p\n",trans)); return PDL_err; } /* pdl_make_trans_mutual() */ @@ -802,7 +802,7 @@ pdl_error pdl__make_physical_recprotect(pdl *it, int recurse_count) { pdl_error PDL_err = {0, NULL, 0}; int i, vaffinepar=0; PDL_RECURSE_CHECK(recurse_count); - PDLDEBUG_f(printf("make_physical %p\n",(void*)it)); + PDLDEBUG_f(printf("make_physical %p\n",it)); pdl_trans *trans = it->trans_parent; PDL_CHKMAGIC(it); if ( @@ -833,8 +833,7 @@ pdl_error pdl_changed(pdl *it, int what, int recursing) { pdl_error PDL_err = {0, NULL, 0}; PDL_Indx i, j; PDLDEBUG_f( - printf("pdl_changed: entry for pdl %p recursing: %d, what=", - (void*)it,recursing); + printf("pdl_changed: entry for pdl %p recursing: %d, what=",it,recursing); pdl_dump_flags_fixspace(what,0,PDL_FLAGS_PDL); ); pdl_trans *trans = it->trans_parent; @@ -850,7 +849,7 @@ pdl_error pdl_changed(pdl *it, int what, int recursing) { && (what & PDL_PARENTDATACHANGED)) { if (it->vafftrans) { if (it->state & PDL_ALLOCATED) { - PDLDEBUG_f(printf("pdl_changed: calling writebackdata_vaffine (pdl %p)\n",(void*)it)); + PDLDEBUG_f(printf("pdl_changed: calling writebackdata_vaffine (pdl %p)\n",it)); PDL_ACCUMERROR(PDL_err, pdl_writebackdata_vaffine(it)); } CHANGED(it->vafftrans->from,what,0); @@ -872,7 +871,7 @@ pdl_error pdl_changed(pdl *it, int what, int recursing) { CHANGED(trans->pdls[j],what,1); PDL_END_CHILDLOOP(it) } - PDLDEBUG_f(printf("pdl_changed: exiting for pdl %p\n",(void*)it)); + PDLDEBUG_f(printf("pdl_changed: exiting for pdl %p\n", it)); return PDL_err; } @@ -889,9 +888,9 @@ pdl_error pdl__make_physvaffine_recprotect(pdl *it, int recurse_count) { pdl_error PDL_err = {0, NULL, 0}; PDL_Indx i,j; - PDLDEBUG_f(printf("make_physvaffine %p calling ",(void*)it)); PDL_RETERROR(PDL_err, pdl__make_physdims_recprotect(it, recurse_count+1)); + PDLDEBUG_f(printf("make_physvaffine %p calling ",it)); PDL_RETERROR(PDL_err, pdl__make_physdims_recprotect(it, recurse_count+1)); if (!it->trans_parent || !(it->trans_parent->flags & PDL_ITRANS_ISAFFINE)) { - PDLDEBUG_f(printf("make_physvaffine handing off to make_physical %p\n",(void*)it)); + PDLDEBUG_f(printf("make_physvaffine handing off to make_physical %p\n",it)); return pdl__make_physical_recprotect(it, recurse_count+1); } if (!it->vafftrans || it->vafftrans->ndims < it->ndims) { diff --git a/lib/PDL/Core/pdlbroadcast.c b/lib/PDL/Core/pdlbroadcast.c index edbe7e732..643f9176c 100644 --- a/lib/PDL/Core/pdlbroadcast.c +++ b/lib/PDL/Core/pdlbroadcast.c @@ -342,7 +342,7 @@ pdl_error pdl_initbroadcaststruct(int nobl, char *flags_UNUSED /*CORE21*/, int noPthreadFlag ) { pdl_error PDL_err = {0, NULL, 0}; - PDLDEBUG_f(printf("initbroadcaststruct(%p)\n", (void*)broadcast)); + PDLDEBUG_f(printf("initbroadcaststruct(%p)\n", broadcast)); char already_alloced = (broadcast->magicno == PDL_BRC_MAGICNO && broadcast->gflags & PDL_BROADCAST_INITIALIZED); PDL_Indx already_nthr = already_alloced ? broadcast->mag_nthr : -1; diff --git a/lib/PDL/Core/pdlconv.c b/lib/PDL/Core/pdlconv.c index 41f8f808b..75c9bd74a 100644 --- a/lib/PDL/Core/pdlconv.c +++ b/lib/PDL/Core/pdlconv.c @@ -249,7 +249,7 @@ pdl_transvtable pdl_converttypei_vtable = { pdl_error pdl_converttypei_new(pdl *PARENT,pdl *CHILD,int totype) { pdl_error PDL_err = {0, NULL, 0}; - pdl_trans *trans = (void *)pdl_create_trans(&pdl_converttypei_vtable); + pdl_trans *trans = pdl_create_trans(&pdl_converttypei_vtable); pdl_params_converttypei *params = trans->params; trans->pdls[0] = PARENT; trans->pdls[1] = CHILD; diff --git a/lib/PDL/Core/pdlcore.c b/lib/PDL/Core/pdlcore.c index fec3a0b7d..79cda0688 100644 --- a/lib/PDL/Core/pdlcore.c +++ b/lib/PDL/Core/pdlcore.c @@ -201,7 +201,7 @@ PDL_Indx pdl_safe_indterm( PDL_Indx dsz, PDL_Indx at, char *file, int lineno) void* pdl_smalloc ( STRLEN nbytes ) { SV* work = sv_2mortal(newSVpv("", 0)); SvGROW( work, nbytes); - return (void *) SvPV_nolen(work); + return SvPV_nolen(work); } /*********** Stuff for barfing *************/ diff --git a/lib/PDL/Core/pdlmagic.c b/lib/PDL/Core/pdlmagic.c index c01be3ce2..5fe5ab3cd 100644 --- a/lib/PDL/Core/pdlmagic.c +++ b/lib/PDL/Core/pdlmagic.c @@ -89,7 +89,7 @@ void *pdl__call_magic(pdl *it,int which) if((*foo)->what & PDL_MAGIC_DELAYED) pdl_add_delayed_magic(*foo); else - ret = (void *)((*foo)->vtable->cast(*foo)); + ret = (*foo)->vtable->cast(*foo); /* Cast spell */ } foo = &((*foo)->next); @@ -114,7 +114,7 @@ pdl_magic *pdl__print_magic(pdl *it) { pdl_magic **foo = (pdl_magic **)(&(it->magic)); while(*foo) { - printf("Magic %p\ttype: ",(void*)(*foo)); + printf("Magic %p\ttype: ",*foo); if((*foo)->what & PDL_MAGIC_MARKCHANGED) printf("PDL_MAGIC_MARKCHANGED"); else if ((*foo)->what & PDL_MAGIC_THREADING) diff --git a/lib/PDL/Core/pdlutil.c b/lib/PDL/Core/pdlutil.c index 179f8cffa..536ac2723 100644 --- a/lib/PDL/Core/pdlutil.c +++ b/lib/PDL/Core/pdlutil.c @@ -155,7 +155,7 @@ PDL_TYPELIST_ALL(X) #undef X NULL }; - printf("DUMPBROADCAST %p\n",(void*)broadcast); + printf("DUMPBROADCAST %p\n",broadcast); if (broadcast->transvtable) { pdl_transvtable *vtable = broadcast->transvtable; psp; printf("Funcname: %s\n",vtable->name); @@ -248,7 +248,7 @@ PDL_TYPELIST_ALL(X) psp; printf("Realdims: "); pdl_print_iarr(broadcast->realdims,broadcast->npdls); printf("\n"); psp; printf("Pdls: ("); for (i=0;inpdls;i++) - printf("%s%p",(i?" ":""),(void*)(broadcast->pdls[i])); + printf("%s%p",(i?" ":""),(broadcast->pdls[i])); printf(")\n"); psp; printf("Per pdl flags: ("); for (i=0;inpdls;i++) @@ -406,7 +406,7 @@ PDL_LIST_FLAGS_PDLVTABLE(X) void pdl_dump_trans_fixspace (pdl_trans *it, int nspac) { PDL_Indx i; SET_SPACE(spaces, nspac); - printf("%sDUMPTRANS %p (%s)\n%s Flags: ",spaces,(void*)it,it->vtable->name,spaces); + printf("%sDUMPTRANS %p (%s)\n%s Flags: ",spaces,it,it->vtable->name,spaces); pdl_dump_flags_fixspace(it->flags,nspac+3, PDL_FLAGS_TRANS); printf("%s vtable flags ",spaces); pdl_dump_flags_fixspace(it->vtable->flags,nspac+3,PDL_FLAGS_VTABLE); @@ -429,10 +429,10 @@ void pdl_dump_trans_fixspace (pdl_trans *it, int nspac) { pdl_print_iarr(it->inc_sizes, it->vtable->nind_ids); printf("\n"); printf("%s INPUTS: (",spaces); for(i=0; ivtable->nparents; i++) - printf("%s%p",(i?" ":""),(void*)(it->pdls[i])); + printf("%s%p",(i?" ":""),(it->pdls[i])); printf(") OUTPUTS: ("); for(;ivtable->npdls; i++) - printf("%s%p",(i>it->vtable->nparents?" ":""),(void*)(it->pdls[i])); + printf("%s%p",(i>it->vtable->nparents?" ":""),(it->pdls[i])); printf(")\n"); } @@ -440,26 +440,26 @@ void pdl_dump_fixspace(pdl *it,int nspac) { PDL_DECL_CHILDLOOP(it) PDL_Indx i; SET_SPACE(spaces, nspac); - printf("%sDUMPING %p datatype: %d\n%s State: ",spaces,(void*)it,it->datatype,spaces); + printf("%sDUMPING %p datatype: %d\n%s State: ",spaces,it,it->datatype,spaces); pdl_dump_flags_fixspace(it->state,nspac+3,PDL_FLAGS_PDL); printf("%s transvtable: %p, trans: %p, sv: %p\n",spaces, - (void*)(it->trans_parent?it->trans_parent->vtable:0), (void*)(it->trans_parent), (void*)(it->sv)); + it->trans_parent?it->trans_parent->vtable:0, it->trans_parent, it->sv); if (it->datasv) printf("%s datasv: %p, Svlen: %lld, refcnt: %lld\n", spaces, - (void*)it->datasv, (long long)SvCUR((SV*)it->datasv), (long long)SvREFCNT((SV*)it->datasv)); + it->datasv, (long long)SvCUR((SV*)it->datasv), (long long)SvREFCNT((SV*)it->datasv)); if (it->data) printf("%s data: %p, nbytes: %"IND_FLAG", nvals: %"IND_FLAG"\n", spaces, - (void*)(it->data), it->nbytes, it->nvals); + it->data, it->nbytes, it->nvals); if (it->hdrsv) printf("%s hdrsv: %p, reftype %s\n", spaces, - (void*)it->hdrsv, sv_reftype((SV*)it->hdrsv, TRUE)); - printf("%s Dims: %p ",spaces,(void*)it->dims); + it->hdrsv, sv_reftype((SV*)it->hdrsv, TRUE)); + printf("%s Dims: %p ",spaces,it->dims); pdl_print_iarr(it->dims, it->ndims); - printf("\n%s BroadcastIds: %p ",spaces,(void*)(it->broadcastids)); + printf("\n%s BroadcastIds: %p ",spaces,it->broadcastids); pdl_print_iarr(it->broadcastids, it->nbroadcastids); if (it->vafftrans) { printf("\n%s Vafftrans: %p (parent), o:%"IND_FLAG", i:", - spaces,(void*)(it->vafftrans->from),it->vafftrans->offs); + spaces,it->vafftrans->from,it->vafftrans->offs); pdl_print_iarr(PDL_REPRINCS(it), it->vafftrans->ndims); } if (it->state & PDL_BADVAL) {