]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix static analyser cppcheck issue
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 17 Apr 2023 15:15:33 +0000 (11:15 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 24 Apr 2023 15:40:43 +0000 (11:40 -0400)
Static analyser of the maple tree code noticed that the split variable
is being used to dereference into an array prior to checking the
variable itself.  Fix this issue by changing the order of the statement
to check the variable first.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 110a36479dced7f5e061d0562eb9e40bf89cdf15..9cf4fca42310c6ff74f8688ed16cdb690e22234d 100644 (file)
@@ -1943,8 +1943,9 @@ static inline int mab_calc_split(struct ma_state *mas,
                 * causes one node to be deficient.
                 * NOTE: mt_min_slots is 1 based, b_end and split are zero.
                 */
-               while (((bn->pivot[split] - min) < slot_count - 1) &&
-                      (split < slot_count - 1) && (b_end - split > slot_min))
+               while ((split < slot_count - 1) &&
+                      ((bn->pivot[split] - min) < slot_count - 1) &&
+                      (b_end - split > slot_min))
                        split++;
        }