maple tree: Use goto label to simplify code
Subsystems (3)
PATCH 1/1 maple tree: Use goto label to simplify code
Use the underflow goto label to set the status to ma_underflow and return NULL, as is being done elsewhere.
Signed-off-by Dev Jain <[email protected]>
--- lib/maple_tree.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
lib/maple_tree.c +2 -5
@@ -4565,11 +4565,8 @@ static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty)return entry;if (!empty) { -if (mas->index <= min) { - mas->status = ma_underflow; -return NULL ; - } - +if (mas->index <= min) + goto underflow; goto again; }
Signature · 1 line
2.30.2
Quoted 2 lines · Dev Jain
Use the underflow goto label to set the status to
ma_underflowand return NULL, as is being done elsewhere.
Thanks for this, but the stacking of labels is unpleasant to read.
A new line like I've added makes it a bit better. It's more my fault having the existing code as it is.
Quoted 14 lines
Signed-off-by Dev Jain <[email protected]>--- lib/maple_tree.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)lib/maple_tree.c +0
-0@@ -4565,11 +4565,8 @@ static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty)return entry;if (!empty) {
lib/maple_tree.c static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty) · line 4572
Quoted 10 lines
lib/maple_tree.c +2
-5-if (mas->index <= min) { - mas->status = ma_underflow; -return NULL ; - } - +if (mas->index <= min) + goto underflow; goto again; }
Andrew, can you just add a new line like I have above?
Reviewed-by Liam R. Howlett <[email protected]>
Thanks,
Liam
Quoted 4 lines · Dev Jain
Use the underflow goto label to set the status to
ma_underflowand return NULL, as is being done elsewhere.Signed-off-by Dev Jain <[email protected]>
LGTM, thanks :-)
Reviewed-by Wei Yang <[email protected]>
Signature · 2 lines
Wei Yang Help you, Help me