diff options
author | Joe Conway <mail@joeconway.com> | 2017-01-02 14:42:28 -0800 |
---|---|---|
committer | Joe Conway <mail@joeconway.com> | 2017-01-02 14:42:28 -0800 |
commit | 5099e8ee23641abc8437d98555b63158e75a8a55 (patch) | |
tree | 0b3b7acd7f566ce4ba17e8e53cded21a5f721de1 /src | |
parent | 7911e78f6cc5a51f4d41589542140eee00b3f10d (diff) | |
download | postgresql-5099e8ee23641abc8437d98555b63158e75a8a55.tar.gz postgresql-5099e8ee23641abc8437d98555b63158e75a8a55.zip |
Silence compiler warnings
Rearrange a bit of code to ensure that 'mode' in LWLockRelease is
obviously always set, which seems a bit cleaner and avoids a compiler
warning (thanks to Robert for the suggestion!).
Back-patch back to 9.5 where the warning is first seen.
Author: Stephen Frost
Discussion: https://postgr.es/m/20161129152102.GR13284%40tamriel.snowman.net
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/storage/lmgr/lwlock.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index a814809e570..4dc050d05ae 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -1781,15 +1781,14 @@ LWLockRelease(LWLock *lock) * be the latest-acquired lock; so search array backwards. */ for (i = num_held_lwlocks; --i >= 0;) - { if (lock == held_lwlocks[i].lock) - { - mode = held_lwlocks[i].mode; break; - } - } + if (i < 0) elog(ERROR, "lock %s %d is not held", T_NAME(lock), T_ID(lock)); + + mode = held_lwlocks[i].mode; + num_held_lwlocks--; for (; i < num_held_lwlocks; i++) held_lwlocks[i] = held_lwlocks[i + 1]; |