1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-18 13:44:19 +03:00

Use "(void)" to mark pgstat_lock_entry(..., false) calls.

This should silence Coverity's complaints about the result being
sometimes ignored.

I'm inclined to think that these routines are simply misdesigned,
because sometimes it's okay to ignore the result and sometimes it
isn't, and we have no way to enforce the latter.  But for now
I just added a comment.
This commit is contained in:
Tom Lane 2025-04-06 11:37:09 -04:00
parent 5e19154390
commit 2e4ccf1b45
3 changed files with 12 additions and 3 deletions

View File

@ -1019,7 +1019,7 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
stats_data = MemoryContextAlloc(pgStatLocal.snapshot.context,
kind_info->shared_data_len);
pgstat_lock_entry_shared(entry_ref, false);
(void) pgstat_lock_entry_shared(entry_ref, false);
memcpy(stats_data,
pgstat_get_entry_data(kind, entry_ref->shared_stats),
kind_info->shared_data_len);

View File

@ -195,7 +195,7 @@ pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
return;
}
pgstat_lock_entry(entry_ref, false);
(void) pgstat_lock_entry(entry_ref, false);
sharedent = (PgStatShared_Database *) entry_ref->shared_stats;
sharedent->stats.checksum_failures += failurecount;

View File

@ -643,6 +643,13 @@ pgstat_release_entry_ref(PgStat_HashKey key, PgStat_EntryRef *entry_ref,
pfree(entry_ref);
}
/*
* Acquire exclusive lock on the entry.
*
* If nowait is true, it's just a conditional acquire, and the result
* *must* be checked to verify success.
* If nowait is false, waits as necessary, always returning true.
*/
bool
pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)
{
@ -656,8 +663,10 @@ pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)
}
/*
* Acquire shared lock on the entry.
*
* Separate from pgstat_lock_entry() as most callers will need to lock
* exclusively.
* exclusively. The wait semantics are identical.
*/
bool
pgstat_lock_entry_shared(PgStat_EntryRef *entry_ref, bool nowait)