]> granicus.if.org Git - postgresql/commitdiff
Silence compiler warnings
authorJoe Conway <mail@joeconway.com>
Mon, 2 Jan 2017 22:42:28 +0000 (14:42 -0800)
committerJoe Conway <mail@joeconway.com>
Mon, 2 Jan 2017 22:42:28 +0000 (14:42 -0800)
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

src/backend/storage/lmgr/lwlock.c

index a814809e57099f73d0e29a79884f73a47322edfd..4dc050d05aeaea6864fe5c080c50b6475c34dd1f 100644 (file)
@@ -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];