mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Fix some -Wcast-qual warnings
Small rearrangements to avoid having to cast away qualifiers. In some cases, the whole cast was unnecessary. Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Discussion: https://www.postgresql.org/message-id/flat/459217ca-3840-4452-8cd1-8f9b47e8d479%40eisentraut.org
This commit is contained in:
@@ -98,7 +98,7 @@ gbt_bitcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
|
||||
* descend to that leaf page.
|
||||
*/
|
||||
static bytea *
|
||||
gbt_bit_xfrm(VarBit *leaf)
|
||||
gbt_bit_xfrm(const VarBit *leaf)
|
||||
{
|
||||
bytea *out;
|
||||
int sz = VARBITBYTES(leaf) + VARHDRSZ;
|
||||
@@ -125,7 +125,7 @@ gbt_bit_l2n(GBT_VARKEY *leaf, FmgrInfo *flinfo)
|
||||
GBT_VARKEY_R r = gbt_var_key_readable(leaf);
|
||||
bytea *o;
|
||||
|
||||
o = gbt_bit_xfrm((VarBit *) r.lower);
|
||||
o = gbt_bit_xfrm((const VarBit *) r.lower);
|
||||
r.upper = r.lower = o;
|
||||
out = gbt_var_key_copy(&r);
|
||||
pfree(o);
|
||||
|
||||
@@ -62,9 +62,9 @@ gbt_var_key_readable(const GBT_VARKEY *k)
|
||||
{
|
||||
GBT_VARKEY_R r;
|
||||
|
||||
r.lower = (bytea *) &(((char *) k)[VARHDRSZ]);
|
||||
r.lower = (const bytea *) &(((const char *) k)[VARHDRSZ]);
|
||||
if (VARSIZE(k) > (VARHDRSZ + (VARSIZE(r.lower))))
|
||||
r.upper = (bytea *) &(((char *) k)[VARHDRSZ + INTALIGN(VARSIZE(r.lower))]);
|
||||
r.upper = (const bytea *) &(((const char *) k)[VARHDRSZ + INTALIGN(VARSIZE(r.lower))]);
|
||||
else
|
||||
r.upper = r.lower;
|
||||
return r;
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef bytea GBT_VARKEY;
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bytea *lower,
|
||||
const bytea *lower,
|
||||
*upper;
|
||||
} GBT_VARKEY_R;
|
||||
|
||||
|
||||
@@ -580,28 +580,31 @@ construct_connection_params(ForeignServer *server, UserMapping *user,
|
||||
if (MyProcPort != NULL && MyProcPort->has_scram_keys && UseScramPassthrough(server, user))
|
||||
{
|
||||
int len;
|
||||
char *encoded;
|
||||
int encoded_len;
|
||||
|
||||
keywords[n] = "scram_client_key";
|
||||
len = pg_b64_enc_len(sizeof(MyProcPort->scram_ClientKey));
|
||||
/* don't forget the zero-terminator */
|
||||
values[n] = palloc0(len + 1);
|
||||
encoded = palloc0(len + 1);
|
||||
encoded_len = pg_b64_encode(MyProcPort->scram_ClientKey,
|
||||
sizeof(MyProcPort->scram_ClientKey),
|
||||
(char *) values[n], len);
|
||||
encoded, len);
|
||||
if (encoded_len < 0)
|
||||
elog(ERROR, "could not encode SCRAM client key");
|
||||
values[n] = encoded;
|
||||
n++;
|
||||
|
||||
keywords[n] = "scram_server_key";
|
||||
len = pg_b64_enc_len(sizeof(MyProcPort->scram_ServerKey));
|
||||
/* don't forget the zero-terminator */
|
||||
values[n] = palloc0(len + 1);
|
||||
encoded = palloc0(len + 1);
|
||||
encoded_len = pg_b64_encode(MyProcPort->scram_ServerKey,
|
||||
sizeof(MyProcPort->scram_ServerKey),
|
||||
(char *) values[n], len);
|
||||
encoded, len);
|
||||
if (encoded_len < 0)
|
||||
elog(ERROR, "could not encode SCRAM server key");
|
||||
values[n] = encoded;
|
||||
n++;
|
||||
|
||||
/*
|
||||
|
||||
@@ -60,7 +60,7 @@ xslt_process(PG_FUNCTION_ARGS)
|
||||
volatile xsltSecurityPrefsPtr xslt_sec_prefs = NULL;
|
||||
volatile xsltTransformContextPtr xslt_ctxt = NULL;
|
||||
volatile int resstat = -1;
|
||||
xmlChar *volatile resstr = NULL;
|
||||
xmlChar *volatile resstrv = NULL;
|
||||
|
||||
if (fcinfo->nargs == 3)
|
||||
{
|
||||
@@ -80,6 +80,7 @@ xslt_process(PG_FUNCTION_ARGS)
|
||||
PG_TRY();
|
||||
{
|
||||
bool xslt_sec_prefs_error;
|
||||
xmlChar *resstr = NULL;
|
||||
int reslen = 0;
|
||||
|
||||
/* Parse document */
|
||||
@@ -147,8 +148,8 @@ xslt_process(PG_FUNCTION_ARGS)
|
||||
xml_ereport(xmlerrcxt, ERROR, ERRCODE_INVALID_ARGUMENT_FOR_XQUERY,
|
||||
"failed to apply stylesheet");
|
||||
|
||||
resstat = xsltSaveResultToString((xmlChar **) &resstr, &reslen,
|
||||
restree, stylesheet);
|
||||
resstat = xsltSaveResultToString(&resstr, &reslen, restree, stylesheet);
|
||||
resstrv = resstr;
|
||||
|
||||
if (resstat >= 0)
|
||||
{
|
||||
@@ -176,8 +177,8 @@ xslt_process(PG_FUNCTION_ARGS)
|
||||
xmlFreeDoc(ssdoc);
|
||||
if (doctree != NULL)
|
||||
xmlFreeDoc(doctree);
|
||||
if (resstr != NULL)
|
||||
xmlFree(resstr);
|
||||
if (resstrv != NULL)
|
||||
xmlFree(resstrv);
|
||||
xsltCleanupGlobals();
|
||||
|
||||
pg_xml_done(xmlerrcxt, true);
|
||||
@@ -193,8 +194,8 @@ xslt_process(PG_FUNCTION_ARGS)
|
||||
xmlFreeDoc(doctree);
|
||||
xsltCleanupGlobals();
|
||||
|
||||
if (resstr)
|
||||
xmlFree(resstr);
|
||||
if (resstrv)
|
||||
xmlFree(resstrv);
|
||||
|
||||
pg_xml_done(xmlerrcxt, false);
|
||||
|
||||
|
||||
@@ -722,11 +722,11 @@ multirange_get_range(TypeCacheEntry *rangetyp,
|
||||
* exact size.
|
||||
*/
|
||||
if (RANGE_HAS_LBOUND(flags))
|
||||
ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
|
||||
ptr = att_addlength_pointer(ptr, typlen, ptr);
|
||||
if (RANGE_HAS_UBOUND(flags))
|
||||
{
|
||||
ptr = (char *) att_align_pointer(ptr, typalign, typlen, ptr);
|
||||
ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
|
||||
ptr = att_addlength_pointer(ptr, typlen, ptr);
|
||||
}
|
||||
len = (ptr - begin) + sizeof(RangeType) + sizeof(uint8);
|
||||
|
||||
@@ -773,7 +773,7 @@ multirange_get_bounds(TypeCacheEntry *rangetyp,
|
||||
{
|
||||
/* att_align_pointer cannot be necessary here */
|
||||
lbound = fetch_att(ptr, typbyval, typlen);
|
||||
ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
|
||||
ptr = att_addlength_pointer(ptr, typlen, ptr);
|
||||
}
|
||||
else
|
||||
lbound = (Datum) 0;
|
||||
|
||||
@@ -2117,7 +2117,7 @@ range_deserialize(TypeCacheEntry *typcache, const RangeType *range,
|
||||
{
|
||||
/* att_align_pointer cannot be necessary here */
|
||||
lbound = fetch_att(ptr, typbyval, typlen);
|
||||
ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
|
||||
ptr = att_addlength_pointer(ptr, typlen, ptr);
|
||||
}
|
||||
else
|
||||
lbound = (Datum) 0;
|
||||
|
||||
@@ -1153,9 +1153,9 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
|
||||
int needle_len = state->len2;
|
||||
int skiptablemask = state->skiptablemask;
|
||||
const char *haystack = state->str1;
|
||||
const char *needle = state->str2;
|
||||
char *needle = state->str2;
|
||||
const char *haystack_end = &haystack[haystack_len];
|
||||
const char *hptr;
|
||||
char *hptr;
|
||||
|
||||
Assert(start_ptr >= haystack && start_ptr <= haystack_end);
|
||||
Assert(needle_len > 0);
|
||||
@@ -1184,7 +1184,7 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
|
||||
* collation would accept an empty match, returning one would send
|
||||
* callers that search for successive matches into an infinite loop.)
|
||||
*/
|
||||
const char *result_hptr = NULL;
|
||||
char *result_hptr = NULL;
|
||||
|
||||
hptr = start_ptr;
|
||||
while (hptr < haystack_end)
|
||||
@@ -1198,7 +1198,7 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
|
||||
if (!state->greedy &&
|
||||
haystack_end - hptr >= needle_len &&
|
||||
pg_strncoll(hptr, needle_len, needle, needle_len, state->locale) == 0)
|
||||
return (char *) hptr;
|
||||
return hptr;
|
||||
|
||||
/*
|
||||
* Else check if any of the non-empty substrings starting at hptr
|
||||
@@ -1223,7 +1223,7 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
|
||||
hptr += pg_mblen_range(hptr, haystack_end);
|
||||
}
|
||||
|
||||
return (char *) result_hptr;
|
||||
return result_hptr;
|
||||
}
|
||||
else if (needle_len == 1)
|
||||
{
|
||||
@@ -1234,21 +1234,21 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
|
||||
while (hptr < haystack_end)
|
||||
{
|
||||
if (*hptr == nchar)
|
||||
return (char *) hptr;
|
||||
return hptr;
|
||||
hptr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *needle_last = &needle[needle_len - 1];
|
||||
char *needle_last = &needle[needle_len - 1];
|
||||
|
||||
/* Start at startpos plus the length of the needle */
|
||||
hptr = start_ptr + needle_len - 1;
|
||||
while (hptr < haystack_end)
|
||||
{
|
||||
/* Match the needle scanning *backward* */
|
||||
const char *nptr;
|
||||
const char *p;
|
||||
char *nptr;
|
||||
char *p;
|
||||
|
||||
nptr = needle_last;
|
||||
p = hptr;
|
||||
@@ -1256,7 +1256,7 @@ text_position_next_internal(char *start_ptr, TextPositionState *state)
|
||||
{
|
||||
/* Matched it all? If so, return 1-based position */
|
||||
if (nptr == needle)
|
||||
return (char *) p;
|
||||
return p;
|
||||
nptr--, p--;
|
||||
}
|
||||
|
||||
@@ -4470,7 +4470,7 @@ string_agg_deserialize(PG_FUNCTION_ARGS)
|
||||
bytea *sstate;
|
||||
StringInfo result;
|
||||
StringInfoData buf;
|
||||
char *data;
|
||||
const char *data;
|
||||
int datalen;
|
||||
|
||||
/* cannot be called directly because of internal-type argument */
|
||||
@@ -4492,7 +4492,7 @@ string_agg_deserialize(PG_FUNCTION_ARGS)
|
||||
|
||||
/* data */
|
||||
datalen = VARSIZE_ANY_EXHDR(sstate) - 4;
|
||||
data = (char *) pq_getmsgbytes(&buf, datalen);
|
||||
data = pq_getmsgbytes(&buf, datalen);
|
||||
appendBinaryStringInfo(result, data, datalen);
|
||||
|
||||
pq_getmsgend(&buf);
|
||||
|
||||
@@ -364,7 +364,7 @@ PageValidateSpecialPointer(const PageData *page)
|
||||
#define PageGetSpecialPointer(page) \
|
||||
( \
|
||||
PageValidateSpecialPointer(page), \
|
||||
((page) + ((PageHeader) (page))->pd_special) \
|
||||
((page) + ((const PageHeaderData *) (page))->pd_special) \
|
||||
)
|
||||
|
||||
/*
|
||||
|
||||
@@ -237,7 +237,7 @@ test_custom_stats_var_to_serialized_data(const PgStat_HashKey *key,
|
||||
* be cross-checked with the key read from main stats file at loading
|
||||
* time.
|
||||
*/
|
||||
if (!write_chunk_s(fd_description, (PgStat_HashKey *) key))
|
||||
if (!write_chunk_s(fd_description, key))
|
||||
return false;
|
||||
fd_description_offset += sizeof(PgStat_HashKey);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user