Skip site navigation (1) Skip section navigation (2)

incompatible pointer types with newer zlib

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: incompatible pointer types with newer zlib
Date: 2012-02-23 09:16:11
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
According to me update logs, somewhere between zlib versions and
1.2.6, the definition of the gzFile type was changed from void * to
struct gzFile_s *, an opaque struct.  Note that gzFile is already the
pointer in either case.  Our code has assumed, however, that you use
gzFile like FILE, namely that the APIs take a pointer to the type, but
that is not the case.  So code like

gzFile *handle = gzopen(...)

is wrong.

This used to pass silently because you can assign a void* to a void**,
but with the newer definition you get a bunch of warnings like

pg_backup_files.c: In function ‘_StartData’:
pg_backup_files.c:256:11: warning: assignment from incompatible pointer type [enabled by default]
pg_backup_files.c: In function ‘_WriteData’:
pg_backup_files.c:271:2: warning: passing argument 1 of ‘gzwrite’ from incompatible pointer type [enabled by default]
/usr/include/zlib.h:1318:12: note: expected ‘gzFile’ but argument is of type ‘struct gzFile_s **’

Affected are pg_dump and pg_basebackup.

Fixing most of this is not difficult, see attached patch.  The only
ugliness is in pg_backup_archiver.h

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

which is used throughout pg_dump as sometimes a real FILE* and sometimes
a gzFile handle.  There are also some fileno() calls on this, so just
replacing this with an #ifdef isn't going to work.  This might need some
more restructuring to make the code truly type-safe.  My quick patch
replaces the type with void*, thus sort of restoring the original
situation that allowed this to work.

Note that these are only warnings, so we probably don't need to worry
about backpatching this in a hurry.

Attachment: gzfile.patch
Description: text/x-patch (2.3 KB)


pgsql-hackers by date

Next:From: Simon RiggsDate: 2012-02-23 09:18:57
Subject: Re: foreign key locks, 2nd attempt
Previous:From: Gianni CiolliDate: 2012-02-23 08:50:21
Subject: Re: Triggers with DO functionality

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group