Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix build warnings #652

New issue

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

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

Already on GitHub? Sign in to your account

Open
japinli wants to merge 4 commits into postgrespro:master
base: master
Choose a base branch
Loading
from japinli:fix-warning
Open

Fix build warnings #652

japinli wants to merge 4 commits into postgrespro:master from japinli:fix-warning

Conversation

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.

gz->strm.next_in = gz->buf;
}
rc = fio_read(gz->fd, gz->strm.next_in + gz->strm.avail_in,
rc = fio_read(gz->fd, (void*) (gz->strm.next_in + gz->strm.avail_in),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a good idea to discard const qualifier because external library, probably, can cache some values because expected constant value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
1 more reviewer

@Ogurezzz Ogurezzz Ogurezzz approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /