| From: | Jan Nidzwetzki <jan(at)planetscale(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Add pg_nodiscard decorations to Bitmapset functions |
| Date: | 2026-09-08 15:13:08 |
| Message-ID: | 2020a70e-76f3-4661-afa6-82c2639251c2@planetscale.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Hackers,
The functions in bitmapset.h that return a Bitmapset * either build a
new set or recycle their input, so ignoring the return value is always a
bug.
Commit c617aea6acd introduced the macro pg_nodiscard, which generates a
compiler warning when the result of a function call is ignored. The List
functions in pg_list.h have the same requirement, and commit a378ba49a5c
added pg_nodiscard to most of them.
However, bitmapset.h was never adjusted. The attached patch adds
pg_nodiscard to all functions there that return a Bitmapset *.
This patch does not make REALLOCATE_BITMAPSETS redundant.
REALLOCATE_BITMAPSETS reallocates the set on every modification, so a
stale pointer to the old set is likely to be noticed. However, only at
runtime and only in builds that enable it. pg_nodiscard catches the
simpler case of dropping the return value entirely at compile time.
Best regards
Jan
--
Jan Nidzwetzki
PlanetScale Postgres Core Team
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Add-pg_nodiscard-decorations-to-Bitmapset-functions.patch | text/plain | 3.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dmitry Dolgov | 2026-09-08 15:15:12 | Re: Add ssl_(supported|shared)_groups to sslinfo |
| Previous Message | Dmitry Dolgov | 2026-09-08 15:12:49 | Re: Add ssl_(supported|shared)_groups to sslinfo |