]> granicus.if.org Git - postgresql/commitdiff
More unconstify use
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 29 Jan 2019 00:16:24 +0000 (01:16 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 13 Feb 2019 10:50:16 +0000 (11:50 +0100)
Replace casts whose only purpose is to cast away const with the
unconstify() macro.

Discussion: https://www.postgresql.org/message-id/flat/53a28052-f9f3-1808-fed9-460fd43035ab%402ndquadrant.com

25 files changed:
contrib/btree_gist/btree_utils_num.c
contrib/pgcrypto/imath.c
contrib/pgcrypto/md5.c
contrib/pgcrypto/pgp-compress.c
src/backend/access/brin/brin_pageops.c
src/backend/access/transam/xact.c
src/backend/executor/spi.c
src/backend/libpq/auth.c
src/backend/libpq/be-secure-openssl.c
src/backend/parser/parse_type.c
src/backend/replication/logical/message.c
src/backend/tcop/postgres.c
src/backend/utils/adt/formatting.c
src/backend/utils/mb/mbutils.c
src/backend/utils/misc/guc.c
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/walmethods.c
src/bin/pg_dump/compress_io.c
src/bin/psql/prompt.c
src/fe_utils/print.c
src/interfaces/libpq/fe-lobj.c
src/interfaces/libpq/pqexpbuffer.c
src/pl/tcl/pltcl.c
src/port/path.c
src/timezone/localtime.c

index 4d10bc93f3ea3e075514742bff6813df911ac131..7564a403c7db1068470983034c186308dfe76875 100644 (file)
@@ -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);
        }
 }
 
index b94a51b81a458fba704fbe1107515e4b652956df..c267ea6ab334ccde2cecaa7d940107789fda6356 100644 (file)
@@ -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
index cac4e408ab40db444668ec72e3908ad439b60df2..5bcfbfe28f1435f9868b9e0e76b7b8a6864e5bc5 100644 (file)
@@ -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);
index 57efe73338613f037e516498b1d337c06f9ff27d..eaeb221877f9119ffdbd5029bfb3883e46d7a4cb 100644 (file)
@@ -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;
index 2eb354f948f964e816de9f6f3128e57a30eba138..2e83aa42f786e493f3ea18e94ffa0b15e41b810b 100644 (file)
@@ -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);
index 92bda87804326dd16389f6c387d5529b063024ed..e93262975d3d276c4c2e227162fb912bbb0943d1 100644 (file)
@@ -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)
index 94a53e0e3f6b747205dec91d5bfe76fe9b7a4e27..70c03e0f605728e29d7dd1adb6334045ec22582d 100644 (file)
@@ -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.
index 20fe98fb8264646fa5d3b687ffe34dbd08c7ddc4..c42f7b8fe6a3fa2414889e1fde254924f3583e33 100644 (file)
@@ -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 */
index d1417454f2b4d8fd7b9b0d54662553683c29ed3b..4490516b9e2209b67cb9502c8267db5f7c7cc390 100644 (file)
@@ -866,7 +866,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);
index 8d57e83ac69d58ea042069db78f8911efcc87ebf..5d554633d2c420c334205e6a4feb1cd7aed9dc95 100644 (file)
@@ -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;
 
index 4b13189dde6a8d5171758d6f92b0a9d4d3afbdee..0681cb4a2a459358262d068154c629bb483085a3 100644 (file)
@@ -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);
index 36cfd507b2efbe7c58c14a6b6e97a357f2a9219a..8b4d94c9a135813ba123f9e5411ccc1069bfab80 100644 (file)
@@ -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;
index 096d862c1ded7af7df4d8f14a32934ceff780fb5..df1db7bc9f10827e0d22c57aa678bb366370652c 100644 (file)
@@ -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");
index c8e5571d9757224f32bac179b264f9ae2832b6e9..aa18c9ad3d91b8af575cec798ddab5743c477cb4 100644 (file)
@@ -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
index 41d477165cd796a22402b41502a2f75f95201af3..3a4a113b6259f1f93abd11968d524266aa0a32c6 100644 (file)
@@ -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;
        }
index 594d67c9e9191839c0125d7cdc2e6278a8ca99a0..3d2d4cd0b9428a74868aa6d8650582bddeeff4b2 100644 (file)
@@ -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);
                }
index 7410af3e637510213353e2671d770f939f758649..165b3a1e896793340ee68d53b63ce64150af8d23 100644 (file)
@@ -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;
index e34e6c5618fe8622575d530c278711f7cd9751f7..d904ec62ad1f175d1c1f74fc110faf3f0cc2f81e 100644 (file)
@@ -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);
 
index 73394dc828d59ab261bf68832653c548b439fae1..4514cf8551c3b8196daf1ec61cb7aeb305a7f9c4 100644 (file)
@@ -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':
index 4f84c24dacb04dc99138d7471031fd67da730c10..779a95e8bc1810eb988c6c2f2e80913096efe439 100644 (file)
@@ -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;
index 3c6f11a7d79ce8fd5eb970a33fafb8309afb54ba..6866d645380a386655c81f569019f085cdc2137a 100644 (file)
@@ -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);
index 498f82bd9946795c52c2e9cbb0e57ac938681f55..dc7c3ea07d4fde12981b72058c2f93d5818e7b36 100644 (file)
@@ -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;
 }
index bfbf62305c30c55d48a172416204e90d237f0096..76c9afc33912b4793006426c38781b810ae70a18 100644 (file)
@@ -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));
        }
 }
 
index 661017f8777a55ac0d691bcfd031825f0ff03a62..4b214e89e4ebaff74d17cfb1ca9835c50327a7ef 100644 (file)
@@ -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);
 }
 
 
index 96e62aff3b4372d8613dfc43a94a4d40a62389a1..9fe43135fe34d22977cc8a849944b9b5e0151920 100644 (file)
@@ -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;
 }