-
Notifications
You must be signed in to change notification settings - Fork 848
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
Warn if result of ts_set_flags_32 is not used #5856
Conversation
The ts_set_flags_32 function takes a bitmap and flags and returns an updated bitmap. However, if the returned value is not used, the function call has no effect. An unused result may indicate the improper use of this function. This patch adds the qualifier pg_nodiscard to the function which triggers a warning if the returned value is not used.
@konskov, @pmwkaa: please review this pull request.
|
Codecov Report
@@ Coverage Diff @@
## main #5856 +/- ##
==========================================
- Coverage 87.87% 80.37% -7.51%
==========================================
Files 239 239
Lines 55742 49014 -6728
Branches 12350 12289 -61
==========================================
- Hits 48985 39396 -9589
+ Misses 4864 4217 -647
- Partials 1893 5401 +3508
... and 222 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
static inline pg_nodiscard uint32 | ||
ts_set_flags_32(uint32 bitmap, uint32 flags) | ||
{ | ||
return bitmap | flags; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just replace it with |=
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought about modifying the value directly. But then decided against it to have a function signature that is similar to other PostgreSQL functions like lappend()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean, remove the function altogether. Anyway, with your change it's better.
The
ts_set_flags_32
function takes a bitmap and flags and returns an updated bitmap. However, if the returned value is not used, the function call has no effect. An unused result may indicate the improper use of this function.This patch adds the qualifier
pg_nodiscard
to the function which triggers a warning if the returned value is not used.Disable-check: force-changelog-file