mirror of
https://github.com/postgres/postgres.git
synced 2026-04-21 06:08:26 -04:00
Fix some -Wcast-qual warnings
This fixes some warnings from -Wcast-qual that are easy to fix, without using unconstify or the like. Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Discussion: https://www.postgresql.org/message-id/990c9117-b013-4026-aaf5-261fe2832c3d%40eisentraut.org
This commit is contained in:
parent
65a3ff8f1b
commit
3f98862980
10 changed files with 39 additions and 30 deletions
|
|
@ -244,7 +244,7 @@ ginInsertBAEntries(BuildAccumulator *accum,
|
|||
static int
|
||||
qsortCompareItemPointers(const void *a, const void *b)
|
||||
{
|
||||
int res = ginCompareItemPointers((ItemPointer) a, (ItemPointer) b);
|
||||
int res = ginCompareItemPointers((const ItemPointerData *) a, (const ItemPointerData *) b);
|
||||
|
||||
/* Assert that there are no equal item pointers being sorted */
|
||||
Assert(res != 0);
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ static void read_backend_variables(char *id, void **startup_data, size_t *startu
|
|||
static void restore_backend_variables(BackendParameters *param);
|
||||
|
||||
static bool save_backend_variables(BackendParameters *param, int child_slot,
|
||||
ClientSocket *client_sock,
|
||||
const ClientSocket *client_sock,
|
||||
#ifdef WIN32
|
||||
HANDLE childProcess, pid_t childPid,
|
||||
#endif
|
||||
|
|
@ -162,7 +162,7 @@ static bool save_backend_variables(BackendParameters *param, int child_slot,
|
|||
|
||||
static pid_t internal_forkexec(BackendType child_kind, int child_slot,
|
||||
const void *startup_data, size_t startup_data_len,
|
||||
ClientSocket *client_sock);
|
||||
const ClientSocket *client_sock);
|
||||
|
||||
#endif /* EXEC_BACKEND */
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ PostmasterChildName(BackendType child_type)
|
|||
pid_t
|
||||
postmaster_child_launch(BackendType child_type, int child_slot,
|
||||
void *startup_data, size_t startup_data_len,
|
||||
ClientSocket *client_sock)
|
||||
const ClientSocket *client_sock)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
|
|
@ -283,7 +283,7 @@ postmaster_child_launch(BackendType child_type, int child_slot,
|
|||
*/
|
||||
static pid_t
|
||||
internal_forkexec(BackendType child_kind, int child_slot,
|
||||
const void *startup_data, size_t startup_data_len, ClientSocket *client_sock)
|
||||
const void *startup_data, size_t startup_data_len, const ClientSocket *client_sock)
|
||||
{
|
||||
static unsigned long tmpBackendFileNum = 0;
|
||||
pid_t pid;
|
||||
|
|
@ -393,7 +393,7 @@ internal_forkexec(BackendType child_kind, int child_slot,
|
|||
*/
|
||||
static pid_t
|
||||
internal_forkexec(BackendType child_kind, int child_slot,
|
||||
const void *startup_data, size_t startup_data_len, ClientSocket *client_sock)
|
||||
const void *startup_data, size_t startup_data_len, const ClientSocket *client_sock)
|
||||
{
|
||||
int retry_count = 0;
|
||||
STARTUPINFO si;
|
||||
|
|
@ -700,7 +700,7 @@ static void read_inheritable_socket(SOCKET *dest, InheritableSocket *src);
|
|||
/* Save critical backend variables into the BackendParameters struct */
|
||||
static bool
|
||||
save_backend_variables(BackendParameters *param,
|
||||
int child_slot, ClientSocket *client_sock,
|
||||
int child_slot, const ClientSocket *client_sock,
|
||||
#ifdef WIN32
|
||||
HANDLE childProcess, pid_t childPid,
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -372,6 +372,7 @@ xml_recv(PG_FUNCTION_ARGS)
|
|||
#ifdef USE_LIBXML
|
||||
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
||||
xmltype *result;
|
||||
const char *input;
|
||||
char *str;
|
||||
char *newstr;
|
||||
int nbytes;
|
||||
|
|
@ -385,7 +386,7 @@ xml_recv(PG_FUNCTION_ARGS)
|
|||
* parse that before converting to server encoding.
|
||||
*/
|
||||
nbytes = buf->len - buf->cursor;
|
||||
str = (char *) pq_getmsgbytes(buf, nbytes);
|
||||
input = pq_getmsgbytes(buf, nbytes);
|
||||
|
||||
/*
|
||||
* We need a null-terminated string to pass to parse_xml_decl(). Rather
|
||||
|
|
@ -394,7 +395,7 @@ xml_recv(PG_FUNCTION_ARGS)
|
|||
*/
|
||||
result = palloc(nbytes + 1 + VARHDRSZ);
|
||||
SET_VARSIZE(result, nbytes + VARHDRSZ);
|
||||
memcpy(VARDATA(result), str, nbytes);
|
||||
memcpy(VARDATA(result), input, nbytes);
|
||||
str = VARDATA(result);
|
||||
str[nbytes] = '\0';
|
||||
|
||||
|
|
|
|||
|
|
@ -2932,7 +2932,6 @@ GetACPEncoding(void)
|
|||
static void
|
||||
write_eventlog(int level, const char *line, int len)
|
||||
{
|
||||
WCHAR *utf16;
|
||||
int eventlevel = EVENTLOG_ERROR_TYPE;
|
||||
static HANDLE evtHandle = INVALID_HANDLE_VALUE;
|
||||
|
||||
|
|
@ -2989,9 +2988,13 @@ write_eventlog(int level, const char *line, int len)
|
|||
CurrentMemoryContext != NULL &&
|
||||
GetMessageEncoding() != GetACPEncoding())
|
||||
{
|
||||
WCHAR *utf16;
|
||||
|
||||
utf16 = pgwin32_message_to_UTF16(line, len, NULL);
|
||||
if (utf16)
|
||||
{
|
||||
const WCHAR *utf16_const = utf16;
|
||||
|
||||
ReportEventW(evtHandle,
|
||||
eventlevel,
|
||||
0,
|
||||
|
|
@ -2999,7 +3002,7 @@ write_eventlog(int level, const char *line, int len)
|
|||
NULL,
|
||||
1,
|
||||
0,
|
||||
(LPCWSTR *) &utf16,
|
||||
&utf16_const,
|
||||
NULL);
|
||||
/* XXX Try ReportEventA() when ReportEventW() fails? */
|
||||
|
||||
|
|
|
|||
|
|
@ -2167,9 +2167,9 @@ json_lex_string(JsonLexContext *lex)
|
|||
* can batch calls to jsonapi_appendBinaryStringInfo.
|
||||
*/
|
||||
while (p < end - sizeof(Vector8) &&
|
||||
!pg_lfind8('\\', (uint8 *) p, sizeof(Vector8)) &&
|
||||
!pg_lfind8('"', (uint8 *) p, sizeof(Vector8)) &&
|
||||
!pg_lfind8_le(31, (uint8 *) p, sizeof(Vector8)))
|
||||
!pg_lfind8('\\', (const uint8 *) p, sizeof(Vector8)) &&
|
||||
!pg_lfind8('"', (const uint8 *) p, sizeof(Vector8)) &&
|
||||
!pg_lfind8_le(31, (const uint8 *) p, sizeof(Vector8)))
|
||||
p += sizeof(Vector8);
|
||||
|
||||
for (; p < end; p++)
|
||||
|
|
|
|||
|
|
@ -121,14 +121,14 @@ astreamer_lz4_compressor_content(astreamer *streamer,
|
|||
astreamer_archive_context context)
|
||||
{
|
||||
astreamer_lz4_frame *mystreamer;
|
||||
uint8 *next_in,
|
||||
*next_out;
|
||||
const uint8 *next_in;
|
||||
uint8 *next_out;
|
||||
size_t out_bound,
|
||||
compressed_size,
|
||||
avail_out;
|
||||
|
||||
mystreamer = (astreamer_lz4_frame *) streamer;
|
||||
next_in = (uint8 *) data;
|
||||
next_in = (const uint8 *) data;
|
||||
|
||||
/* Write header before processing the first input chunk. */
|
||||
if (!mystreamer->header_written)
|
||||
|
|
@ -315,13 +315,13 @@ astreamer_lz4_decompressor_content(astreamer *streamer,
|
|||
astreamer_archive_context context)
|
||||
{
|
||||
astreamer_lz4_frame *mystreamer;
|
||||
uint8 *next_in,
|
||||
*next_out;
|
||||
const uint8 *next_in;
|
||||
uint8 *next_out;
|
||||
size_t avail_in,
|
||||
avail_out;
|
||||
|
||||
mystreamer = (astreamer_lz4_frame *) streamer;
|
||||
next_in = (uint8 *) data;
|
||||
next_in = (const uint8 *) data;
|
||||
next_out = (uint8 *) mystreamer->base.bbs_buffer.data + mystreamer->bytes_written;
|
||||
avail_in = len;
|
||||
avail_out = mystreamer->base.bbs_buffer.maxlen - mystreamer->bytes_written;
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ extern ItemPointer ginMergeItemPointers(ItemPointerData *a, uint32 na,
|
|||
* so we want this to be inlined.
|
||||
*/
|
||||
static inline int
|
||||
ginCompareItemPointers(ItemPointer a, ItemPointer b)
|
||||
ginCompareItemPointers(const ItemPointerData *a, const ItemPointerData *b)
|
||||
{
|
||||
uint64 ia = (uint64) GinItemPointerGetBlockNumber(a) << 32 | GinItemPointerGetOffsetNumber(a);
|
||||
uint64 ib = (uint64) GinItemPointerGetBlockNumber(b) << 32 | GinItemPointerGetOffsetNumber(b);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
* return false.
|
||||
*/
|
||||
static inline bool
|
||||
pg_lfind8(uint8 key, uint8 *base, uint32 nelem)
|
||||
pg_lfind8(uint8 key, const uint8 *base, uint32 nelem)
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ pg_lfind8(uint8 key, uint8 *base, uint32 nelem)
|
|||
* 'key', otherwise return false.
|
||||
*/
|
||||
static inline bool
|
||||
pg_lfind8_le(uint8 key, uint8 *base, uint32 nelem)
|
||||
pg_lfind8_le(uint8 key, const uint8 *base, uint32 nelem)
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ extern pid_t postmaster_child_launch(BackendType child_type,
|
|||
int child_slot,
|
||||
void *startup_data,
|
||||
size_t startup_data_len,
|
||||
struct ClientSocket *client_sock);
|
||||
const struct ClientSocket *client_sock);
|
||||
const char *PostmasterChildName(BackendType child_type);
|
||||
#ifdef EXEC_BACKEND
|
||||
pg_noreturn extern void SubPostmasterMain(int argc, char *argv[]);
|
||||
|
|
|
|||
|
|
@ -260,14 +260,19 @@ base_yylex_location(void)
|
|||
break;
|
||||
default:
|
||||
/* Else just use the input, i.e., yytext */
|
||||
base_yylloc = loc_strdup(base_yytext);
|
||||
/* Apply an ASCII-only downcasing */
|
||||
for (unsigned char *ptr = (unsigned char *) base_yylloc; *ptr; ptr++)
|
||||
{
|
||||
if (*ptr >= 'A' && *ptr <= 'Z')
|
||||
*ptr += 'a' - 'A';
|
||||
char *tmp;
|
||||
|
||||
tmp = loc_strdup(base_yytext);
|
||||
/* Apply an ASCII-only downcasing */
|
||||
for (unsigned char *ptr = (unsigned char *) tmp; *ptr; ptr++)
|
||||
{
|
||||
if (*ptr >= 'A' && *ptr <= 'Z')
|
||||
*ptr += 'a' - 'A';
|
||||
}
|
||||
base_yylloc = tmp;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue