| From 5729e06c819184b7ba40869c1ad53e1a463040b2 Mon Sep 17 00:00:00 2001 |
| From: "Liam R. Howlett" <Liam.Howlett@oracle.com> |
| Date: Thu, 18 May 2023 10:55:10 -0400 |
| Subject: maple_tree: fix static analyser cppcheck issue |
| |
| From: Liam R. Howlett <Liam.Howlett@oracle.com> |
| |
| commit 5729e06c819184b7ba40869c1ad53e1a463040b2 upstream. |
| |
| Patch series "Maple tree mas_{next,prev}_range() and cleanup", v4. |
| |
| This patchset contains a number of clean ups to the code to make it more |
| usable (next/prev range), the addition of debug output formatting, the |
| addition of printing the maple state information in the WARN_ON/BUG_ON |
| code. |
| |
| There is also work done here to keep nodes active during iterations to |
| reduce the necessity of re-walking the tree. |
| |
| Finally, there is a new interface added to move to the next or previous |
| range in the tree, even if it is empty. |
| |
| The organisation of the patches is as follows: |
| |
| 0001-0004 - Small clean ups |
| 0005-0018 - Additional debug options and WARN_ON/BUG_ON changes |
| 0019 - Test module __init and __exit addition |
| 0020-0021 - More functional clean ups |
| 0022-0026 - Changes to keep nodes active |
| 0027-0034 - Add new mas_{prev,next}_range() |
| 0035 - Use new mas_{prev,next}_range() in mmap_region() |
| |
| |
| This patch (of 35): |
| |
| 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. |
| |
| Link: https://lkml.kernel.org/r/20230518145544.1722059-1-Liam.Howlett@oracle.com |
| Link: https://lkml.kernel.org/r/20230518145544.1722059-2-Liam.Howlett@oracle.com |
| Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> |
| Reported-by: David Binderman <dcb314@hotmail.com> |
| Reviewed-by: Peng Zhang<zhangpeng.00@bytedance.com> |
| Cc: Sergey Senozhatsky <senozhatsky@chromium.org> |
| Cc: Vernon Yang <vernon2gm@gmail.com> |
| Cc: Wei Yang <richard.weiyang@gmail.com> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| lib/maple_tree.c | 5 +++-- |
| 1 file changed, 3 insertions(+), 2 deletions(-) |
| |
| --- a/lib/maple_tree.c |
| +++ b/lib/maple_tree.c |
| @@ -1935,8 +1935,9 @@ static inline int mab_calc_split(struct |
| * 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++; |
| } |
| |