Skip to content

Fix build warnings #652

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Fix build warnings #652

wants to merge 4 commits into from

Conversation

japinli
Copy link
Contributor

@japinli japinli commented Jun 4, 2025

When I build pg_probackup with PostgreSQL REL_17_STABLE, I encountered the following warning:

$ make USE_PGXS=1 top_srcdir=/home/japin/Codes/pg/REL_17_STABLE -s
src/utils/file.c: In function ‘fio_gzread’:
src/utils/file.c:1687:64: warning: passing argument 2 of ‘fio_read’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 1687 |                         rc = fio_read(gz->fd, gz->strm.next_in + gz->strm.avail_in,
      |                                               ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
src/utils/file.c:1096:24: note: expected ‘void *’ but argument is of type ‘const Bytef *’ {aka ‘const unsigned char *’}
 1096 | fio_read(int fd, void* buf, size_t size)
      |                  ~~~~~~^~~
src/utils/file.c: In function ‘fio_send_file_gz’:
src/utils/file.c:2521:28: warning: declaration of ‘hdr’ shadows a previous local [-Wshadow=compatible-local]
 2521 |                 fio_header hdr;
      |                            ^~~
src/utils/file.c:2502:20: note: shadowed declaration is here
 2502 |         fio_header hdr;
      |                    ^~~
src/backup.c: In function ‘do_backup_pg’:
src/backup.c:513:17: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  513 |                 char    from_fullpath[MAXPGPATH];
      |                 ^~~~
src/catalog.c: In function ‘catalog_get_timelines’:
src/catalog.c:1758:31: warning: declaration of ‘tlinfo’ shadows a previous local [-Wshadow=compatible-local]
 1758 |                 timelineInfo *tlinfo = parray_get(timelineinfos, i);
      |                               ^~~~~~
src/catalog.c:1537:23: note: shadowed declaration is here
 1537 |         timelineInfo *tlinfo;
      |                       ^~~~~~
src/catalog.c:1775:31: warning: declaration of ‘tlinfo’ shadows a previous local [-Wshadow=compatible-local]
 1775 |                 timelineInfo *tlinfo = parray_get(timelineinfos, i);
      |                               ^~~~~~
src/catalog.c:1537:23: note: shadowed declaration is here
 1537 |         timelineInfo *tlinfo;
      |                       ^~~~~~
src/catalog.c:1848:31: warning: declaration of ‘tlinfo’ shadows a previous local [-Wshadow=compatible-local]
 1848 |                 timelineInfo *tlinfo = parray_get(timelineinfos, i);
      |                               ^~~~~~
src/catalog.c:1537:23: note: shadowed declaration is here
 1537 |         timelineInfo *tlinfo;
      |                       ^~~~~~
src/catalog.c:2084:31: warning: declaration of ‘tlinfo’ shadows a previous local [-Wshadow=compatible-local]
 2084 |                 timelineInfo *tlinfo = parray_get(timelineinfos, i);
      |                               ^~~~~~
src/catalog.c:1537:23: note: shadowed declaration is here
 1537 |         timelineInfo *tlinfo;
      |                       ^~~~~~
src/stream.c: In function ‘parse_tli_history_buffer’:
src/stream.c:595:41: warning: declaration of ‘tli’ shadows a parameter [-Wshadow=compatible-local]
  595 |                         TimeLineID      tli;
      |                                         ^~~
src/stream.c:574:52: note: shadowed declaration is here
  574 | parse_tli_history_buffer(char *history, TimeLineID tli)
      |                                         ~~~~~~~~~~~^~~
src/utils/file.c:1687:26: warning: passing 'const Bytef *' (aka 'const unsigned char *') to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
 1687 |                         rc = fio_read(gz->fd, gz->strm.next_in + gz->strm.avail_in,
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/utils/file.c:1096:24: note: passing argument to parameter 'buf' here
 1096 | fio_read(int fd, void* buf, size_t size)
      |                        ^
1 warning generated.

This PR tries to fix them.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant