[PATCH 8/9] XArray: take xas_error() handling for clearer logic

From: Wei Yang
Date: Mon Mar 30 2020 - 08:37:29 EST


If xas is already in error state, return NULL directly.

Take this logic out instead of burying in the middle to make the logic
more straight forward.

Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx>
---
lib/xarray.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/xarray.c b/lib/xarray.c
index 82570bbbf2a5..01f64a000e14 100644
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -636,6 +636,9 @@ static void *xas_create(struct xa_state *xas, bool allow_root)
int shift;
unsigned int order = xas->xa_shift;

+ if (xas_error(xas))
+ return NULL;
+
if (xas_top(node)) {
entry = xa_head_locked(xa);
xas->xa_node = NULL;
@@ -648,8 +651,6 @@ static void *xas_create(struct xa_state *xas, bool allow_root)
shift = XA_CHUNK_SHIFT;
entry = xa_head_locked(xa);
slot = &xa->xa_head;
- } else if (xas_error(xas)) {
- return NULL;
} else {
unsigned int offset = xas->xa_offset;

--
2.23.0