Skip to content

Commit

Permalink
remove unnecessary casts
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 18, 2024
1 parent ecd672c commit 69c20e8
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion lib/PDL/Core/pdlaffine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 18 additions & 19 deletions lib/PDL/Core/pdlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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() */

Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
}

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/PDL/Core/pdlbroadcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/PDL/Core/pdlconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/PDL/Core/pdlcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *************/
Expand Down
4 changes: 2 additions & 2 deletions lib/PDL/Core/pdlmagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions lib/PDL/Core/pdlutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;i<broadcast->npdls;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;i<broadcast->npdls;i++)
Expand Down Expand Up @@ -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);
Expand All @@ -429,37 +429,37 @@ 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; i<it->vtable->nparents; i++)
printf("%s%p",(i?" ":""),(void*)(it->pdls[i]));
printf("%s%p",(i?" ":""),(it->pdls[i]));
printf(") OUTPUTS: (");
for(;i<it->vtable->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");
}

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) {
Expand Down

0 comments on commit 69c20e8

Please sign in to comment.