diff mbox series

[1/2] powerpc/powernv: Treat an empty reboot string as default

Message ID 20200217024833.30580-1-oohall@gmail.com (mailing list archive)
State Accepted
Commit 16985f2d25095899685952296f128a71f0aff05c
Headers show
Series [1/2] powerpc/powernv: Treat an empty reboot string as default | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (a5bc6e124219546a81ce334dc9b16483d55e9abf)
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Oliver O'Halloran Feb. 17, 2020, 2:48 a.m. UTC
Treat an empty reboot cmd string the same as a NULL string. This squashes a
spurious unsupported reboot message that sometimes gets out when using
xmon.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 arch/powerpc/platforms/powernv/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexey Kardashevskiy Feb. 24, 2020, 2:32 a.m. UTC | #1
On 17/02/2020 13:48, Oliver O'Halloran wrote:
> Treat an empty reboot cmd string the same as a NULL string. This squashes a
> spurious unsupported reboot message that sometimes gets out when using
> xmon.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  arch/powerpc/platforms/powernv/setup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
> index 11fdae8..a8fe630 100644
> --- a/arch/powerpc/platforms/powernv/setup.c
> +++ b/arch/powerpc/platforms/powernv/setup.c
> @@ -229,7 +229,7 @@ static void  __noreturn pnv_restart(char *cmd)
>  	pnv_prepare_going_down();
>  
>  	do {
> -		if (!cmd)
> +		if (!cmd || !strlen(cmd))


nit: this does not matter here in practice but

if (!cmd || cmd[0] == '\0')

is faster (you do not care about the length anyway) and safer (@cmd can
potentially be endless) ;)


>  			rc = opal_cec_reboot();
>  		else if (strcmp(cmd, "full") == 0)
>  			rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL, NULL);
>
Andrew Donnellan Feb. 24, 2020, 3:13 a.m. UTC | #2
On 17/2/20 1:48 pm, Oliver O'Halloran wrote:
> Treat an empty reboot cmd string the same as a NULL string. This squashes a
> spurious unsupported reboot message that sometimes gets out when using
> xmon.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Pretty sure I've seen that spurious reboot message a few times and never 
thought to check why... this makes sense.

Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
Segher Boessenkool Feb. 24, 2020, 10:04 a.m. UTC | #3
On Mon, Feb 24, 2020 at 01:32:28PM +1100, Alexey Kardashevskiy wrote:
> On 17/02/2020 13:48, Oliver O'Halloran wrote:
> > Treat an empty reboot cmd string the same as a NULL string. This squashes a
> > spurious unsupported reboot message that sometimes gets out when using
> > xmon.

> > -		if (!cmd)
> > +		if (!cmd || !strlen(cmd))
> 
> nit: this does not matter here in practice but
> 
> if (!cmd || cmd[0] == '\0')
> 
> is faster (you do not care about the length anyway) and safer (@cmd can
> potentially be endless) ;)

No it isn't, this compiles to identical machine code.  (I tested with
GCC 9, and going back until 4.6 -- the generated code becomes
progressively worse (unrelated to this code, fwiw), but identical for
both cases all the time).


Segher
Alexey Kardashevskiy Feb. 25, 2020, 1:38 a.m. UTC | #4
On 24/02/2020 21:04, Segher Boessenkool wrote:
> On Mon, Feb 24, 2020 at 01:32:28PM +1100, Alexey Kardashevskiy wrote:
>> On 17/02/2020 13:48, Oliver O'Halloran wrote:
>>> Treat an empty reboot cmd string the same as a NULL string. This squashes a
>>> spurious unsupported reboot message that sometimes gets out when using
>>> xmon.
> 
>>> -		if (!cmd)
>>> +		if (!cmd || !strlen(cmd))
>>
>> nit: this does not matter here in practice but
>>
>> if (!cmd || cmd[0] == '\0')
>>
>> is faster (you do not care about the length anyway) and safer (@cmd can
>> potentially be endless) ;)
> 
> No it isn't, this compiles to identical machine code.  (I tested with
> GCC 9, and going back until 4.6 -- the generated code becomes
> progressively worse (unrelated to this code, fwiw), but identical for
> both cases all the time).

oh cool, I did not think gcc is that smart.
Michael Ellerman March 6, 2020, 12:27 a.m. UTC | #5
On Mon, 2020-02-17 at 02:48:32 UTC, Oliver O'Halloran wrote:
> Treat an empty reboot cmd string the same as a NULL string. This squashes a
> spurious unsupported reboot message that sometimes gets out when using
> xmon.
> 
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/16985f2d25095899685952296f128a71f0aff05c

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index 11fdae8..a8fe630 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -229,7 +229,7 @@  static void  __noreturn pnv_restart(char *cmd)
 	pnv_prepare_going_down();
 
 	do {
-		if (!cmd)
+		if (!cmd || !strlen(cmd))
 			rc = opal_cec_reboot();
 		else if (strcmp(cmd, "full") == 0)
 			rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL, NULL);