Fix regression tests against PostgreSQL 19 and also fix build warnings - #59
Merged
Conversation
Owner
|
Thank you @devrimgunduz I'll try to put together a package for v19 🙂 |
Building pgmp against recent PostgreSQL versions produces a number of
warnings enabled by PGXS's default `CFLAGS`
(`-Wmissing-variable-declarations`, and, on `clang`,
`-Wdefault-const-init-var-unsafe`). None of them point to an actual bug,
but they are worth cleaning up so the module builds warning-free again.
* **`-Wmissing-variable-declarations` on `_pgmp_limb_0` / `_pgmp_limb_1`
(src/pgmp.c)**
These two file-scope constants are defined in `pgmp.c` and referenced
from `pmpq.c` and `pmpz.c` via ad-hoc local `extern` declarations, but
there was no declaration visible *before* the point where they are
actually defined in `pgmp.c` itself, which is what the warning flags.
Moved the `extern` declarations into `pgmp-impl.h` (already included by
all three files) and dropped the now-redundant local `extern`s from
`pmpq.c` and `pmpz.c`.
* **`-Wmissing-variable-declarations` on `pgmp_randstate`
(src/pmpz_rand.c)**
`pgmp_randstate` is only ever used inside `pmpz_rand.c`, so instead of
adding a pointless header declaration it is simply declared `static`,
which also documents that it's private module state.
* **`-Wdefault-const-init-var-unsafe` on `const mpz_t` / `const mpq_t`
locals (all `pmp[zq]*.c` files)**
Every wrapper function (and the macros that generate them) declares its
GMP arguments as `const mpz_t`/`const mpq_t` with no initializer; the
struct is instead populated a few lines later by `mpz_from_pmpz()` /
`mpq_from_pmpq()`, which take a `const` pointer but fill it in through a
local non-const alias (see the comment in `pmpz.c`/`pmpq.c`). This is
intentional and safe (the values are never read before being
populated), but newer compilers warn that a `const`-qualified
aggregate with no explicit initializer is left "uninitialized".
Added an explicit `= {0}` zero-initializer to every such declaration.
This is a no-op at runtime (the values are overwritten by
`mpz_from_pmpz()`/`mpq_from_pmpq()` before use in every case) and
silences the warning without changing any behaviour.
No functional/behavioural change is introduced by this patch; it is
warnings-only.
Coded by Claude, tested by me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @dvarrazzo ,
Attached are patches against master that fixes regression tests against PG 19 and also fixes build warnings against all recent PostgreSQL versions.
Cheers, Devrim
Per: pgdg-packaging/pgdg-rpms#213