diff mbox

[v3,25/52] xen/common/efi/boot.c: let custom parameter parsing routines return errno

Message ID 20170816125219.5255-26-jgross@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Juergen Gross Aug. 16, 2017, 12:51 p.m. UTC
Modify the custom parameter parsing routines in:

xen/common/efi/boot.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- dont return out of loops (Jan Beulich)
- dont modify option value in parsing function
---
 xen/common/efi/boot.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Comments

Jan Beulich Aug. 22, 2017, 9:56 a.m. UTC | #1
>>> On 16.08.17 at 14:51, <jgross@suse.com> wrote:
> Modify the custom parameter parsing routines in:
> 
> xen/common/efi/boot.c
> 
> to indicate whether the parameter value was parsed successfully.
> 
> Cc: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
diff mbox

Patch

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 11bdc7a2a4..01d33004e0 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1306,9 +1306,10 @@  efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 
 static bool __initdata efi_map_uc;
 
-static void __init parse_efi_param(char *s)
+static int __init parse_efi_param(const char *s)
 {
-    char *ss;
+    const char *ss;
+    int rc = 0;
 
     do {
         bool val = strncmp(s, "no-", 3);
@@ -1317,21 +1318,25 @@  static void __init parse_efi_param(char *s)
             s += 3;
 
         ss = strchr(s, ',');
-        if ( ss )
-            *ss = '\0';
+        if ( !ss )
+            ss = strchr(s, '\0');
 
-        if ( !strcmp(s, "rs") )
+        if ( !strncmp(s, "rs", ss - s) )
         {
             if ( val )
                 __set_bit(EFI_RS, &efi_flags);
             else
                 __clear_bit(EFI_RS, &efi_flags);
         }
-        else if ( !strcmp(s, "attr=uc") )
+        else if ( !strncmp(s, "attr=uc", ss - s) )
             efi_map_uc = val;
+        else
+            rc = -EINVAL;
 
         s = ss + 1;
-    } while ( ss );
+    } while ( *ss );
+
+    return rc;
 }
 custom_param("efi", parse_efi_param);