public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/decodecode: Return 0 on success
@ 2026-03-18 15:05 Patrick Bellasi
  2026-03-18 17:55 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Bellasi @ 2026-03-18 15:05 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, Patrick Bellasi

The decodecode script always returns an exit code of 1, regardless of
whether the operation was successful or not. This is because the
"cleanup" function, which is registered to run on any script exit via
"trap cleanup EXIT", contains an unconditional "exit 1".

Remove the "exit 1" from the "cleanup" function so that it only performs
the necessary file cleanup without forcing a non-zero exit status.

Do that to ensure successful script executions now exit with code 0.
Exits due to errors are all handled by the "die()" function and will
still correctly exit with code 1.

Signed-off-by: Patrick Bellasi <derkling@google.com>
---
 scripts/decodecode | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/decodecode b/scripts/decodecode
index 6364218b2178f..01d25dc110de7 100755
--- a/scripts/decodecode
+++ b/scripts/decodecode
@@ -12,7 +12,6 @@ faultlinenum=1
 
 cleanup() {
 	rm -f $T $T.s $T.o $T.oo $T.aa $T.dis
-	exit 1
 }
 
 die() {
@@ -49,7 +48,7 @@ done
 
 if [ -z "$code" ]; then
 	rm $T
-	exit
+	die "Code line not found"
 fi
 
 echo $code
-- 
2.53.0.851.ga537e3e6e9-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scripts/decodecode: Return 0 on success
  2026-03-18 15:05 [PATCH] scripts/decodecode: Return 0 on success Patrick Bellasi
@ 2026-03-18 17:55 ` Andrew Morton
  2026-03-18 22:02   ` Randy Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2026-03-18 17:55 UTC (permalink / raw)
  To: Patrick Bellasi; +Cc: linux-kernel, Randy Dunlap

On Wed, 18 Mar 2026 15:05:45 +0000 Patrick Bellasi <derkling@google.com> wrote:

> The decodecode script always returns an exit code of 1, regardless of
> whether the operation was successful or not. This is because the
> "cleanup" function, which is registered to run on any script exit via
> "trap cleanup EXIT", contains an unconditional "exit 1".
> 
> Remove the "exit 1" from the "cleanup" function so that it only performs
> the necessary file cleanup without forcing a non-zero exit status.
> 
> Do that to ensure successful script executions now exit with code 0.
> Exits due to errors are all handled by the "die()" function and will
> still correctly exit with code 1.
> 
> ...
>
> --- a/scripts/decodecode
> +++ b/scripts/decodecode
> @@ -12,7 +12,6 @@ faultlinenum=1
>  
>  cleanup() {
>  	rm -f $T $T.s $T.o $T.oo $T.aa $T.dis
> -	exit 1
>  }
>  
>  die() {
> @@ -49,7 +48,7 @@ done
>  
>  if [ -z "$code" ]; then
>  	rm $T
> -	exit
> +	die "Code line not found"
>  fi
>  
>  echo $code

Seems reasonable.  Randy added this in 2008 - I'm sure he can remember
why ;)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scripts/decodecode: Return 0 on success
  2026-03-18 17:55 ` Andrew Morton
@ 2026-03-18 22:02   ` Randy Dunlap
  0 siblings, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2026-03-18 22:02 UTC (permalink / raw)
  To: Andrew Morton, Patrick Bellasi; +Cc: linux-kernel



On 3/18/26 10:55 AM, Andrew Morton wrote:
> On Wed, 18 Mar 2026 15:05:45 +0000 Patrick Bellasi <derkling@google.com> wrote:
> 
>> The decodecode script always returns an exit code of 1, regardless of
>> whether the operation was successful or not. This is because the
>> "cleanup" function, which is registered to run on any script exit via
>> "trap cleanup EXIT", contains an unconditional "exit 1".

Who would do that? and why?  ;)

>> Remove the "exit 1" from the "cleanup" function so that it only performs
>> the necessary file cleanup without forcing a non-zero exit status.
>>
>> Do that to ensure successful script executions now exit with code 0.
>> Exits due to errors are all handled by the "die()" function and will
>> still correctly exit with code 1.
>>
>> ...
>>
>> --- a/scripts/decodecode
>> +++ b/scripts/decodecode
>> @@ -12,7 +12,6 @@ faultlinenum=1
>>  
>>  cleanup() {
>>  	rm -f $T $T.s $T.o $T.oo $T.aa $T.dis
>> -	exit 1
>>  }
>>  
>>  die() {
>> @@ -49,7 +48,7 @@ done
>>  
>>  if [ -z "$code" ]; then
>>  	rm $T
>> -	exit
>> +	die "Code line not found"
>>  fi
>>  
>>  echo $code
> 
> Seems reasonable.  Randy added this in 2008 - I'm sure he can remember
> why ;)

Thanks, Andrew. NFI.

Acked-by: Randy Dunlap <rdunlap@infradead.org>
Thanks for the patch.

-- 
~Randy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-18 22:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 15:05 [PATCH] scripts/decodecode: Return 0 on success Patrick Bellasi
2026-03-18 17:55 ` Andrew Morton
2026-03-18 22:02   ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox