Skip to content

Commit c6be3da

Browse files
committed
Remove no longer needed casts to Pointer
These casts used to be required when Pointer was char *, but now it's void * (commit 1b2bb50), so they are not needed anymore. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://www.postgresql.org/message-id/4154950a-47ae-4223-bd01-1235cc50e933%40eisentraut.org
1 parent 6bd469d commit c6be3da

File tree

12 files changed

+33
-33
lines changed

12 files changed

+33
-33
lines changed

contrib/btree_gist/btree_utils_var.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ typedef struct
4949
*/
5050
#define GBT_FREE_IF_COPY(ptr1, ptr2) \
5151
do { \
52-
if ((Pointer) (ptr1) != DatumGetPointer(ptr2)) \
52+
if ((ptr1) != DatumGetPointer(ptr2)) \
5353
pfree(ptr1); \
5454
} while (0)
5555

src/backend/access/heap/heaptoast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
569569
intnum_to_free;
570570
inti;
571571
Datumnew_values[MaxTupleAttributeNumber];
572-
Pointerfreeable_values[MaxTupleAttributeNumber];
572+
void *freeable_values[MaxTupleAttributeNumber];
573573

574574
/*
575575
* We can pass the caller's isnull array directly to heap_form_tuple, but
@@ -593,7 +593,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
593593
{
594594
new_value = detoast_external_attr(new_value);
595595
new_values[i] = PointerGetDatum(new_value);
596-
freeable_values[num_to_free++] = (Pointer) new_value;
596+
freeable_values[num_to_free++] = new_value;
597597
}
598598
}
599599
}

src/backend/catalog/aclchk.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,7 @@ object_aclmask_ext(Oid classid, Oid objectid, Oid roleid,
31253125
result = aclmask(acl, roleid, ownerId, mask, how);
31263126

31273127
/* if we have a detoasted copy, free it */
3128-
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
3128+
if (acl && acl != DatumGetPointer(aclDatum))
31293129
pfree(acl);
31303130

31313131
ReleaseSysCache(tuple);
@@ -3255,7 +3255,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
32553255
result = aclmask(acl, roleid, ownerId, mask, how);
32563256

32573257
/* if we have a detoasted copy, free it */
3258-
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
3258+
if (acl && acl != DatumGetPointer(aclDatum))
32593259
pfree(acl);
32603260

32613261
ReleaseSysCache(attTuple);
@@ -3362,7 +3362,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
33623362
result = aclmask(acl, roleid, ownerId, mask, how);
33633363

33643364
/* if we have a detoasted copy, free it */
3365-
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
3365+
if (acl && acl != DatumGetPointer(aclDatum))
33663366
pfree(acl);
33673367

33683368
ReleaseSysCache(tuple);
@@ -3454,7 +3454,7 @@ pg_parameter_aclmask(const char *name, Oid roleid, AclMode mask, AclMaskHow how)
34543454
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
34553455

34563456
/* if we have a detoasted copy, free it */
3457-
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
3457+
if (acl && acl != DatumGetPointer(aclDatum))
34583458
pfree(acl);
34593459

34603460
ReleaseSysCache(tuple);
@@ -3509,7 +3509,7 @@ pg_parameter_acl_aclmask(Oid acl_oid, Oid roleid, AclMode mask, AclMaskHow how)
35093509
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
35103510

35113511
/* if we have a detoasted copy, free it */
3512-
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
3512+
if (acl && acl != DatumGetPointer(aclDatum))
35133513
pfree(acl);
35143514

35153515
ReleaseSysCache(tuple);
@@ -3589,7 +3589,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
35893589
result = aclmask(acl, roleid, ownerId, mask, how);
35903590

35913591
/* if we have a detoasted copy, free it */
3592-
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
3592+
if (acl && acl != DatumGetPointer(aclDatum))
35933593
pfree(acl);
35943594

35953595
systable_endscan(scan);
@@ -3683,7 +3683,7 @@ pg_namespace_aclmask_ext(Oid nsp_oid, Oid roleid,
36833683
result = aclmask(acl, roleid, ownerId, mask, how);
36843684

36853685
/* if we have a detoasted copy, free it */
3686-
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
3686+
if (acl && acl != DatumGetPointer(aclDatum))
36873687
pfree(acl);
36883688

36893689
ReleaseSysCache(tuple);
@@ -3819,7 +3819,7 @@ pg_type_aclmask_ext(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how,
38193819
result = aclmask(acl, roleid, ownerId, mask, how);
38203820

38213821
/* if we have a detoasted copy, free it */
3822-
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
3822+
if (acl && acl != DatumGetPointer(aclDatum))
38233823
pfree(acl);
38243824

38253825
ReleaseSysCache(tuple);
@@ -4003,7 +4003,7 @@ pg_attribute_aclcheck_all_ext(Oid table_oid, Oid roleid,
40034003
attmask = aclmask(acl, roleid, ownerId, mode, ACLMASK_ANY);
40044004

40054005
/* if we have a detoasted copy, free it */
4006-
if ((Pointer) acl != DatumGetPointer(aclDatum))
4006+
if (acl != DatumGetPointer(aclDatum))
40074007
pfree(acl);
40084008
}
40094009

src/backend/catalog/pg_constraint.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
15441544
if (numkeys <= 0 || numkeys > INDEX_MAX_KEYS)
15451545
elog(ERROR, "foreign key constraint cannot have %d columns", numkeys);
15461546
memcpy(conkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
1547-
if ((Pointer) arr != DatumGetPointer(adatum))
1547+
if (arr != DatumGetPointer(adatum))
15481548
pfree(arr);/* free de-toasted copy, if any */
15491549

15501550
adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
@@ -1556,7 +1556,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
15561556
ARR_ELEMTYPE(arr) != INT2OID)
15571557
elog(ERROR, "confkey is not a 1-D smallint array");
15581558
memcpy(confkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
1559-
if ((Pointer) arr != DatumGetPointer(adatum))
1559+
if (arr != DatumGetPointer(adatum))
15601560
pfree(arr);/* free de-toasted copy, if any */
15611561

15621562
if (pf_eq_oprs)
@@ -1571,7 +1571,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
15711571
ARR_ELEMTYPE(arr) != OIDOID)
15721572
elog(ERROR, "conpfeqop is not a 1-D Oid array");
15731573
memcpy(pf_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
1574-
if ((Pointer) arr != DatumGetPointer(adatum))
1574+
if (arr != DatumGetPointer(adatum))
15751575
pfree(arr);/* free de-toasted copy, if any */
15761576
}
15771577

@@ -1586,7 +1586,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
15861586
ARR_ELEMTYPE(arr) != OIDOID)
15871587
elog(ERROR, "conppeqop is not a 1-D Oid array");
15881588
memcpy(pp_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
1589-
if ((Pointer) arr != DatumGetPointer(adatum))
1589+
if (arr != DatumGetPointer(adatum))
15901590
pfree(arr);/* free de-toasted copy, if any */
15911591
}
15921592

@@ -1601,7 +1601,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
16011601
ARR_ELEMTYPE(arr) != OIDOID)
16021602
elog(ERROR, "conffeqop is not a 1-D Oid array");
16031603
memcpy(ff_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
1604-
if ((Pointer) arr != DatumGetPointer(adatum))
1604+
if (arr != DatumGetPointer(adatum))
16051605
pfree(arr);/* free de-toasted copy, if any */
16061606
}
16071607

@@ -1624,7 +1624,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
16241624
elog(ERROR, "confdelsetcols is not a 1-D smallint array");
16251625
num_delete_cols = ARR_DIMS(arr)[0];
16261626
memcpy(fk_del_set_cols, ARR_DATA_PTR(arr), num_delete_cols * sizeof(int16));
1627-
if ((Pointer) arr != DatumGetPointer(adatum))
1627+
if (arr != DatumGetPointer(adatum))
16281628
pfree(arr);/* free de-toasted copy, if any */
16291629

16301630
*num_fk_del_set_cols = num_delete_cols;

src/backend/utils/adt/arrayfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5687,7 +5687,7 @@ accumArrayResultArr(ArrayBuildStateArr *astate,
56875687
MemoryContextSwitchTo(oldcontext);
56885688

56895689
/* Release detoasted copy if any */
5690-
if ((Pointer) arg != DatumGetPointer(dvalue))
5690+
if (arg != DatumGetPointer(dvalue))
56915691
pfree(arg);
56925692

56935693
return astate;

src/backend/utils/adt/datum.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
299299
len1 - VARHDRSZ) == 0);
300300

