Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7e5237

Browse files
committed
Fix asserts in fast-path locking code
Commitc4d5cb7 introduced a couple asserts in the fast-path lockingcode, upsetting Coverity.The assert in InitProcGlobal() is clearly wrong, as it assigns insteadof checking the value. This is harmless, but doesn't check anything.The asserts in FAST_PATH_ macros are written as if for signed values,but the macros are only called for unsigned ones. That makes the checkfor (val >= 0) useless. Checks written as ((uint32) x < max) work forboth signed and unsigned values. Negative values should wrap to valuesgreater than INT32_MAX.Per Coverity, report by Tom Lane.Reported-by: Tom LaneDiscussion:https://postgr.es/m/2891628.1727019959@sss.pgh.pa.us
1 parent40708ac commita7e5237

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

‎src/backend/storage/lmgr/lock.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,19 @@ intFastPathLockGroupsPerBackend = 0;
218218
* of fast-path lock slots.
219219
*/
220220
#defineFAST_PATH_SLOT(group,index) \
221-
(AssertMacro(((group) >= 0) && ((group) < FastPathLockGroupsPerBackend)), \
222-
AssertMacro(((index) >= 0) && ((index) < FP_LOCK_SLOTS_PER_GROUP)), \
221+
(AssertMacro((uint32) (group) < FastPathLockGroupsPerBackend), \
222+
AssertMacro((uint32) (index) < FP_LOCK_SLOTS_PER_GROUP), \
223223
((group) * FP_LOCK_SLOTS_PER_GROUP + (index)))
224224

225225
/*
226226
* Given a slot index (into the whole per-backend array), calculated using
227227
* the FAST_PATH_SLOT macro, split it into group and index (in the group).
228228
*/
229229
#defineFAST_PATH_GROUP(index)\
230-
(AssertMacro(((index) >= 0) && ((index) < FP_LOCK_SLOTS_PER_BACKEND)), \
230+
(AssertMacro((uint32) (index) < FP_LOCK_SLOTS_PER_BACKEND), \
231231
((index) / FP_LOCK_SLOTS_PER_GROUP))
232232
#defineFAST_PATH_INDEX(index)\
233-
(AssertMacro(((index) >= 0) && ((index) < FP_LOCK_SLOTS_PER_BACKEND)), \
233+
(AssertMacro((uint32) (index) < FP_LOCK_SLOTS_PER_BACKEND), \
234234
((index) % FP_LOCK_SLOTS_PER_GROUP))
235235

236236
/* Macros for manipulating proc->fpLockBits */

‎src/backend/storage/lmgr/proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ InitProcGlobal(void)
322322
}
323323

324324
/* Should have consumed exactly the expected amount of fast-path memory. */
325-
Assert(fpPtr=fpEndPtr);
325+
Assert(fpPtr==fpEndPtr);
326326

327327
/*
328328
* Save pointers to the blocks of PGPROC structures reserved for auxiliary

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp