Skip to content

Commit

Permalink
Silence compiler warning (#8153)
Browse files Browse the repository at this point in the history
I saw this compiler warning on my laptop:

pgxn/neon_walredo/walredoproc.c:178:10: warning: using the result of an
assignment as a condition without parentheses [-Wparentheses]
            if (err = close_range_syscall(3, ~0U, 0)) {
                ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pgxn/neon_walredo/walredoproc.c:178:10: note: place parentheses around
the assignment to silence this warning
            if (err = close_range_syscall(3, ~0U, 0)) {
                    ^
                (                                   )
pgxn/neon_walredo/walredoproc.c:178:10: note: use '==' to turn this
assignment into an equality comparison
            if (err = close_range_syscall(3, ~0U, 0)) {
                    ^
                    ==
    1 warning generated.

I'm not sure what compiler version or options cause that, but it's a
good warning. Write the call a little differently, to avoid the warning
and to make it a little more clear anyway. (The 'err' variable wasn't
used for anything, so I'm surprised we were not seeing a compiler
warning on the unused value, too.)
  • Loading branch information
hlinnaka committed Jun 26, 2024
1 parent 3118c24 commit 24ce73f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pgxn/neon_walredo/walredoproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,15 @@ close_range_syscall(unsigned int start_fd, unsigned int count, unsigned int flag
static void
enter_seccomp_mode(void)
{

/*
* The pageserver process relies on us to close all the file descriptors
* it potentially leaked to us, _before_ we start processing potentially dangerous
* wal records. See the comment in the Rust code that launches this process.
*/
int err;
if (err = close_range_syscall(3, ~0U, 0)) {
ereport(FATAL, (errcode(ERRCODE_SYSTEM_ERROR), errmsg("seccomp: could not close files >= fd 3")));
}
if (close_range_syscall(3, ~0U, 0) != 0)
ereport(FATAL,
(errcode(ERRCODE_SYSTEM_ERROR),
errmsg("seccomp: could not close files >= fd 3")));

PgSeccompRule syscalls[] =
{
Expand Down

1 comment on commit 24ce73f

@github-actions
Copy link

Choose a reason for hiding this comment

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

2998 tests run: 2872 passed, 0 failed, 126 skipped (full report)


Code coverage* (full report)

  • functions: 32.8% (6892 of 21018 functions)
  • lines: 50.3% (53909 of 107207 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
24ce73f at 2024-06-26T17:56:29.031Z :recycle:

Please sign in to comment.