[PATCH v2 2/2] discover/grub2: Add the '-e' test support

Jeremy Kerr jk at ozlabs.org
Wed Jan 20 16:08:32 AEDT 2021


Hi Klaus,

diff --git a/discover/grub2/builtins.c b/discover/grub2/builtins.c
index 31cbe0e..291bb03 100644
--- a/discover/grub2/builtins.c
+++ b/discover/grub2/builtins.c
@@ -245,6 +245,11 @@ static bool builtin_test_op_file(struct
grub2_script *script, char op,
                return false;
 
        switch (op) {
+       case 'e':
+               /* -e: for grub, a special case is testing for the
device
+                * presence itself (e.g. allows null file). */
+               result = true;
+               break;

I would suggest moving this earlier, so we avoid the stat (which we
don't care about for '-e'). Then you can handle the path = NULL case in
one conditional, rather than in each 'op' branch.


diff --git a/test/parser/test-grub2-ubuntu-13_04-x86.c
b/test/parser/test-grub2-ubuntu-13_04-x86.c
index 2f9aefd..785781a 100644
--- a/test/parser/test-grub2-ubuntu-13_04-x86.c
+++ b/test/parser/test-grub2-ubuntu-13_04-x86.c

This looks unrelated too :)

Cheers,


Jeremy




More information about the Petitboot mailing list