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;
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);
}
}
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
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);
*/
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;
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);
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);
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");
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);
{
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)
{
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)
* 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;
/* 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;
* 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;
* 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;
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.
void *scram_opaq = NULL;
char *output = NULL;
int outputlen = 0;
- char *input;
+ const char *input;
int inputlen;
int result;
bool initial;
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);
* 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);
* 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 */
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);
* 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;
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);
* 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;
/* 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");
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);
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)
* 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)
(unsigned char) s[i])));
}
}
- return (char *) s;
+ return unconstify(char *, s);
}
/* Fast path if we can use cached conversion function */
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);
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 */
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);
}
if (flinfo == NULL)
- return (char *) src;
+ return unconstify(char *, src);
/*
* Allocate space for conversion result, being wary of integer overflow
if (!add_guc_variable((struct config_generic *) var, elevel))
{
- free((void *) gen->name);
+ free(unconstify(char *, gen->name));
free(var);
return NULL;
}
*/
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);
}
#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;
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);
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':
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;
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);
/* 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);
* 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;
}
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;
}
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;
}
/* 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;
else
Tcl_UnsetVar2(interp, *arrptr, *nameptr, 0);
- pfree((char *) attname);
+ pfree(unconstify(char *, attname));
}
}
for (p = skip_drive(filename); *p; p++)
if (IS_DIR_SEP(*p))
- return (char *) p;
+ return unconstify(char *, p);
return NULL;
}
/* 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;
}
for (p = skip_drive(filename); *p; p++)
if (IS_DIR_SEP(*p))
ret = p;
- return (char *) ret;
+ return unconstify(char *, ret);
}
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;
}