The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Matteo Croce <mcroce@linux.microsoft.com>
Cc: linux-kernel@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>,
	Arnd Bergmann <arnd@arndb.de>, Mike Rapoport <rppt@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Pavel Tatashin <pasha.tatashin@soleen.com>,
	Robin Holt <robinmholt@gmail.com>,
	Fabian Frederick <fabf@skynet.be>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v3 3/3] reboot: refactor and comment the cpu selection code
Date: Thu, 5 Nov 2020 19:09:53 +0100	[thread overview]
Message-ID: <20201105180953.GI1602@alley> (raw)
In-Reply-To: <20201103214025.116799-4-mcroce@linux.microsoft.com>

On Tue 2020-11-03 22:40:25, Matteo Croce wrote:
> From: Matteo Croce <mcroce@microsoft.com>
> 
> Small improvements to the code, without changing the way it works:
> - use a local variable, to avoid a small time lapse where reboot_cpu
>   can have an invalid value
> - comment the code which is not easy to understand at a glance
> - merge two identical code blocks into one
> - replace pointer arithmetics with equivalent array syntax
> 
> Signed-off-by: Matteo Croce <mcroce@microsoft.com>
> ---
>  kernel/reboot.c | 30 +++++++++++++++++-------------
>  1 file changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/kernel/reboot.c b/kernel/reboot.c
> index af6f23d8bea1..dd483bde932b 100644
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -551,20 +551,24 @@ static int __init reboot_setup(char *str)
>  			break;
>  
>  		case 's':
> -			if (isdigit(*(str+1)))
> -				reboot_cpu = simple_strtoul(str+1, NULL, 0);
> -			else if (str[1] == 'm' && str[2] == 'p' &&
> -							isdigit(*(str+3)))
> -				reboot_cpu = simple_strtoul(str+3, NULL, 0);
> -			else
> +			/*
> +			 * reboot_cpu is s[mp]#### with #### being the processor
> +			 * to be used for rebooting. Skip 's' or 'smp' prefix.
> +			 */
> +			str += str[1] == 'm' && str[2] == 'p' ? 3 : 1;
> +
> +			if (isdigit(str[0])) {
> +				int cpu = simple_strtoul(str, NULL, 0);
> +
> +				if (cpu >= num_possible_cpus()) {
> +					pr_err("Ignoring the CPU number in reboot= option. "
> +					"CPU %d exceeds possible cpu number %d\n",

Same here. I am not sure if Andrew would like to get this on a single
line.

In both cases:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

      reply	other threads:[~2020-11-05 18:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 21:40 [PATCH v3 0/3] fix parsing of reboot= cmdline Matteo Croce
2020-11-03 21:40 ` [PATCH v3 1/3] Revert "kernel/reboot.c: convert simple_strtoul to kstrtoint" Matteo Croce
2020-11-05 18:02   ` Petr Mladek
2020-11-03 21:40 ` [PATCH v3 2/3] reboot: fix overflow parsing reboot cpu number Matteo Croce
2020-11-05 18:09   ` Petr Mladek
2020-11-05 18:14     ` Matteo Croce
2020-11-06 10:18       ` Petr Mladek
2020-11-03 21:40 ` [PATCH v3 3/3] reboot: refactor and comment the cpu selection code Matteo Croce
2020-11-05 18:09   ` Petr Mladek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201105180953.GI1602@alley \
    --to=pmladek@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=fabf@skynet.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mcroce@linux.microsoft.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=robinmholt@gmail.com \
    --cc=rppt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox