aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Conway <mail@joeconway.com>2017-01-02 14:42:44 -0800
committerJoe Conway <mail@joeconway.com>2017-01-02 14:42:44 -0800
commitcbc62b22952006324199979396d229ce82f6a0d7 (patch)
tree088beaa36e97ee9c2f2630208ef362abea1aaf9f
parent35d4dd82c2e82d2bc0e51174b5cfb5ac30061a81 (diff)
downloadpostgresql-cbc62b22952006324199979396d229ce82f6a0d7.tar.gz
postgresql-cbc62b22952006324199979396d229ce82f6a0d7.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
-rw-r--r--src/backend/storage/lmgr/lwlock.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 2671aef22bf..32fdc088cff 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -1533,15 +1533,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];