]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix type of iterator variable in SH_START_ITERATE
authorAndres Freund <andres@anarazel.de>
Thu, 6 Jul 2023 15:34:17 +0000 (08:34 -0700)
committerAndres Freund <andres@anarazel.de>
Thu, 6 Jul 2023 16:57:33 +0000 (09:57 -0700)
Also add comment to make the reasoning behind the Assert() more explicit (per
Tom).

Reported-by: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAocXNJ6s1VLz+hMamLAQAiewRoW17OJ6-+9GACKfj6iPQ@mail.gmail.com
Backpatch: 11-

src/include/lib/simplehash.h

index 664febe54ccc39d282cff22a3d5b0639509c7bf2..145d9db50ec099c956e58d018505829eeea43354 100644 (file)
@@ -772,7 +772,6 @@ SH_DELETE(SH_TYPE * tb, SH_KEY_TYPE key)
 SH_SCOPE void
 SH_START_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
 {
-       int                     i;
        uint64          startelem = PG_UINT64_MAX;
 
        /*
@@ -780,7 +779,7 @@ SH_START_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
         * supported, we want to start/end at an element that cannot be affected
         * by elements being shifted.
         */
-       for (i = 0; i < tb->size; i++)
+       for (uint32 i = 0; i < tb->size; i++)
        {
                SH_ELEMENT_TYPE *entry = &tb->data[i];
 
@@ -791,6 +790,7 @@ SH_START_ITERATE(SH_TYPE * tb, SH_ITERATOR * iter)
                }
        }
 
+       /* we should have found an empty element */
        Assert(startelem < SH_MAX_SIZE);
 
        /*