neondatabase / neon

Neon: Serverless Postgres. We separated storage and compute to offer autoscaling, code-like database branching, and scale to zero.
https://neon.tech
Apache License 2.0
14.48k stars 419 forks source link

Silence compiler warning #8153

Closed hlinnaka closed 3 months ago

hlinnaka commented 3 months ago

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.)

github-actions[bot] commented 3 months ago

2922 tests run: 2805 passed, 0 failed, 117 skipped (full report)


Code coverage* (full report)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
d3dc80ba303d573d9d44a7f3290f1b1b48b7e1a0 at 2024-06-25T11:55:59.759Z :recycle: