mirror of https://github.com/postgres/postgres
Improve const use in zlib-using code
If we define ZLIB_CONST before including zlib.h, zlib augments some
interfaces with const decorations. By doing that we can keep our own
interfaces cleaner and can remove some unconstify calls.
ZLIB_CONST was introduced in zlib 1.2.5.2 (17 Dec 2011). When
compiling with older zlib releases, you might now get compiler
warnings about discarding qualifiers.
CentOS 6 has zlib 1.2.3, but in 8e278b6576
, we removed support for the
OpenSSL release in CentOS 6, so it seems ok to de-support the zlib
release in CentOS 6 as well.
Reviewed-by: Tristan Partin <tristan@neon.tech>
Discussion: https://www.postgresql.org/message-id/flat/33462926-bb1e-7cc9-8d92-d86318e8ed1d%40eisentraut.org
This commit is contained in:
parent
fdd79d8992
commit
67c0ef9752
|
@ -113,7 +113,7 @@ compress_process(PushFilter *next, void *priv, const uint8 *data, int len)
|
||||||
/*
|
/*
|
||||||
* process data
|
* process data
|
||||||
*/
|
*/
|
||||||
st->stream.next_in = unconstify(uint8 *, data);
|
st->stream.next_in = data;
|
||||||
st->stream.avail_in = len;
|
st->stream.avail_in = len;
|
||||||
while (st->stream.avail_in > 0)
|
while (st->stream.avail_in > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -269,7 +269,7 @@ bbstreamer_gzip_decompressor_content(bbstreamer *streamer,
|
||||||
mystreamer = (bbstreamer_gzip_decompressor *) streamer;
|
mystreamer = (bbstreamer_gzip_decompressor *) streamer;
|
||||||
|
|
||||||
zs = &mystreamer->zstream;
|
zs = &mystreamer->zstream;
|
||||||
zs->next_in = (uint8 *) data;
|
zs->next_in = (const uint8 *) data;
|
||||||
zs->avail_in = len;
|
zs->avail_in = len;
|
||||||
|
|
||||||
/* Process the current chunk */
|
/* Process the current chunk */
|
||||||
|
|
|
@ -705,7 +705,7 @@ typedef struct TarMethodData
|
||||||
|
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
static bool
|
static bool
|
||||||
tar_write_compressed_data(TarMethodData *tar_data, void *buf, size_t count,
|
tar_write_compressed_data(TarMethodData *tar_data, const void *buf, size_t count,
|
||||||
bool flush)
|
bool flush)
|
||||||
{
|
{
|
||||||
tar_data->zp->next_in = buf;
|
tar_data->zp->next_in = buf;
|
||||||
|
@ -782,8 +782,7 @@ tar_write(Walfile *f, const void *buf, size_t count)
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
else if (f->wwmethod->compression_algorithm == PG_COMPRESSION_GZIP)
|
else if (f->wwmethod->compression_algorithm == PG_COMPRESSION_GZIP)
|
||||||
{
|
{
|
||||||
if (!tar_write_compressed_data(tar_data, unconstify(void *, buf),
|
if (!tar_write_compressed_data(tar_data, buf, count, false))
|
||||||
count, false))
|
|
||||||
return -1;
|
return -1;
|
||||||
f->currpos += count;
|
f->currpos += count;
|
||||||
return count;
|
return count;
|
||||||
|
|
|
@ -75,6 +75,11 @@
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Define before including zlib.h to add const decorations to zlib API. */
|
||||||
|
#ifdef HAVE_LIBZ
|
||||||
|
#define ZLIB_CONST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------
|
/* ----------------------------------------------------------------
|
||||||
* Section 1: compiler characteristics
|
* Section 1: compiler characteristics
|
||||||
|
|
Loading…
Reference in New Issue