]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fdtgrep: Simplify code to inverting the match
authorSimon Glass <sjg@chromium.org>
Sun, 17 Dec 2023 16:36:19 +0000 (09:36 -0700)
committerSimon Glass <sjg@chromium.org>
Sun, 31 Dec 2023 14:21:02 +0000 (07:21 -0700)
The code to invert the match in h_include() is a bit convoluted.
Simplify it by using disp->invert only once.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/fdtgrep.c

index a6cdc326709d0fa74ae9e9969d56548352513eff..b06a1a7a838439255af9486500e48417c4cf9b91 100644 (file)
@@ -634,14 +634,8 @@ static int h_include(void *priv, const void *fdt, int offset, int type,
                        inc = 0;
        }
 
-       switch (inc) {
-       case 1:
-               inc = !disp->invert;
-               break;
-       case 0:
-               inc = disp->invert;
-               break;
-       }
+       if (inc != -1 && disp->invert)
+               inc = !inc;
        debug("   - returning %d\n", inc);
 
        return inc;