diff mbox

[v2,20/52] xen/arch/x86/shutdown.c: let custom parameter parsing routines return errno

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

Commit Message

Jürgen Groß Aug. 14, 2017, 7:08 a.m. UTC
Modify the custom parameter parsing routines in:

xen/arch/x86/shutdown.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/shutdown.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Jan Beulich Aug. 14, 2017, 1:39 p.m. UTC | #1
>>> On 14.08.17 at 09:08, <jgross@suse.com> wrote:
> --- a/xen/arch/x86/shutdown.c
> +++ b/xen/arch/x86/shutdown.c
> @@ -51,7 +51,7 @@ static int reboot_mode;
>   * efi    Use the EFI reboot (if running under EFI)
>   */
>  static enum reboot_type reboot_type = BOOT_INVALID;
> -static void __init set_reboot_type(char *str)
> +static int __init set_reboot_type(char *str)
>  {
>      for ( ; ; )
>      {
> @@ -74,6 +74,8 @@ static void __init set_reboot_type(char *str)
>          case 't':
>              reboot_type = *str;
>              break;
> +        default:
> +            return -EINVAL;

This alters behavior - you want to store -EINVAL in a local variable,
but continue the loop.

Jan
Jürgen Groß Aug. 14, 2017, 2:29 p.m. UTC | #2
On 14/08/17 15:39, Jan Beulich wrote:
>>>> On 14.08.17 at 09:08, <jgross@suse.com> wrote:
>> --- a/xen/arch/x86/shutdown.c
>> +++ b/xen/arch/x86/shutdown.c
>> @@ -51,7 +51,7 @@ static int reboot_mode;
>>   * efi    Use the EFI reboot (if running under EFI)
>>   */
>>  static enum reboot_type reboot_type = BOOT_INVALID;
>> -static void __init set_reboot_type(char *str)
>> +static int __init set_reboot_type(char *str)
>>  {
>>      for ( ; ; )
>>      {
>> @@ -74,6 +74,8 @@ static void __init set_reboot_type(char *str)
>>          case 't':
>>              reboot_type = *str;
>>              break;
>> +        default:
>> +            return -EINVAL;
> 
> This alters behavior - you want to store -EINVAL in a local variable,
> but continue the loop.

Aah, yes. Okay.


Juergen
diff mbox

Patch

diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c
index f63b8a668f..db9060e5e2 100644
--- a/xen/arch/x86/shutdown.c
+++ b/xen/arch/x86/shutdown.c
@@ -51,7 +51,7 @@  static int reboot_mode;
  * efi    Use the EFI reboot (if running under EFI)
  */
 static enum reboot_type reboot_type = BOOT_INVALID;
-static void __init set_reboot_type(char *str)
+static int __init set_reboot_type(char *str)
 {
     for ( ; ; )
     {
@@ -74,6 +74,8 @@  static void __init set_reboot_type(char *str)
         case 't':
             reboot_type = *str;
             break;
+        default:
+            return -EINVAL;
         }
         if ( (str = strchr(str, ',')) == NULL )
             break;
@@ -82,6 +84,8 @@  static void __init set_reboot_type(char *str)
 
     if ( reboot_type == BOOT_EFI && !efi_enabled(EFI_RS) )
         reboot_type = BOOT_INVALID;
+
+    return 0;
 }
 custom_param("reboot", set_reboot_type);