mirror of
https://github.com/postgres/postgres.git
synced 2026-04-20 22:00:13 -04:00
Fix accidentally cast away qualifiers
This fixes cases where a qualifier (const, in all cases here) was dropped by a cast, but the cast was otherwise necessary or desirable, so the straightforward fix is to add the qualifier into the cast. Co-authored-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/b04f4d3a-5e70-4e73-9ef2-87f777ca4aac%40eisentraut.org
This commit is contained in:
parent
33a92632b7
commit
5ca5f12c2c
42 changed files with 111 additions and 111 deletions
|
|
@ -328,7 +328,7 @@ int_query_opr_selec(ITEM *item, Datum *mcelems, float4 *mcefreqs,
|
|||
static int
|
||||
compare_val_int4(const void *a, const void *b)
|
||||
{
|
||||
int32 key = *(int32 *) a;
|
||||
int32 key = *(const int32 *) a;
|
||||
int32 value = DatumGetInt32(*(const Datum *) b);
|
||||
|
||||
if (key < value)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static inline Oid
|
|||
HeapTupleHeaderGetOidOld(const HeapTupleHeaderData *tup)
|
||||
{
|
||||
if (tup->t_infomask & HEAP_HASOID_OLD)
|
||||
return *((Oid *) ((char *) (tup) + (tup)->t_hoff - sizeof(Oid)));
|
||||
return *((const Oid *) ((const char *) (tup) + (tup)->t_hoff - sizeof(Oid)));
|
||||
else
|
||||
return InvalidOid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len)
|
|||
elog(ERROR, "could not initialize %s context: %s", "MD5",
|
||||
pg_cryptohash_error(ctx));
|
||||
if (pg_cryptohash_update(ctx, ns, sizeof(uu)) < 0 ||
|
||||
pg_cryptohash_update(ctx, (unsigned char *) ptr, len) < 0)
|
||||
pg_cryptohash_update(ctx, (const unsigned char *) ptr, len) < 0)
|
||||
elog(ERROR, "could not update %s context: %s", "MD5",
|
||||
pg_cryptohash_error(ctx));
|
||||
/* we assume sizeof MD5 result is 16, same as UUID size */
|
||||
|
|
@ -356,7 +356,7 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len)
|
|||
elog(ERROR, "could not initialize %s context: %s", "SHA1",
|
||||
pg_cryptohash_error(ctx));
|
||||
if (pg_cryptohash_update(ctx, ns, sizeof(uu)) < 0 ||
|
||||
pg_cryptohash_update(ctx, (unsigned char *) ptr, len) < 0)
|
||||
pg_cryptohash_update(ctx, (const unsigned char *) ptr, len) < 0)
|
||||
elog(ERROR, "could not update %s context: %s", "SHA1",
|
||||
pg_cryptohash_error(ctx));
|
||||
if (pg_cryptohash_final(ctx, sha1result, sizeof(sha1result)) < 0)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ pglz_decompress_datum(const struct varlena *value)
|
|||
result = (struct varlena *) palloc(VARDATA_COMPRESSED_GET_EXTSIZE(value) + VARHDRSZ);
|
||||
|
||||
/* decompress the data */
|
||||
rawsize = pglz_decompress((char *) value + VARHDRSZ_COMPRESSED,
|
||||
rawsize = pglz_decompress((const char *) value + VARHDRSZ_COMPRESSED,
|
||||
VARSIZE(value) - VARHDRSZ_COMPRESSED,
|
||||
VARDATA(result),
|
||||
VARDATA_COMPRESSED_GET_EXTSIZE(value), true);
|
||||
|
|
@ -116,7 +116,7 @@ pglz_decompress_datum_slice(const struct varlena *value,
|
|||
result = (struct varlena *) palloc(slicelength + VARHDRSZ);
|
||||
|
||||
/* decompress the data */
|
||||
rawsize = pglz_decompress((char *) value + VARHDRSZ_COMPRESSED,
|
||||
rawsize = pglz_decompress((const char *) value + VARHDRSZ_COMPRESSED,
|
||||
VARSIZE(value) - VARHDRSZ_COMPRESSED,
|
||||
VARDATA(result),
|
||||
slicelength, false);
|
||||
|
|
@ -192,7 +192,7 @@ lz4_decompress_datum(const struct varlena *value)
|
|||
result = (struct varlena *) palloc(VARDATA_COMPRESSED_GET_EXTSIZE(value) + VARHDRSZ);
|
||||
|
||||
/* decompress the data */
|
||||
rawsize = LZ4_decompress_safe((char *) value + VARHDRSZ_COMPRESSED,
|
||||
rawsize = LZ4_decompress_safe((const char *) value + VARHDRSZ_COMPRESSED,
|
||||
VARDATA(result),
|
||||
VARSIZE(value) - VARHDRSZ_COMPRESSED,
|
||||
VARDATA_COMPRESSED_GET_EXTSIZE(value));
|
||||
|
|
@ -229,7 +229,7 @@ lz4_decompress_datum_slice(const struct varlena *value, int32 slicelength)
|
|||
result = (struct varlena *) palloc(slicelength + VARHDRSZ);
|
||||
|
||||
/* decompress the data */
|
||||
rawsize = LZ4_decompress_safe_partial((char *) value + VARHDRSZ_COMPRESSED,
|
||||
rawsize = LZ4_decompress_safe_partial((const char *) value + VARHDRSZ_COMPRESSED,
|
||||
VARDATA(result),
|
||||
VARSIZE(value) - VARHDRSZ_COMPRESSED,
|
||||
slicelength,
|
||||
|
|
|
|||
|
|
@ -3023,8 +3023,8 @@ _bt_deadblocks(Page page, OffsetNumber *deletable, int ndeletable,
|
|||
static inline int
|
||||
_bt_blk_cmp(const void *arg1, const void *arg2)
|
||||
{
|
||||
BlockNumber b1 = *((BlockNumber *) arg1);
|
||||
BlockNumber b2 = *((BlockNumber *) arg2);
|
||||
BlockNumber b1 = *((const BlockNumber *) arg1);
|
||||
BlockNumber b2 = *((const BlockNumber *) arg2);
|
||||
|
||||
return pg_cmp_u32(b1, b2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,8 +147,8 @@ spg_quad_choose(PG_FUNCTION_ARGS)
|
|||
static int
|
||||
x_cmp(const void *a, const void *b, void *arg)
|
||||
{
|
||||
Point *pa = *(Point **) a;
|
||||
Point *pb = *(Point **) b;
|
||||
Point *pa = *(Point *const *) a;
|
||||
Point *pb = *(Point *const *) b;
|
||||
|
||||
if (pa->x == pb->x)
|
||||
return 0;
|
||||
|
|
@ -158,8 +158,8 @@ x_cmp(const void *a, const void *b, void *arg)
|
|||
static int
|
||||
y_cmp(const void *a, const void *b, void *arg)
|
||||
{
|
||||
Point *pa = *(Point **) a;
|
||||
Point *pb = *(Point **) b;
|
||||
Point *pa = *(Point *const *) a;
|
||||
Point *pb = *(Point *const *) b;
|
||||
|
||||
if (pa->y == pb->y)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -677,8 +677,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
|
|||
if (regbuf->flags & REGBUF_STANDARD)
|
||||
{
|
||||
/* Assume we can omit data between pd_lower and pd_upper */
|
||||
uint16 lower = ((PageHeader) page)->pd_lower;
|
||||
uint16 upper = ((PageHeader) page)->pd_upper;
|
||||
uint16 lower = ((const PageHeaderData *) page)->pd_lower;
|
||||
uint16 upper = ((const PageHeaderData *) page)->pd_upper;
|
||||
|
||||
if (lower >= SizeOfPageHeaderData &&
|
||||
upper > lower &&
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ AppendStringToManifest(backup_manifest_info *manifest, const char *s)
|
|||
Assert(manifest != NULL);
|
||||
if (manifest->still_checksumming)
|
||||
{
|
||||
if (pg_cryptohash_update(manifest->manifest_ctx, (uint8 *) s, len) < 0)
|
||||
if (pg_cryptohash_update(manifest->manifest_ctx, (const uint8 *) s, len) < 0)
|
||||
elog(ERROR, "failed to update checksum of backup manifest: %s",
|
||||
pg_cryptohash_error(manifest->manifest_ctx));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1104,7 +1104,7 @@ sendFileWithContent(bbsink *sink, const char *filename, const char *content,
|
|||
|
||||
_tarWriteHeader(sink, filename, NULL, &statbuf, false);
|
||||
|
||||
if (pg_checksum_update(&checksum_ctx, (uint8 *) content, len) < 0)
|
||||
if (pg_checksum_update(&checksum_ctx, (const uint8 *) content, len) < 0)
|
||||
elog(ERROR, "could not update checksum of file \"%s\"",
|
||||
filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -930,7 +930,7 @@ GetIncrementalFileSize(unsigned num_blocks_required)
|
|||
static uint32
|
||||
hash_string_pointer(const char *s)
|
||||
{
|
||||
unsigned char *ss = (unsigned char *) s;
|
||||
const unsigned char *ss = (const unsigned char *) s;
|
||||
|
||||
return hash_bytes(ss, strlen(s));
|
||||
}
|
||||
|
|
@ -1049,8 +1049,8 @@ manifest_report_error(JsonManifestParseContext *context, const char *fmt,...)
|
|||
static int
|
||||
compare_block_numbers(const void *a, const void *b)
|
||||
{
|
||||
BlockNumber aa = *(BlockNumber *) a;
|
||||
BlockNumber bb = *(BlockNumber *) b;
|
||||
BlockNumber aa = *(const BlockNumber *) a;
|
||||
BlockNumber bb = *(const BlockNumber *) b;
|
||||
|
||||
return pg_cmp_u32(aa, bb);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -443,8 +443,8 @@ static int
|
|||
reorderqueue_cmp(const pairingheap_node *a, const pairingheap_node *b,
|
||||
void *arg)
|
||||
{
|
||||
ReorderTuple *rta = (ReorderTuple *) a;
|
||||
ReorderTuple *rtb = (ReorderTuple *) b;
|
||||
const ReorderTuple *rta = (const ReorderTuple *) a;
|
||||
const ReorderTuple *rtb = (const ReorderTuple *) b;
|
||||
IndexScanState *node = (IndexScanState *) arg;
|
||||
|
||||
/* exchange argument order to invert the sort order */
|
||||
|
|
|
|||
|
|
@ -1490,8 +1490,8 @@ scram_mock_salt(const char *username, pg_cryptohash_type hash_type,
|
|||
|
||||
ctx = pg_cryptohash_create(hash_type);
|
||||
if (pg_cryptohash_init(ctx) < 0 ||
|
||||
pg_cryptohash_update(ctx, (uint8 *) username, strlen(username)) < 0 ||
|
||||
pg_cryptohash_update(ctx, (uint8 *) mock_auth_nonce, MOCK_AUTH_NONCE_LEN) < 0 ||
|
||||
pg_cryptohash_update(ctx, (const uint8 *) username, strlen(username)) < 0 ||
|
||||
pg_cryptohash_update(ctx, (const uint8 *) mock_auth_nonce, MOCK_AUTH_NONCE_LEN) < 0 ||
|
||||
pg_cryptohash_final(ctx, sha_digest, key_length) < 0)
|
||||
{
|
||||
pg_cryptohash_free(ctx);
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ encrypt_password(PasswordType target_type, const char *role,
|
|||
case PASSWORD_TYPE_MD5:
|
||||
encrypted_password = palloc(MD5_PASSWD_LEN + 1);
|
||||
|
||||
if (!pg_md5_encrypt(password, (uint8 *) role, strlen(role),
|
||||
if (!pg_md5_encrypt(password, (const uint8 *) role, strlen(role),
|
||||
encrypted_password, &errstr))
|
||||
elog(ERROR, "password encryption failed: %s", errstr);
|
||||
break;
|
||||
|
|
@ -284,7 +284,7 @@ plain_crypt_verify(const char *role, const char *shadow_pass,
|
|||
|
||||
case PASSWORD_TYPE_MD5:
|
||||
if (!pg_md5_encrypt(client_pass,
|
||||
(uint8 *) role,
|
||||
(const uint8 *) role,
|
||||
strlen(role),
|
||||
crypt_client_pass,
|
||||
&errstr))
|
||||
|
|
|
|||
|
|
@ -1009,14 +1009,14 @@ exprCollation(const Node *expr)
|
|||
break;
|
||||
case T_JsonExpr:
|
||||
{
|
||||
const JsonExpr *jsexpr = (JsonExpr *) expr;
|
||||
const JsonExpr *jsexpr = (const JsonExpr *) expr;
|
||||
|
||||
coll = jsexpr->collation;
|
||||
}
|
||||
break;
|
||||
case T_JsonBehavior:
|
||||
{
|
||||
const JsonBehavior *behavior = (JsonBehavior *) expr;
|
||||
const JsonBehavior *behavior = (const JsonBehavior *) expr;
|
||||
|
||||
if (behavior->expr)
|
||||
coll = exprCollation(behavior->expr);
|
||||
|
|
@ -1593,7 +1593,7 @@ exprLocation(const Node *expr)
|
|||
}
|
||||
break;
|
||||
case T_JsonBehavior:
|
||||
loc = exprLocation(((JsonBehavior *) expr)->expr);
|
||||
loc = exprLocation(((const JsonBehavior *) expr)->expr);
|
||||
break;
|
||||
case T_NullTest:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -736,17 +736,17 @@ outNode(StringInfo str, const void *obj)
|
|||
_outList(str, obj);
|
||||
/* nodeRead does not want to see { } around these! */
|
||||
else if (IsA(obj, Integer))
|
||||
_outInteger(str, (Integer *) obj);
|
||||
_outInteger(str, (const Integer *) obj);
|
||||
else if (IsA(obj, Float))
|
||||
_outFloat(str, (Float *) obj);
|
||||
_outFloat(str, (const Float *) obj);
|
||||
else if (IsA(obj, Boolean))
|
||||
_outBoolean(str, (Boolean *) obj);
|
||||
_outBoolean(str, (const Boolean *) obj);
|
||||
else if (IsA(obj, String))
|
||||
_outString(str, (String *) obj);
|
||||
_outString(str, (const String *) obj);
|
||||
else if (IsA(obj, BitString))
|
||||
_outBitString(str, (BitString *) obj);
|
||||
_outBitString(str, (const BitString *) obj);
|
||||
else if (IsA(obj, Bitmapset))
|
||||
outBitmapset(str, (Bitmapset *) obj);
|
||||
outBitmapset(str, (const Bitmapset *) obj);
|
||||
else
|
||||
{
|
||||
appendStringInfoChar(str, '{');
|
||||
|
|
|
|||
|
|
@ -1439,8 +1439,8 @@ static int
|
|||
tbm_shared_comparator(const void *left, const void *right, void *arg)
|
||||
{
|
||||
PagetableEntry *base = (PagetableEntry *) arg;
|
||||
PagetableEntry *lpage = &base[*(int *) left];
|
||||
PagetableEntry *rpage = &base[*(int *) right];
|
||||
PagetableEntry *lpage = &base[*(const int *) left];
|
||||
PagetableEntry *rpage = &base[*(const int *) right];
|
||||
|
||||
if (lpage->blockno < rpage->blockno)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -915,8 +915,8 @@ multi_sort_compare_dims(int start, int end,
|
|||
int
|
||||
compare_scalars_simple(const void *a, const void *b, void *arg)
|
||||
{
|
||||
return compare_datums_simple(*(Datum *) a,
|
||||
*(Datum *) b,
|
||||
return compare_datums_simple(*(const Datum *) a,
|
||||
*(const Datum *) b,
|
||||
(SortSupport) arg);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1041,7 +1041,7 @@ shm_mq_send_bytes(shm_mq_handle *mqh, Size nbytes, const void *data,
|
|||
*/
|
||||
pg_memory_barrier();
|
||||
memcpy(&mq->mq_ring[mq->mq_ring_offset + offset],
|
||||
(char *) data + sent, sendnow);
|
||||
(const char *) data + sent, sendnow);
|
||||
sent += sendnow;
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2463,9 +2463,9 @@ SplitToVariants(IspellDict *Conf, SPNode *snode, SplitVar *orig, const char *wor
|
|||
while (StopLow < StopHigh)
|
||||
{
|
||||
StopMiddle = StopLow + ((StopHigh - StopLow) >> 1);
|
||||
if (StopMiddle->val == ((uint8 *) (word))[level])
|
||||
if (StopMiddle->val == ((const uint8 *) (word))[level])
|
||||
break;
|
||||
else if (StopMiddle->val < ((uint8 *) (word))[level])
|
||||
else if (StopMiddle->val < ((const uint8 *) (word))[level])
|
||||
StopLow = StopMiddle + 1;
|
||||
else
|
||||
StopHigh = StopMiddle;
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@
|
|||
static int
|
||||
compareDoubles(const void *a, const void *b)
|
||||
{
|
||||
float8 x = *(float8 *) a;
|
||||
float8 y = *(float8 *) b;
|
||||
float8 x = *(const float8 *) a;
|
||||
float8 y = *(const float8 *) b;
|
||||
|
||||
if (x == y)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -901,7 +901,7 @@ json_agg_finalfn(PG_FUNCTION_ARGS)
|
|||
static uint32
|
||||
json_unique_hash(const void *key, Size keysize)
|
||||
{
|
||||
const JsonUniqueHashEntry *entry = (JsonUniqueHashEntry *) key;
|
||||
const JsonUniqueHashEntry *entry = (const JsonUniqueHashEntry *) key;
|
||||
uint32 hash = hash_bytes_uint32(entry->object_id);
|
||||
|
||||
hash ^= hash_bytes((const unsigned char *) entry->key, entry->key_len);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ initcap_wbnext(void *state)
|
|||
while (wbstate->offset < wbstate->len &&
|
||||
wbstate->str[wbstate->offset] != '\0')
|
||||
{
|
||||
char32_t u = utf8_to_unicode((unsigned char *) wbstate->str +
|
||||
char32_t u = utf8_to_unicode((const unsigned char *) wbstate->str +
|
||||
wbstate->offset);
|
||||
bool curr_alnum = pg_u_isalnum(u, wbstate->posix);
|
||||
|
||||
|
|
|
|||
|
|
@ -2108,7 +2108,7 @@ range_deserialize(TypeCacheEntry *typcache, const RangeType *range,
|
|||
typalign = typcache->rngelemtype->typalign;
|
||||
|
||||
/* initialize data pointer just after the range OID */
|
||||
ptr = (char *) (range + 1);
|
||||
ptr = (const char *) (range + 1);
|
||||
|
||||
/* fetch lower bound, if any */
|
||||
if (RANGE_HAS_LBOUND(flags))
|
||||
|
|
@ -2155,7 +2155,7 @@ char
|
|||
range_get_flags(const RangeType *range)
|
||||
{
|
||||
/* fetch the flag byte from datum's last byte */
|
||||
return *((char *) range + VARSIZE(range) - 1);
|
||||
return *((const char *) range + VARSIZE(range) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -2360,8 +2360,8 @@ range_cmp_bound_values(TypeCacheEntry *typcache, const RangeBound *b1,
|
|||
int
|
||||
range_compare(const void *key1, const void *key2, void *arg)
|
||||
{
|
||||
RangeType *r1 = *(RangeType **) key1;
|
||||
RangeType *r2 = *(RangeType **) key2;
|
||||
RangeType *r1 = *(RangeType *const *) key1;
|
||||
RangeType *r2 = *(RangeType *const *) key2;
|
||||
TypeCacheEntry *typcache = (TypeCacheEntry *) arg;
|
||||
RangeBound lower1;
|
||||
RangeBound upper1;
|
||||
|
|
|
|||
|
|
@ -1768,8 +1768,8 @@ interval_cmp_upper(const void *a, const void *b, void *arg)
|
|||
static int
|
||||
common_entry_cmp(const void *i1, const void *i2)
|
||||
{
|
||||
double delta1 = ((CommonEntry *) i1)->delta;
|
||||
double delta2 = ((CommonEntry *) i2)->delta;
|
||||
double delta1 = ((const CommonEntry *) i1)->delta;
|
||||
double delta2 = ((const CommonEntry *) i2)->delta;
|
||||
|
||||
if (delta1 < delta2)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ dir_write(Walfile *f, const void *buf, size_t count)
|
|||
return -1;
|
||||
}
|
||||
|
||||
inbuf = ((char *) inbuf) + chunk;
|
||||
inbuf = ((const char *) inbuf) + chunk;
|
||||
}
|
||||
|
||||
/* Our caller keeps track of the uncompressed size. */
|
||||
|
|
|
|||
|
|
@ -694,8 +694,8 @@ datasegpath(RelFileLocator rlocator, ForkNumber forknum, BlockNumber segno)
|
|||
static int
|
||||
final_filemap_cmp(const void *a, const void *b)
|
||||
{
|
||||
file_entry_t *fa = *((file_entry_t **) a);
|
||||
file_entry_t *fb = *((file_entry_t **) b);
|
||||
file_entry_t *fa = *((file_entry_t *const *) a);
|
||||
file_entry_t *fb = *((file_entry_t *const *) b);
|
||||
|
||||
if (fa->action > fb->action)
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ member_compute_checksum(astreamer *streamer, astreamer_member *member,
|
|||
mystreamer->checksum_bytes += len;
|
||||
|
||||
/* Feed these bytes to the checksum calculation. */
|
||||
if (pg_checksum_update(checksum_ctx, (uint8 *) data, len) < 0)
|
||||
if (pg_checksum_update(checksum_ctx, (const uint8 *) data, len) < 0)
|
||||
{
|
||||
report_backup_error(mystreamer->context,
|
||||
"could not update checksum of file \"%s\"",
|
||||
|
|
|
|||
|
|
@ -217,8 +217,8 @@ dump_one_relation(ws_options *opt, RelFileLocator *rlocator,
|
|||
static int
|
||||
compare_block_numbers(const void *a, const void *b)
|
||||
{
|
||||
BlockNumber aa = *(BlockNumber *) a;
|
||||
BlockNumber bb = *(BlockNumber *) b;
|
||||
BlockNumber aa = *(const BlockNumber *) a;
|
||||
BlockNumber bb = *(const BlockNumber *) b;
|
||||
|
||||
return pg_cmp_u32(aa, bb);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ scram_SaltedPassword(const char *password,
|
|||
*/
|
||||
|
||||
/* First iteration */
|
||||
if (pg_hmac_init(hmac_ctx, (uint8 *) password, password_len) < 0 ||
|
||||
if (pg_hmac_init(hmac_ctx, (const uint8 *) password, password_len) < 0 ||
|
||||
pg_hmac_update(hmac_ctx, salt, saltlen) < 0 ||
|
||||
pg_hmac_update(hmac_ctx, (uint8 *) &one, sizeof(uint32)) < 0 ||
|
||||
pg_hmac_final(hmac_ctx, Ui_prev, key_length) < 0)
|
||||
|
|
@ -84,7 +84,7 @@ scram_SaltedPassword(const char *password,
|
|||
CHECK_FOR_INTERRUPTS();
|
||||
#endif
|
||||
|
||||
if (pg_hmac_init(hmac_ctx, (uint8 *) password, password_len) < 0 ||
|
||||
if (pg_hmac_init(hmac_ctx, (const uint8 *) password, password_len) < 0 ||
|
||||
pg_hmac_update(hmac_ctx, (uint8 *) Ui_prev, key_length) < 0 ||
|
||||
pg_hmac_final(hmac_ctx, Ui, key_length) < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ initcap_wbnext(void *state)
|
|||
while (wbstate->offset < wbstate->len &&
|
||||
wbstate->str[wbstate->offset] != '\0')
|
||||
{
|
||||
char32_t u = utf8_to_unicode((unsigned char *) wbstate->str +
|
||||
char32_t u = utf8_to_unicode((const unsigned char *) wbstate->str +
|
||||
wbstate->offset);
|
||||
bool curr_alnum = pg_u_isalnum(u, wbstate->posix);
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ convert_case(char *dst, size_t dstsize, const char *src, ssize_t srclen,
|
|||
|
||||
while ((srclen < 0 || srcoff < srclen) && src[srcoff] != '\0')
|
||||
{
|
||||
char32_t u1 = utf8_to_unicode((unsigned char *) src + srcoff);
|
||||
char32_t u1 = utf8_to_unicode((const unsigned char *) src + srcoff);
|
||||
int u1len = unicode_utf8len(u1);
|
||||
char32_t simple = 0;
|
||||
const char32_t *special = NULL;
|
||||
|
|
@ -373,7 +373,7 @@ check_special_conditions(int conditions, const char *str, size_t len,
|
|||
if (conditions == 0)
|
||||
return true;
|
||||
else if (conditions == PG_U_FINAL_SIGMA)
|
||||
return check_final_sigma((unsigned char *) str, len, offset);
|
||||
return check_final_sigma((const unsigned char *) str, len, offset);
|
||||
|
||||
/* no other conditions supported */
|
||||
Assert(false);
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ fetch_att(const void *T, bool attbyval, int attlen)
|
|||
: \
|
||||
( \
|
||||
AssertMacro((attlen) == -2), \
|
||||
(cur_offset) + (strlen((char *) (attptr)) + 1) \
|
||||
(cur_offset) + (strlen((const char *) (attptr)) + 1) \
|
||||
)) \
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ fasthash_accum_cstring_aligned(fasthash_state *hs, const char *str)
|
|||
*/
|
||||
for (;;)
|
||||
{
|
||||
uint64 chunk = *(uint64 *) str;
|
||||
uint64 chunk = *(const uint64 *) str;
|
||||
|
||||
zero_byte_low = haszero64(chunk);
|
||||
if (zero_byte_low)
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ pg_memory_is_all_zeros(const void *ptr, size_t len)
|
|||
*/
|
||||
for (; p < aligned_end; p += sizeof(size_t))
|
||||
{
|
||||
if (*(size_t *) p != 0)
|
||||
if (*(const size_t *) p != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -290,10 +290,10 @@ pg_memory_is_all_zeros(const void *ptr, size_t len)
|
|||
*/
|
||||
for (; p < aligned_end - (sizeof(size_t) * 7); p += sizeof(size_t) * 8)
|
||||
{
|
||||
if ((((size_t *) p)[0] != 0) | (((size_t *) p)[1] != 0) |
|
||||
(((size_t *) p)[2] != 0) | (((size_t *) p)[3] != 0) |
|
||||
(((size_t *) p)[4] != 0) | (((size_t *) p)[5] != 0) |
|
||||
(((size_t *) p)[6] != 0) | (((size_t *) p)[7] != 0))
|
||||
if ((((const size_t *) p)[0] != 0) | (((const size_t *) p)[1] != 0) |
|
||||
(((const size_t *) p)[2] != 0) | (((const size_t *) p)[3] != 0) |
|
||||
(((const size_t *) p)[4] != 0) | (((const size_t *) p)[5] != 0) |
|
||||
(((const size_t *) p)[6] != 0) | (((const size_t *) p)[7] != 0))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ pg_memory_is_all_zeros(const void *ptr, size_t len)
|
|||
*/
|
||||
for (; p < aligned_end; p += sizeof(size_t))
|
||||
{
|
||||
if (*(size_t *) p != 0)
|
||||
if (*(const size_t *) p != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -193,25 +193,25 @@ typedef struct
|
|||
#ifdef WORDS_BIGENDIAN
|
||||
|
||||
#define VARATT_IS_4B(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header & 0x80) == 0x00)
|
||||
((((const varattrib_1b *) (PTR))->va_header & 0x80) == 0x00)
|
||||
#define VARATT_IS_4B_U(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header & 0xC0) == 0x00)
|
||||
((((const varattrib_1b *) (PTR))->va_header & 0xC0) == 0x00)
|
||||
#define VARATT_IS_4B_C(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header & 0xC0) == 0x40)
|
||||
((((const varattrib_1b *) (PTR))->va_header & 0xC0) == 0x40)
|
||||
#define VARATT_IS_1B(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header & 0x80) == 0x80)
|
||||
((((const varattrib_1b *) (PTR))->va_header & 0x80) == 0x80)
|
||||
#define VARATT_IS_1B_E(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header) == 0x80)
|
||||
((((const varattrib_1b *) (PTR))->va_header) == 0x80)
|
||||
#define VARATT_NOT_PAD_BYTE(PTR) \
|
||||
(*((uint8 *) (PTR)) != 0)
|
||||
(*((const uint8 *) (PTR)) != 0)
|
||||
|
||||
/* VARSIZE_4B() should only be used on known-aligned data */
|
||||
#define VARSIZE_4B(PTR) \
|
||||
(((varattrib_4b *) (PTR))->va_4byte.va_header & 0x3FFFFFFF)
|
||||
(((const varattrib_4b *) (PTR))->va_4byte.va_header & 0x3FFFFFFF)
|
||||
#define VARSIZE_1B(PTR) \
|
||||
(((varattrib_1b *) (PTR))->va_header & 0x7F)
|
||||
(((const varattrib_1b *) (PTR))->va_header & 0x7F)
|
||||
#define VARTAG_1B_E(PTR) \
|
||||
((vartag_external) ((varattrib_1b_e *) (PTR))->va_tag)
|
||||
((vartag_external) ((const varattrib_1b_e *) (PTR))->va_tag)
|
||||
|
||||
#define SET_VARSIZE_4B(PTR,len) \
|
||||
(((varattrib_4b *) (PTR))->va_4byte.va_header = (len) & 0x3FFFFFFF)
|
||||
|
|
@ -226,25 +226,25 @@ typedef struct
|
|||
#else /* !WORDS_BIGENDIAN */
|
||||
|
||||
#define VARATT_IS_4B(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header & 0x01) == 0x00)
|
||||
((((const varattrib_1b *) (PTR))->va_header & 0x01) == 0x00)
|
||||
#define VARATT_IS_4B_U(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header & 0x03) == 0x00)
|
||||
((((const varattrib_1b *) (PTR))->va_header & 0x03) == 0x00)
|
||||
#define VARATT_IS_4B_C(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header & 0x03) == 0x02)
|
||||
((((const varattrib_1b *) (PTR))->va_header & 0x03) == 0x02)
|
||||
#define VARATT_IS_1B(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header & 0x01) == 0x01)
|
||||
((((const varattrib_1b *) (PTR))->va_header & 0x01) == 0x01)
|
||||
#define VARATT_IS_1B_E(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header) == 0x01)
|
||||
((((const varattrib_1b *) (PTR))->va_header) == 0x01)
|
||||
#define VARATT_NOT_PAD_BYTE(PTR) \
|
||||
(*((uint8 *) (PTR)) != 0)
|
||||
(*((const uint8 *) (PTR)) != 0)
|
||||
|
||||
/* VARSIZE_4B() should only be used on known-aligned data */
|
||||
#define VARSIZE_4B(PTR) \
|
||||
((((varattrib_4b *) (PTR))->va_4byte.va_header >> 2) & 0x3FFFFFFF)
|
||||
((((const varattrib_4b *) (PTR))->va_4byte.va_header >> 2) & 0x3FFFFFFF)
|
||||
#define VARSIZE_1B(PTR) \
|
||||
((((varattrib_1b *) (PTR))->va_header >> 1) & 0x7F)
|
||||
((((const varattrib_1b *) (PTR))->va_header >> 1) & 0x7F)
|
||||
#define VARTAG_1B_E(PTR) \
|
||||
((vartag_external) ((varattrib_1b_e *) (PTR))->va_tag)
|
||||
((vartag_external) ((const varattrib_1b_e *) (PTR))->va_tag)
|
||||
|
||||
#define SET_VARSIZE_4B(PTR,len) \
|
||||
(((varattrib_4b *) (PTR))->va_4byte.va_header = (((uint32) (len)) << 2))
|
||||
|
|
@ -492,14 +492,14 @@ VARDATA_ANY(const void *PTR)
|
|||
static inline Size
|
||||
VARDATA_COMPRESSED_GET_EXTSIZE(const void *PTR)
|
||||
{
|
||||
return ((varattrib_4b *) PTR)->va_compressed.va_tcinfo & VARLENA_EXTSIZE_MASK;
|
||||
return ((const varattrib_4b *) PTR)->va_compressed.va_tcinfo & VARLENA_EXTSIZE_MASK;
|
||||
}
|
||||
|
||||
/* Compression method of a compressed-in-line varlena datum */
|
||||
static inline uint32
|
||||
VARDATA_COMPRESSED_GET_COMPRESS_METHOD(const void *PTR)
|
||||
{
|
||||
return ((varattrib_4b *) PTR)->va_compressed.va_tcinfo >> VARLENA_EXTSIZE_BITS;
|
||||
return ((const varattrib_4b *) PTR)->va_compressed.va_tcinfo >> VARLENA_EXTSIZE_BITS;
|
||||
}
|
||||
|
||||
/* Same for external Datums; but note argument is a struct varatt_external */
|
||||
|
|
|
|||
|
|
@ -819,7 +819,7 @@ calculate_client_proof(fe_scram_state *state,
|
|||
strlen(state->server_first_message)) < 0 ||
|
||||
pg_hmac_update(ctx, (uint8 *) ",", 1) < 0 ||
|
||||
pg_hmac_update(ctx,
|
||||
(uint8 *) client_final_message_without_proof,
|
||||
(const uint8 *) client_final_message_without_proof,
|
||||
strlen(client_final_message_without_proof)) < 0 ||
|
||||
pg_hmac_final(ctx, ClientSignature, state->key_length) < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1369,7 +1369,7 @@ PQencryptPassword(const char *passwd, const char *user)
|
|||
if (!crypt_pwd)
|
||||
return NULL;
|
||||
|
||||
if (!pg_md5_encrypt(passwd, (uint8 *) user, strlen(user), crypt_pwd, &errstr))
|
||||
if (!pg_md5_encrypt(passwd, (const uint8 *) user, strlen(user), crypt_pwd, &errstr))
|
||||
{
|
||||
free(crypt_pwd);
|
||||
return NULL;
|
||||
|
|
@ -1482,7 +1482,7 @@ PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user,
|
|||
{
|
||||
const char *errstr = NULL;
|
||||
|
||||
if (!pg_md5_encrypt(passwd, (uint8 *) user, strlen(user), crypt_pwd, &errstr))
|
||||
if (!pg_md5_encrypt(passwd, (const uint8 *) user, strlen(user), crypt_pwd, &errstr))
|
||||
{
|
||||
libpq_append_conn_error(conn, "could not encrypt password: %s", errstr);
|
||||
free(crypt_pwd);
|
||||
|
|
|
|||
|
|
@ -42,32 +42,32 @@ pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t len)
|
|||
if (!PointerIsAligned(p, uint32) &&
|
||||
p + 2 <= pend)
|
||||
{
|
||||
crc = __crc32ch(crc, *(uint16 *) p);
|
||||
crc = __crc32ch(crc, *(const uint16 *) p);
|
||||
p += 2;
|
||||
}
|
||||
if (!PointerIsAligned(p, uint64) &&
|
||||
p + 4 <= pend)
|
||||
{
|
||||
crc = __crc32cw(crc, *(uint32 *) p);
|
||||
crc = __crc32cw(crc, *(const uint32 *) p);
|
||||
p += 4;
|
||||
}
|
||||
|
||||
/* Process eight bytes at a time, as far as we can. */
|
||||
while (p + 8 <= pend)
|
||||
{
|
||||
crc = __crc32cd(crc, *(uint64 *) p);
|
||||
crc = __crc32cd(crc, *(const uint64 *) p);
|
||||
p += 8;
|
||||
}
|
||||
|
||||
/* Process remaining 0-7 bytes. */
|
||||
if (p + 4 <= pend)
|
||||
{
|
||||
crc = __crc32cw(crc, *(uint32 *) p);
|
||||
crc = __crc32cw(crc, *(const uint32 *) p);
|
||||
p += 4;
|
||||
}
|
||||
if (p + 2 <= pend)
|
||||
{
|
||||
crc = __crc32ch(crc, *(uint16 *) p);
|
||||
crc = __crc32ch(crc, *(const uint16 *) p);
|
||||
p += 2;
|
||||
}
|
||||
if (p < pend)
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ pg_popcount_neon(const char *buf, int bytes)
|
|||
*/
|
||||
for (; bytes >= sizeof(uint64); bytes -= sizeof(uint64))
|
||||
{
|
||||
popcnt += pg_popcount64(*((uint64 *) buf));
|
||||
popcnt += pg_popcount64(*((const uint64 *) buf));
|
||||
buf += sizeof(uint64);
|
||||
}
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ pg_popcount_masked_neon(const char *buf, int bytes, bits8 mask)
|
|||
*/
|
||||
for (; bytes >= sizeof(uint64); bytes -= sizeof(uint64))
|
||||
{
|
||||
popcnt += pg_popcount64(*((uint64 *) buf) & mask64);
|
||||
popcnt += pg_popcount64(*((const uint64 *) buf) & mask64);
|
||||
buf += sizeof(uint64);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -498,8 +498,8 @@ run_named_permutations(TestSpec *testspec)
|
|||
static int
|
||||
step_qsort_cmp(const void *a, const void *b)
|
||||
{
|
||||
Step *stepa = *((Step **) a);
|
||||
Step *stepb = *((Step **) b);
|
||||
Step *stepa = *((Step *const *) a);
|
||||
Step *stepb = *((Step *const *) b);
|
||||
|
||||
return strcmp(stepa->name, stepb->name);
|
||||
}
|
||||
|
|
@ -507,8 +507,8 @@ step_qsort_cmp(const void *a, const void *b)
|
|||
static int
|
||||
step_bsearch_cmp(const void *a, const void *b)
|
||||
{
|
||||
char *stepname = (char *) a;
|
||||
Step *step = *((Step **) b);
|
||||
const char *stepname = (const char *) a;
|
||||
Step *step = *((Step *const *) b);
|
||||
|
||||
return strcmp(stepname, step->name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1594,7 +1594,7 @@ test_singlerowmode(PGconn *conn)
|
|||
"SELECT generate_series(42, $1)",
|
||||
1,
|
||||
NULL,
|
||||
(const char **) param,
|
||||
(const char *const *) param,
|
||||
NULL,
|
||||
NULL,
|
||||
0) != 1)
|
||||
|
|
|
|||
|
|
@ -56,16 +56,16 @@ itemptr_cmp(const void *left, const void *right)
|
|||
OffsetNumber loff,
|
||||
roff;
|
||||
|
||||
lblk = ItemPointerGetBlockNumber((ItemPointer) left);
|
||||
rblk = ItemPointerGetBlockNumber((ItemPointer) right);
|
||||
lblk = ItemPointerGetBlockNumber((const ItemPointerData *) left);
|
||||
rblk = ItemPointerGetBlockNumber((const ItemPointerData *) right);
|
||||
|
||||
if (lblk < rblk)
|
||||
return -1;
|
||||
if (lblk > rblk)
|
||||
return 1;
|
||||
|
||||
loff = ItemPointerGetOffsetNumber((ItemPointer) left);
|
||||
roff = ItemPointerGetOffsetNumber((ItemPointer) right);
|
||||
loff = ItemPointerGetOffsetNumber((const ItemPointerData *) left);
|
||||
roff = ItemPointerGetOffsetNumber((const ItemPointerData *) right);
|
||||
|
||||
if (loff < roff)
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue