]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix double assignment.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 14 Dec 2025 17:09:56 +0000 (12:09 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 14 Dec 2025 17:09:56 +0000 (12:09 -0500)
Coverity complained about this, not without reason:

OldMultiXactReader *state = state = pg_malloc(sizeof(*state));

(I'm surprised this is even legal C ... why is "state" in-scope
in its initialization expression?)

While at it, convert to use our newly-preferred "pg_malloc_object"
macro instead of an explicit sizeof().

src/bin/pg_upgrade/multixact_read_v18.c

index e7496a73e0e8990f629aa768d64ef1e51fa9557d..f74011c4786bd7c1f2693009f5b4ec6b53653209 100644 (file)
@@ -119,7 +119,7 @@ OldMultiXactReader *
 AllocOldMultiXactRead(char *pgdata, MultiXactId nextMulti,
                                          MultiXactOffset32 nextOffset)
 {
-       OldMultiXactReader *state = state = pg_malloc(sizeof(*state));
+       OldMultiXactReader *state = pg_malloc_object(OldMultiXactReader);
        char            dir[MAXPGPATH] = {0};
 
        state->nextMXact = nextMulti;