]> granicus.if.org Git - postgresql/commitdiff
Fix incorrect uses of gzFile
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 2 Mar 2012 20:30:01 +0000 (22:30 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 2 Mar 2012 20:30:01 +0000 (22:30 +0200)
gzFile is already a pointer, so code like

gzFile *handle = gzopen(...)

is wrong.

This used to pass silently because gzFile used to be defined as void*,
and you can assign a void* to a void**.  But somewhere between zlib
versions 1.2.3.4 and 1.2.6, the definition of gzFile was changed to
struct gzFile_s *, and with that new definition this usage causes
compiler warnings.

So remove all those extra pointer decorations.

There is a related issue in pg_backup_archiver.h, where

FILE       *FH;             /* General purpose file handle */

is used throughout pg_dump as sometimes a real FILE* and sometimes a
gzFile handle, which also causes warnings now.  This is not yet fixed
here, because it might need more code restructuring.

src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_dump/pg_backup_files.c
src/bin/pg_dump/pg_backup_tar.c

index b39d2e7bf38071a1503e899ebde15c08fc4015de..bf88726f326a0a6d83fb533df9105fffb6c56305 100644 (file)
@@ -82,7 +82,7 @@ static bool segment_callback(XLogRecPtr segendpos, uint32 timeline);
 
 #ifdef HAVE_LIBZ
 static const char *
-get_gz_error(gzFile *gzf)
+get_gz_error(gzFile gzf)
 {
        int                     errnum;
        const char *errmsg;
@@ -450,7 +450,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
        FILE       *tarfile = NULL;
 
 #ifdef HAVE_LIBZ
-       gzFile     *ztarfile = NULL;
+       gzFile          ztarfile = NULL;
 #endif
 
        if (PQgetisnull(res, rownum, 0))
index 71bace0eab71f568cc961e0f3526f3c1a4992c5c..a7fd91d1c53a7a96e6cee8238964a8e49863d248 100644 (file)
@@ -60,7 +60,7 @@ typedef struct
 typedef struct
 {
 #ifdef HAVE_LIBZ
-       gzFile     *FH;
+       gzFile          FH;
 #else
        FILE       *FH;
 #endif
index 4952f5a15d3356b67facdd119061d8be9a16c545..4823edec7fea0a924e42c0b7f82d6efdbba152b6 100644 (file)
@@ -58,16 +58,13 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
 #define K_STD_BUF_SIZE 1024
 
 
+typedef struct
+{
 #ifdef HAVE_LIBZ
- /* typedef gzFile      ThingFile; */
-typedef FILE ThingFile;
+       gzFile          zFH;
 #else
-typedef FILE ThingFile;
+       FILE       *zFH;
 #endif
-
-typedef struct
-{
-       ThingFile  *zFH;
        FILE       *nFH;
        FILE       *tarFH;
        FILE       *tmpFH;