From 8dc004406f742dce9c76d0b922f45fdfda174ea3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 29 Jan 2019 01:16:24 +0100 Subject: [PATCH v1 2/5] More unconstify use Replace casts whose only purpose is to cast away const with the unconstify() macro. --- contrib/btree_gist/btree_utils_num.c | 8 ++++---- contrib/pgcrypto/imath.c | 2 +- contrib/pgcrypto/md5.c | 2 +- contrib/pgcrypto/pgp-compress.c | 2 +- src/backend/access/brin/brin_pageops.c | 8 ++++---- src/backend/access/transam/xact.c | 4 ++-- src/backend/executor/spi.c | 10 +++++----- src/backend/libpq/auth.c | 10 +++++----- src/backend/libpq/be-secure-openssl.c | 2 +- src/backend/parser/parse_type.c | 2 +- src/backend/replication/logical/message.c | 4 ++-- src/backend/tcop/postgres.c | 2 +- src/backend/utils/adt/formatting.c | 2 +- src/backend/utils/mb/mbutils.c | 20 ++++++++++---------- src/backend/utils/misc/guc.c | 2 +- src/bin/pg_basebackup/pg_basebackup.c | 2 +- src/bin/pg_basebackup/walmethods.c | 2 +- src/bin/pg_dump/compress_io.c | 2 +- src/bin/psql/prompt.c | 2 +- src/fe_utils/print.c | 2 +- src/interfaces/libpq/fe-lobj.c | 2 +- src/interfaces/libpq/pqexpbuffer.c | 8 +++++--- src/pl/tcl/pltcl.c | 4 ++-- src/port/path.c | 6 +++--- src/timezone/localtime.c | 2 +- 25 files changed, 57 insertions(+), 55 deletions(-) diff --git a/contrib/btree_gist/btree_utils_num.c b/contrib/btree_gist/btree_utils_num.c index 4d10bc93f3..7564a403c7 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, c.lower, tinfo->size); + memcpy(unconstify(GBT_NUMKEY *, 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, c.upper, tinfo->size); + memcpy(unconstify(GBT_NUMKEY *, o.upper), c.upper, tinfo->size); } return out; @@ -237,9 +237,9 @@ 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(ur.lower, rd.lower, flinfo)) - memcpy((void *) ur.lower, rd.lower, tinfo->size); + memcpy(unconstify(GBT_NUMKEY *, ur.lower), rd.lower, tinfo->size); if (tinfo->f_lt(ur.upper, rd.upper, flinfo)) - memcpy((void *) ur.upper, rd.upper, tinfo->size); + memcpy(unconstify(GBT_NUMKEY *, ur.upper), rd.upper, tinfo->size); } } diff --git a/contrib/pgcrypto/imath.c b/contrib/pgcrypto/imath.c index b94a51b81a..c267ea6ab3 100644 --- a/contrib/pgcrypto/imath.c +++ b/contrib/pgcrypto/imath.c @@ -2050,7 +2050,7 @@ mp_int_read_cstring(mp_int z, mp_size radix, const char *str, char **end) MP_SIGN(z) = MP_ZPOS; if (end != NULL) - *end = (char *) str; + *end = unconstify(char *, str); /* * Return a truncation error if the string has unprocessed characters diff --git a/contrib/pgcrypto/md5.c b/contrib/pgcrypto/md5.c index cac4e408ab..5bcfbfe28f 100644 --- a/contrib/pgcrypto/md5.c +++ b/contrib/pgcrypto/md5.c @@ -161,7 +161,7 @@ md5_loop(md5_ctxt *ctxt, const uint8 *input, unsigned len) md5_calc(ctxt->md5_buf, ctxt); for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN) - md5_calc((uint8 *) (input + i), ctxt); + md5_calc(unconstify(uint8 *, (input + i)), ctxt); ctxt->md5_i = len - i; memmove(ctxt->md5_buf, input + i, ctxt->md5_i); diff --git a/contrib/pgcrypto/pgp-compress.c b/contrib/pgcrypto/pgp-compress.c index 57efe73338..eaeb221877 100644 --- a/contrib/pgcrypto/pgp-compress.c +++ b/contrib/pgcrypto/pgp-compress.c @@ -117,7 +117,7 @@ compress_process(PushFilter *next, void *priv, const uint8 *data, int len) */ while (len > 0) { - st->stream.next_in = (void *) data; + st->stream.next_in = unconstify(uint8 *, data); st->stream.avail_in = len; st->stream.next_out = st->buf; st->stream.avail_out = st->buf_len; diff --git a/src/backend/access/brin/brin_pageops.c b/src/backend/access/brin/brin_pageops.c index 2eb354f948..2e83aa42f7 100644 --- a/src/backend/access/brin/brin_pageops.c +++ b/src/backend/access/brin/brin_pageops.c @@ -178,7 +178,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, brin_can_do_samepage_update(oldbuf, origsz, newsz)) { START_CRIT_SECTION(); - if (!PageIndexTupleOverwrite(oldpage, oldoff, (Item) newtup, newsz)) + if (!PageIndexTupleOverwrite(oldpage, oldoff, (Item) unconstify(BrinTuple *, newtup), newsz)) elog(ERROR, "failed to replace BRIN tuple"); MarkBufferDirty(oldbuf); @@ -195,7 +195,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, XLogRegisterData((char *) &xlrec, SizeOfBrinSamepageUpdate); XLogRegisterBuffer(0, oldbuf, REGBUF_STANDARD); - XLogRegisterBufData(0, (char *) newtup, newsz); + XLogRegisterBufData(0, (char *) unconstify(BrinTuple *, newtup), newsz); recptr = XLogInsert(RM_BRIN_ID, info); @@ -252,7 +252,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, brin_page_init(newpage, BRIN_PAGETYPE_REGULAR); PageIndexTupleDeleteNoCompact(oldpage, oldoff); - newoff = PageAddItem(newpage, (Item) newtup, newsz, + newoff = PageAddItem(newpage, (Item) unconstify(BrinTuple *, newtup), newsz, InvalidOffsetNumber, false, false); if (newoff == InvalidOffsetNumber) elog(ERROR, "failed to add BRIN tuple to new page"); @@ -287,7 +287,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, XLogRegisterData((char *) &xlrec, SizeOfBrinUpdate); XLogRegisterBuffer(0, newbuf, REGBUF_STANDARD | (extended ? REGBUF_WILL_INIT : 0)); - XLogRegisterBufData(0, (char *) newtup, newsz); + XLogRegisterBufData(0, (char *) unconstify(BrinTuple *, newtup), newsz); /* revmap page */ XLogRegisterBuffer(1, revmapbuf, 0); diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 92bda87804..e93262975d 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -5409,7 +5409,7 @@ XactLogCommitRecord(TimestampTz commit_time, { XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase)); if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID) - XLogRegisterData((char *) twophase_gid, strlen(twophase_gid) + 1); + XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) + 1); } if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN) @@ -5537,7 +5537,7 @@ XactLogAbortRecord(TimestampTz abort_time, { XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase)); if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID) - XLogRegisterData((char *) twophase_gid, strlen(twophase_gid) + 1); + XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) + 1); } if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN) diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 94a53e0e3f..70c03e0f60 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -1314,7 +1314,7 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan, * throws an error. */ spierrcontext.callback = _SPI_error_callback; - spierrcontext.arg = (void *) plansource->query_string; + spierrcontext.arg = unconstify(char *, plansource->query_string); spierrcontext.previous = error_context_stack; error_context_stack = &spierrcontext; @@ -1753,7 +1753,7 @@ SPI_plan_get_cached_plan(SPIPlanPtr plan) /* Setup error traceback support for ereport() */ spierrcontext.callback = _SPI_error_callback; - spierrcontext.arg = (void *) plansource->query_string; + spierrcontext.arg = unconstify(char *, plansource->query_string); spierrcontext.previous = error_context_stack; error_context_stack = &spierrcontext; @@ -1884,7 +1884,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan) * Setup error traceback support for ereport() */ spierrcontext.callback = _SPI_error_callback; - spierrcontext.arg = (void *) src; + spierrcontext.arg = unconstify(char *, src); spierrcontext.previous = error_context_stack; error_context_stack = &spierrcontext; @@ -1989,7 +1989,7 @@ _SPI_prepare_oneshot_plan(const char *src, SPIPlanPtr plan) * Setup error traceback support for ereport() */ spierrcontext.callback = _SPI_error_callback; - spierrcontext.arg = (void *) src; + spierrcontext.arg = unconstify(char *, src); spierrcontext.previous = error_context_stack; error_context_stack = &spierrcontext; @@ -2100,7 +2100,7 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI, List *stmt_list; ListCell *lc2; - spierrcontext.arg = (void *) plansource->query_string; + spierrcontext.arg = unconstify(char *, plansource->query_string); /* * If this is a one-shot plan, we still need to do parse analysis. diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 20fe98fb82..c42f7b8fe6 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -867,7 +867,7 @@ CheckSCRAMAuth(Port *port, char *shadow_pass, char **logdetail) void *scram_opaq = NULL; char *output = NULL; int outputlen = 0; - char *input; + const char *input; int inputlen; int result; bool initial; @@ -964,14 +964,14 @@ CheckSCRAMAuth(Port *port, char *shadow_pass, char **logdetail) if (inputlen == -1) input = NULL; else - input = (char *) pq_getmsgbytes(&buf, inputlen); + input = pq_getmsgbytes(&buf, inputlen); initial = false; } else { inputlen = buf.len; - input = (char *) pq_getmsgbytes(&buf, buf.len); + input = pq_getmsgbytes(&buf, buf.len); } pq_getmsgend(&buf); @@ -985,7 +985,7 @@ CheckSCRAMAuth(Port *port, char *shadow_pass, char **logdetail) * we pass 'logdetail' as NULL when doing a mock authentication, * because we should already have a better error message in that case */ - result = pg_be_scram_exchange(scram_opaq, input, inputlen, + result = pg_be_scram_exchange(scram_opaq, unconstify(char *, input), inputlen, &output, &outputlen, logdetail); @@ -2175,7 +2175,7 @@ CheckPAMAuth(Port *port, const char *user, const char *password) * later used inside the PAM conversation to pass the password to the * authentication module. */ - pam_passw_conv.appdata_ptr = (char *) password; /* from password above, + pam_passw_conv.appdata_ptr = unconstify(char *, password); /* from password above, * not allocated */ /* Optionally, one can set the service name in pg_hba.conf */ diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c index a2779543ec..3a3d041039 100644 --- a/src/backend/libpq/be-secure-openssl.c +++ b/src/backend/libpq/be-secure-openssl.c @@ -854,7 +854,7 @@ load_dh_buffer(const char *buffer, size_t len) BIO *bio; DH *dh = NULL; - bio = BIO_new_mem_buf((char *) buffer, len); + bio = BIO_new_mem_buf(unconstify(char *, buffer), len); if (bio == NULL) return NULL; dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index 8d57e83ac6..5d554633d2 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -739,7 +739,7 @@ typeStringToTypeName(const char *str) * Setup error traceback support in case of ereport() during parse */ ptserrcontext.callback = pts_error_callback; - ptserrcontext.arg = (void *) str; + ptserrcontext.arg = unconstify(char *, str); ptserrcontext.previous = error_context_stack; error_context_stack = &ptserrcontext; diff --git a/src/backend/replication/logical/message.c b/src/backend/replication/logical/message.c index 4b13189dde..0681cb4a2a 100644 --- a/src/backend/replication/logical/message.c +++ b/src/backend/replication/logical/message.c @@ -69,8 +69,8 @@ LogLogicalMessage(const char *prefix, const char *message, size_t size, XLogBeginInsert(); XLogRegisterData((char *) &xlrec, SizeOfLogicalMessage); - XLogRegisterData((char *) prefix, xlrec.prefix_size); - XLogRegisterData((char *) message, size); + XLogRegisterData(unconstify(char *, prefix), xlrec.prefix_size); + XLogRegisterData(unconstify(char *, message), size); /* allow origin filtering */ XLogSetRecordFlags(XLOG_INCLUDE_ORIGIN); diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 36cfd507b2..8b4d94c9a1 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -1767,7 +1767,7 @@ exec_bind_message(StringInfo input_message) * trailing null. This is grotty but is a big win when * dealing with very large parameter strings. */ - pbuf.data = (char *) pvalue; + pbuf.data = unconstify(char *, pvalue); pbuf.maxlen = plength + 1; pbuf.len = plength; pbuf.cursor = 0; diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 096d862c1d..df1db7bc9f 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -3688,7 +3688,7 @@ to_timestamp(PG_FUNCTION_ARGS) /* Use the specified time zone, if any. */ if (tm.tm_zone) { - int dterr = DecodeTimezone((char *) tm.tm_zone, &tz); + int dterr = DecodeTimezone(unconstify(char *, tm.tm_zone), &tz); if (dterr) DateTimeParseError(dterr, text_to_cstring(date_txt), "timestamptz"); diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index c8e5571d97..aa18c9ad3d 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -464,7 +464,7 @@ pg_convert(PG_FUNCTION_ARGS) pg_verify_mbstr_len(src_encoding, src_str, len, false); /* perform conversion */ - dest_str = (char *) pg_do_encoding_conversion((unsigned char *) src_str, + dest_str = (char *) pg_do_encoding_conversion((unsigned char *) unconstify(char *, src_str), len, src_encoding, dest_encoding); @@ -561,7 +561,7 @@ char * pg_any_to_server(const char *s, int len, int encoding) { if (len <= 0) - return (char *) s; /* empty string is always valid */ + return unconstify(char *, s); /* empty string is always valid */ if (encoding == DatabaseEncoding->encoding || encoding == PG_SQL_ASCII) @@ -570,7 +570,7 @@ pg_any_to_server(const char *s, int len, int encoding) * No conversion is needed, but we must still validate the data. */ (void) pg_verify_mbstr(DatabaseEncoding->encoding, s, len, false); - return (char *) s; + return unconstify(char *, s); } if (DatabaseEncoding->encoding == PG_SQL_ASCII) @@ -600,7 +600,7 @@ pg_any_to_server(const char *s, int len, int encoding) (unsigned char) s[i]))); } } - return (char *) s; + return unconstify(char *, s); } /* Fast path if we can use cached conversion function */ @@ -608,7 +608,7 @@ pg_any_to_server(const char *s, int len, int encoding) return perform_default_encoding_conversion(s, len, true); /* General case ... will not work outside transactions */ - return (char *) pg_do_encoding_conversion((unsigned char *) s, + return (char *) pg_do_encoding_conversion((unsigned char *) unconstify(char *, s), len, encoding, DatabaseEncoding->encoding); @@ -634,17 +634,17 @@ char * pg_server_to_any(const char *s, int len, int encoding) { if (len <= 0) - return (char *) s; /* empty string is always valid */ + return unconstify(char *, s); /* empty string is always valid */ if (encoding == DatabaseEncoding->encoding || encoding == PG_SQL_ASCII) - return (char *) s; /* assume data is valid */ + return unconstify(char *, s); /* assume data is valid */ if (DatabaseEncoding->encoding == PG_SQL_ASCII) { /* No conversion is possible, but we must validate the result */ (void) pg_verify_mbstr(encoding, s, len, false); - return (char *) s; + return unconstify(char *, s); } /* Fast path if we can use cached conversion function */ @@ -652,7 +652,7 @@ pg_server_to_any(const char *s, int len, int encoding) return perform_default_encoding_conversion(s, len, false); /* General case ... will not work outside transactions */ - return (char *) pg_do_encoding_conversion((unsigned char *) s, + return (char *) pg_do_encoding_conversion((unsigned char *) unconstify(char *, s), len, DatabaseEncoding->encoding, encoding); @@ -687,7 +687,7 @@ perform_default_encoding_conversion(const char *src, int len, } if (flinfo == NULL) - return (char *) src; + return unconstify(char *, src); /* * Allocate space for conversion result, being wary of integer overflow diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 8681ada33a..57595cfb95 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4897,7 +4897,7 @@ add_placeholder_variable(const char *name, int elevel) if (!add_guc_variable((struct config_generic *) var, elevel)) { - free((void *) gen->name); + free(unconstify(char *, gen->name)); free(var); return NULL; } diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 594d67c9e9..3d2d4cd0b9 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -1970,7 +1970,7 @@ BaseBackup(void) */ if (format == 'p' && !PQgetisnull(res, i, 1)) { - char *path = (char *) get_tablespace_mapping(PQgetvalue(res, i, 1)); + char *path = unconstify(char *, get_tablespace_mapping(PQgetvalue(res, i, 1))); verify_dir_is_empty_or_create(path, &made_tablespace_dirs, &found_tablespace_dirs); } diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c index 7410af3e63..165b3a1e89 100644 --- a/src/bin/pg_basebackup/walmethods.c +++ b/src/bin/pg_basebackup/walmethods.c @@ -496,7 +496,7 @@ tar_write(Walfile f, const void *buf, size_t count) #ifdef HAVE_LIBZ else { - if (!tar_write_compressed_data((void *) buf, count, false)) + if (!tar_write_compressed_data(unconstify(void *, buf), count, false)) return -1; ((TarMethodFile *) f)->currpos += count; return count; diff --git a/src/bin/pg_dump/compress_io.c b/src/bin/pg_dump/compress_io.c index e34e6c5618..d904ec62ad 100644 --- a/src/bin/pg_dump/compress_io.c +++ b/src/bin/pg_dump/compress_io.c @@ -312,7 +312,7 @@ static void WriteDataToArchiveZlib(ArchiveHandle *AH, CompressorState *cs, const char *data, size_t dLen) { - cs->zp->next_in = (void *) data; + cs->zp->next_in = (void *) unconstify(char *, data); cs->zp->avail_in = dLen; DeflateCompressorZlib(AH, cs, false); diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index 73394dc828..4514cf8551 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -181,7 +181,7 @@ get_prompt(promptStatus_t status, ConditionalStack cstack) case '5': case '6': case '7': - *buf = (char) strtol(p, (char **) &p, 8); + *buf = (char) strtol(p, unconstify(char **, &p), 8); --p; break; case 'R': diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c index 4f84c24dac..779a95e8bc 100644 --- a/src/fe_utils/print.c +++ b/src/fe_utils/print.c @@ -3250,7 +3250,7 @@ printTableCleanup(printTableContent *const content) for (i = 0; i < content->nrows * content->ncolumns; i++) { if (content->cellmustfree[i]) - free((char *) content->cells[i]); + free(unconstify(char *, content->cells[i])); } free(content->cellmustfree); content->cellmustfree = NULL; diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 3c6f11a7d7..6866d64538 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -341,7 +341,7 @@ lo_write(PGconn *conn, int fd, const char *buf, size_t len) argv[1].isint = 0; argv[1].len = (int) len; - argv[1].u.ptr = (int *) buf; + argv[1].u.ptr = (int *) unconstify(char *, buf); res = PQfn(conn, conn->lobjfuncs->fn_lo_write, &retval, &result_len, 1, argv, 2); diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c index 498f82bd99..dc7c3ea07d 100644 --- a/src/interfaces/libpq/pqexpbuffer.c +++ b/src/interfaces/libpq/pqexpbuffer.c @@ -36,6 +36,8 @@ /* All "broken" PQExpBuffers point to this string. */ static const char oom_buffer[1] = ""; +/* Need a char * for unconstify() compatiblity */ +static const char * oom_buffer_ptr = oom_buffer; static bool appendPQExpBufferVA(PQExpBuffer str, const char *fmt, va_list args) pg_attribute_printf(2, 0); @@ -57,7 +59,7 @@ markPQExpBufferBroken(PQExpBuffer str) * to put oom_buffer in read-only storage, so that anyone who tries to * scribble on a broken PQExpBuffer will get a failure. */ - str->data = (char *) oom_buffer; + str->data = unconstify(char *, oom_buffer_ptr); str->len = 0; str->maxlen = 0; } @@ -91,7 +93,7 @@ initPQExpBuffer(PQExpBuffer str) str->data = (char *) malloc(INITIAL_EXPBUFFER_SIZE); if (str->data == NULL) { - str->data = (char *) oom_buffer; /* see comment above */ + str->data = unconstify(char *, oom_buffer_ptr); /* see comment above */ str->maxlen = 0; str->len = 0; } @@ -130,7 +132,7 @@ termPQExpBuffer(PQExpBuffer str) if (str->data != oom_buffer) free(str->data); /* just for luck, make the buffer validly empty. */ - str->data = (char *) oom_buffer; /* see comment above */ + str->data = unconstify(char *, oom_buffer_ptr); /* see comment above */ str->maxlen = 0; str->len = 0; } diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index bfbf62305c..76c9afc339 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -610,7 +610,7 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted) /* Set up errcontext callback to make errors more helpful */ errcallback.callback = start_proc_error_callback; - errcallback.arg = (void *) gucname; + errcallback.arg = unconstify(char *, gucname); errcallback.previous = error_context_stack; error_context_stack = &errcallback; @@ -3081,7 +3081,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, const char *arrayname, else Tcl_UnsetVar2(interp, *arrptr, *nameptr, 0); - pfree((char *) attname); + pfree(unconstify(char *, attname)); } } diff --git a/src/port/path.c b/src/port/path.c index 661017f877..4b214e89e4 100644 --- a/src/port/path.c +++ b/src/port/path.c @@ -106,7 +106,7 @@ first_dir_separator(const char *filename) for (p = skip_drive(filename); *p; p++) if (IS_DIR_SEP(*p)) - return (char *) p; + return unconstify(char *, p); return NULL; } @@ -124,7 +124,7 @@ first_path_var_separator(const char *pathlist) /* skip_drive is not needed */ for (p = pathlist; *p; p++) if (IS_PATH_VAR_SEP(*p)) - return (char *) p; + return unconstify(char *, p); return NULL; } @@ -143,7 +143,7 @@ last_dir_separator(const char *filename) for (p = skip_drive(filename); *p; p++) if (IS_DIR_SEP(*p)) ret = p; - return (char *) ret; + return unconstify(char *, ret); } diff --git a/src/timezone/localtime.c b/src/timezone/localtime.c index 96e62aff3b..9fe43135fe 100644 --- a/src/timezone/localtime.c +++ b/src/timezone/localtime.c @@ -1364,7 +1364,7 @@ localsub(struct state const *sp, pg_time_t const *timep, if (result) { result->tm_isdst = ttisp->tt_isdst; - result->tm_zone = (char *) &sp->chars[ttisp->tt_abbrind]; + result->tm_zone = unconstify(char *, &sp->chars[ttisp->tt_abbrind]); } return result; } -- 2.20.1