Skip to content

Commit aa69541

Browse files
committed
Remove useless casts to (void *) in arguments of some system functions
The affected functions are: bsearch, memcmp, memcpy, memset, memmove, qsort, repalloc Reviewed-by: Corey Huinker <corey.huinker@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/fd9adf5d-b1aa-e82f-e4c7-263c30145807%40enterprisedb.com
1 parent d9d7fe6 commit aa69541

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+116
-119
lines changed

contrib/btree_gist/btree_bit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ gbt_bit_xfrm(bytea *leaf)
8484
while (sz < padded_sz)
8585
((char *) out)[sz++] = 0;
8686
SET_VARSIZE(out, padded_sz);
87-
memcpy((void *) VARDATA(out), (void *) VARBITS(leaf), VARBITBYTES(leaf));
87+
memcpy(VARDATA(out), VARBITS(leaf), VARBITBYTES(leaf));
8888
return out;
8989
}
9090

contrib/btree_gist/btree_interval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ gbt_intv_compress(PG_FUNCTION_ARGS)
157157
{
158158
Interval *key = DatumGetIntervalP(entry->key);
159159

160-
memcpy((void *) r, (void *) key, INTERVALSIZE);
161-
memcpy((void *) (r + INTERVALSIZE), (void *) key, INTERVALSIZE);
160+
memcpy(r, key, INTERVALSIZE);
161+
memcpy(r + INTERVALSIZE, key, INTERVALSIZE);
162162
}
163163
else
164164
{

contrib/btree_gist/btree_utils_num.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
8787

8888
Assert(tinfo->indexsize >= 2 * tinfo->size);
8989

90-
memcpy((void *) &r[0], leaf, tinfo->size);
91-
memcpy((void *) &r[tinfo->size], leaf, tinfo->size);
90+
memcpy(&r[0], leaf, tinfo->size);
91+
memcpy(&r[tinfo->size], leaf, tinfo->size);
9292
retval = palloc(sizeof(GISTENTRY));
9393
gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page,
9494
entry->offset, false);
@@ -184,7 +184,7 @@ gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_nin
184184
o.lower = &((GBT_NUMKEY *) out)[0];
185185
o.upper = &((GBT_NUMKEY *) out)[tinfo->size];
186186

187-
memcpy((void *) out, (void *) cur, 2 * tinfo->size);
187+
memcpy(out, cur, 2 * tinfo->size);
188188

189189
for (i = 1; i < numranges; i++)
190190
{
@@ -360,7 +360,7 @@ gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
360360
arr[i].t = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[i].key));
361361
arr[i].i = i;
362362
}
363-
qsort_arg((void *) &arr[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1, sizeof(Nsrt), (qsort_arg_comparator) tinfo->f_cmp, (void *) flinfo);
363+
qsort_arg(&arr[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1, sizeof(Nsrt), (qsort_arg_comparator) tinfo->f_cmp, flinfo);
364364

365365
/* We do simply create two parts */
366366

contrib/btree_gist/btree_utils_var.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,11 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
502502
varg.tinfo = tinfo;
503503
varg.collation = collation;
504504
varg.flinfo = flinfo;
505-
qsort_arg((void *) &arr[FirstOffsetNumber],
505+
qsort_arg(&arr[FirstOffsetNumber],
506506
maxoff - FirstOffsetNumber + 1,
507507
sizeof(Vsrt),
508508
gbt_vsrt_cmp,
509-
(void *) &varg);
509+
&varg);
510510

511511
/* We do simply create two parts */
512512

contrib/btree_gist/btree_uuid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ gbt_uuid_compress(PG_FUNCTION_ARGS)
110110

111111
retval = palloc(sizeof(GISTENTRY));
112112

113-
memcpy((void *) r, (void *) key, UUID_LEN);
114-
memcpy((void *) (r + UUID_LEN), (void *) key, UUID_LEN);
113+
memcpy(r, key, UUID_LEN);
114+
memcpy(r + UUID_LEN, key, UUID_LEN);
115115
gistentryinit(*retval, PointerGetDatum(r),
116116
entry->rel, entry->page,
117117
entry->offset, false);

contrib/citext/citext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ internal_citext_pattern_cmp(text *left, text *right, Oid collid)
8080
llen = strlen(lcstr);
8181
rlen = strlen(rcstr);
8282

83-
result = memcmp((void *) lcstr, (void *) rcstr, Min(llen, rlen));
83+
result = memcmp(lcstr, rcstr, Min(llen, rlen));
8484
if (result == 0)
8585
{
8686
if (llen < rlen)

contrib/hstore/hstore_gist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
436436
size_beta = hemdist(datum_r, _j, siglen);
437437
costvector[j - 1].cost = abs(size_alpha - size_beta);
438438
}
439-
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
439+
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
440440

441441
union_l = GETSIGN(datum_l);
442442
union_r = GETSIGN(datum_r);
@@ -465,7 +465,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
465465
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
466466
{
467467
if (!ISALLTRUE(datum_l))
468-
memset((void *) union_l, 0xff, siglen);
468+
memset(union_l, 0xff, siglen);
469469
}
470470
else
471471
{
@@ -481,7 +481,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
481481
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
482482
{
483483
if (!ISALLTRUE(datum_r))
484-
memset((void *) union_r, 0xff, siglen);
484+
memset(union_r, 0xff, siglen);
485485
}
486486
else
487487
{

contrib/hstore/hstore_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen)
365365
return l;
366366
}
367367

368-
qsort((void *) a, l, sizeof(Pairs), comparePairs);
368+
qsort(a, l, sizeof(Pairs), comparePairs);
369369

370370
/*
371371
* We can't use qunique here because we have some clean-up code to run on

contrib/intarray/_int_gist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ g_int_compress(PG_FUNCTION_ARGS)
243243
/*
244244
* shunt everything down to start at the right place
245245
*/
246-
memmove((void *) &dr[0], (void *) &dr[2 * j], 2 * (len - j) * sizeof(int32));
246+
memmove(&dr[0], &dr[2 * j], 2 * (len - j) * sizeof(int32));
247247
}
248248

249249
/*
@@ -260,7 +260,7 @@ g_int_compress(PG_FUNCTION_ARGS)
260260
min = ((int64) dr[i] - (int64) dr[i - 1]);
261261
cand = i;
262262
}
263-
memmove((void *) &dr[cand - 1], (void *) &dr[cand + 1], (len - cand - 1) * sizeof(int32));
263+
memmove(&dr[cand - 1], &dr[cand + 1], (len - cand - 1) * sizeof(int32));
264264
len -= 2;
265265
}
266266

@@ -542,7 +542,7 @@ g_int_picksplit(PG_FUNCTION_ARGS)
542542
pfree(union_d);
543543
costvector[i - 1].cost = fabsf((size_alpha - size_l) - (size_beta - size_r));
544544
}
545-
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
545+
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
546546

547547
/*
548548
* Now split up the regions between the two seeds. An important property

contrib/intarray/_int_tool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ isort(int32 *a, int len)
212212
{
213213
bool r = false;
214214

215-
qsort_arg(a, len, sizeof(int32), isort_cmp, (void *) &r);
215+
qsort_arg(a, len, sizeof(int32), isort_cmp, &r);
216216
return r;
217217
}
218218

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy