incompatible pointer types with newer zlib

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема incompatible pointer types with newer zlib
Дата
Msg-id 1329988571.6474.9.camel@vanquo.pezone.net
обсуждение исходный текст
Ответы Re: incompatible pointer types with newer zlib  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
According to me update logs, somewhere between zlib versions 1.2.3.4 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.


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Gianni Ciolli
Дата:
Сообщение: Re: Triggers with DO functionality
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: foreign key locks, 2nd attempt