From cf40dc65b676c8df1ee12f060b40f0e37a183e04 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 29 Jan 2019 01:12:18 +0100 Subject: [PATCH] Remove useless casts Some of these were uselessly casting away "const", some were just nearby, but they where all unnecessary anyway. Discussion: https://www.postgresql.org/message-id/flat/53a28052-f9f3-1808-fed9-460fd43035ab%402ndquadrant.com --- contrib/btree_gist/btree_utils_num.c | 24 ++++++++++++------------ src/backend/catalog/heap.c | 2 +- src/common/unicode_norm.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/contrib/btree_gist/btree_utils_num.c b/contrib/btree_gist/btree_utils_num.c index 29b0faf997..4d10bc93f3 100644 --- a/contrib/btree_gist/btree_utils_num.c +++ b/contrib/btree_gist/btree_utils_num.c @@ -185,10 +185,10 @@ gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_nin c.upper = &cur[tinfo->size]; /* if out->lower > cur->lower, adopt cur as lower */ if (tinfo->f_gt(o.lower, c.lower, flinfo)) - memcpy((void *) o.lower, (void *) c.lower, tinfo->size); + memcpy((void *) o.lower, c.lower, tinfo->size); /* if out->upper < cur->upper, adopt cur as upper */ if (tinfo->f_lt(o.upper, c.upper, flinfo)) - memcpy((void *) o.upper, (void *) c.upper, tinfo->size); + memcpy((void *) o.upper, c.upper, tinfo->size); } return out; @@ -206,10 +206,10 @@ gbt_num_same(const GBT_NUMKEY *a, const GBT_NUMKEY *b, const gbtree_ninfo *tinfo GBT_NUMKEY_R b1, b2; - b1.lower = &(((GBT_NUMKEY *) a)[0]); - b1.upper = &(((GBT_NUMKEY *) a)[tinfo->size]); - b2.lower = &(((GBT_NUMKEY *) b)[0]); - b2.upper = &(((GBT_NUMKEY *) b)[tinfo->size]); + b1.lower = &(a[0]); + b1.upper = &(a[tinfo->size]); + b2.lower = &(b[0]); + b2.upper = &(b[tinfo->size]); return (tinfo->f_eq(b1.lower, b2.lower, flinfo) && tinfo->f_eq(b1.upper, b2.upper, flinfo)); @@ -227,8 +227,8 @@ gbt_num_bin_union(Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo, FmgrInfo * if (!DatumGetPointer(*u)) { *u = PointerGetDatum(palloc0(tinfo->indexsize)); - memcpy((void *) &(((GBT_NUMKEY *) DatumGetPointer(*u))[0]), (void *) rd.lower, tinfo->size); - memcpy((void *) &(((GBT_NUMKEY *) DatumGetPointer(*u))[tinfo->size]), (void *) rd.upper, tinfo->size); + memcpy(&(((GBT_NUMKEY *) DatumGetPointer(*u))[0]), rd.lower, tinfo->size); + memcpy(&(((GBT_NUMKEY *) DatumGetPointer(*u))[tinfo->size]), rd.upper, tinfo->size); } else { @@ -236,10 +236,10 @@ gbt_num_bin_union(Datum *u, GBT_NUMKEY *e, const gbtree_ninfo *tinfo, FmgrInfo * ur.lower = &(((GBT_NUMKEY *) DatumGetPointer(*u))[0]); ur.upper = &(((GBT_NUMKEY *) DatumGetPointer(*u))[tinfo->size]); - if (tinfo->f_gt((void *) ur.lower, (void *) rd.lower, flinfo)) - memcpy((void *) ur.lower, (void *) rd.lower, tinfo->size); - if (tinfo->f_lt((void *) ur.upper, (void *) rd.upper, flinfo)) - memcpy((void *) ur.upper, (void *) rd.upper, tinfo->size); + if (tinfo->f_gt(ur.lower, rd.lower, flinfo)) + memcpy((void *) ur.lower, rd.lower, tinfo->size); + if (tinfo->f_lt(ur.upper, rd.upper, flinfo)) + memcpy((void *) ur.upper, rd.upper, tinfo->size); } } diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 06d18a1cfb..d0215a5eed 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -777,7 +777,7 @@ AddNewAttributeTuples(Oid new_rel_oid, { FormData_pg_attribute attStruct; - memcpy(&attStruct, (char *) SysAtt[i], sizeof(FormData_pg_attribute)); + memcpy(&attStruct, SysAtt[i], sizeof(FormData_pg_attribute)); /* Fill in the correct relation OID in the copied tuple */ attStruct.attrelid = new_rel_oid; diff --git a/src/common/unicode_norm.c b/src/common/unicode_norm.c index d5f6d32e0f..6281f2222f 100644 --- a/src/common/unicode_norm.c +++ b/src/common/unicode_norm.c @@ -59,7 +59,7 @@ static pg_unicode_decomposition * get_code_entry(pg_wchar code) { return bsearch(&(code), - (void *) UnicodeDecompMain, + UnicodeDecompMain, lengthof(UnicodeDecompMain), sizeof(pg_unicode_decomposition), conv_compare); -- 2.40.0