301301
/* Only free memory if it's a copy made here. */
302-
if ((Pointer) arg1val != DatumGetPointer(value1))
302+
if (arg1val != DatumGetPointer(value1))
303303
pfree(arg1val);
304-
if ((Pointer) arg2val != DatumGetPointer(value2))
304+
if (arg2val != DatumGetPointer(value2))
305305
pfree(arg2val);
306306
}
307307
}
@@ -355,7 +355,7 @@ datum_image_hash(Datum value, bool typByVal, int typLen)
355355
result = hash_bytes((unsigned char *) VARDATA_ANY(val), len - VARHDRSZ);
356356

357357
/* Only free memory if it's a copy made here. */
358-
if ((Pointer) val != DatumGetPointer(value))
358+
if (val != DatumGetPointer(value))
359359
pfree(val);
360360
}
361361
else if (typLen == -2)

src/backend/utils/adt/like_support.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, Oid collation,
10351035
pattlen = VARSIZE_ANY_EXHDR(bstr);
10361036
patt = (char *) palloc(pattlen);
10371037
memcpy(patt, VARDATA_ANY(bstr), pattlen);
1038-
Assert((Pointer) bstr == DatumGetPointer(patt_const->constvalue));
1038+
Assert(bstr == DatumGetPointer(patt_const->constvalue));
10391039
}
10401040

10411041
match = palloc(pattlen + 1);
@@ -1577,7 +1577,7 @@ make_greater_string(const Const *str_const, FmgrInfo *ltproc, Oid collation)
15771577
len = VARSIZE_ANY_EXHDR(bstr);
15781578
workstr = (char *) palloc(len);
15791579
memcpy(workstr, VARDATA_ANY(bstr), len);
1580-
Assert((Pointer) bstr == DatumGetPointer(str_const->constvalue));
1580+
Assert(bstr == DatumGetPointer(str_const->constvalue));
15811581
cmpstr = str_const->constvalue;
15821582
}
15831583
else

src/backend/utils/adt/numeric.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ numeric_abbrev_convert(Datum original_datum, SortSupport ssup)
21942194
}
21952195

21962196
/* should happen only for external/compressed toasts */
2197-
if ((Pointer) original_varatt != DatumGetPointer(original_datum))
2197+
if (original_varatt != DatumGetPointer(original_datum))
21982198
pfree(original_varatt);
21992199

22002200
return result;
@@ -2284,9 +2284,9 @@ numeric_fast_cmp(Datum x, Datum y, SortSupport ssup)
22842284

22852285
result = cmp_numerics(nx, ny);
22862286

2287-
if ((Pointer) nx != DatumGetPointer(x))
2287+
if (nx != DatumGetPointer(x))
22882288
pfree(nx);
2289-
if ((Pointer) ny != DatumGetPointer(y))
2289+
if (ny != DatumGetPointer(y))
22902290
pfree(ny);
22912291

22922292
return result;

src/backend/utils/adt/rangetypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,9 +1513,9 @@ range_fast_cmp(Datum a, Datum b, SortSupport ssup)
15131513
cmp = range_cmp_bounds(typcache, &upper1, &upper2);
15141514
}
15151515

1516-
if ((Pointer) range_a != DatumGetPointer(a))
1516+
if (range_a != DatumGetPointer(a))
15171517
pfree(range_a);
1518-
if ((Pointer) range_b != DatumGetPointer(b))
1518+
if (range_b != DatumGetPointer(b))
15191519
pfree(range_b);
15201520

15211521
return cmp;

src/backend/utils/adt/rowtypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,9 +1529,9 @@ record_image_cmp(FunctionCallInfo fcinfo)
15291529
if ((cmpresult == 0) && (len1 != len2))
15301530
cmpresult = (len1 < len2) ? -1 : 1;
15311531

1532-
if ((Pointer) arg1val != DatumGetPointer(values1[i1]))
1532+
if (arg1val != DatumGetPointer(values1[i1]))
15331533
pfree(arg1val);
1534-
if ((Pointer) arg2val != DatumGetPointer(values2[i2]))
1534+
if (arg2val != DatumGetPointer(values2[i2]))
15351535
pfree(arg2val);
15361536
}
15371537
else

0 commit comments

Comments
 (0)