All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@redhat.com>
Cc: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	fstests@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-xfs@vger.kernel.org, ojaswin@linux.ibm.com,
	zlang@kernel.org, david@fromorbit.com
Subject: Re: [PATCH v2 5/5] common: exit --> _exit
Date: Tue, 8 Apr 2025 07:33:46 -0700	[thread overview]
Message-ID: <20250408143346.GD6274@frogsfrogsfrogs> (raw)
In-Reply-To: <20250408142747.tojq7dhv3ad2mzaq@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com>

On Tue, Apr 08, 2025 at 10:27:48PM +0800, Zorro Lang wrote:
> On Tue, Apr 08, 2025 at 12:43:32AM +0530, Nirjhar Roy (IBM) wrote:
> > 
> > On 4/8/25 00:16, Ritesh Harjani (IBM) wrote:
> > > Zorro Lang <zlang@redhat.com> writes:
> > > 
> > > > On Fri, Apr 04, 2025 at 10:34:47AM +0530, Ritesh Harjani wrote:
> > > > > "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com> writes:
> > > > > 
> > > > > > Replace exit <return-val> with _exit <return-val> which
> > > > > > is introduced in the previous patch.
> > > > > > 
> > > > > > Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
> > > <...>
> > > > > > ---
> > > > > > @@ -225,7 +225,7 @@ _filter_bmap()
> > > > > >   die_now()
> > > > > >   {
> > > > > >   	status=1
> > > > > > -	exit
> > > > > > +	_exit
> > > > > Why not remove status=1 too and just do _exit 1 here too?
> > > > > Like how we have done at other places?
> > > > Yeah, nice catch! As the defination of _exit:
> > > > 
> > > >    _exit()
> > > >    {
> > > >         status="$1"
> > > >         exit "$status"
> > > >    }
> > > > 
> > > > The
> > > >    "
> > > >    status=1
> > > >    exit
> > > >    "
> > > > should be equal to:
> > > >    "
> > > >    _exit 1
> > > >    "
> > > > 
> > > > And "_exit" looks not make sense, due to it gives null to status.
> > > > 
> > > > Same problem likes below:
> > > > 
> > > > 
> > > > @@ -3776,7 +3773,7 @@ _get_os_name()
> > > >                  echo 'linux'
> > > >          else
> > > >                  echo Unknown operating system: `uname`
> > > > -               exit
> > > > +               _exit
> > > > 
> > > > 
> > > > The "_exit" without argument looks not make sense.
> > > > 
> > > That's right. _exit called with no argument could make status as null.
> > Yes, that is correct.
> > > To prevent such misuse in future, should we add a warning/echo message
> > 
> > Yeah, the other thing that we can do is 'status=${1:-0}'. In that case, for
>                                            ^^^^^^^^^^^^^^
> That's good to me, I'm just wondering if the default value should be "1", to
> tell us "hey, there's an unknown exit status" :)

I think status=1 usually means failure...

/usr/include/stdlib.h:92:#define        EXIT_FAILURE    1       /* Failing exit status.  */
/usr/include/stdlib.h:93:#define        EXIT_SUCCESS    0       /* Successful exit status.  */

--D

> Thanks,
> Zorro
> 
> > cases where the return value is a success, we simply use "_exit". Which one
> > do you think adds more value and flexibility to the usage?
> > 
> > --NR
> > 
> > > if the no. of arguments passed to _exit() is not 1?
> > > 
> > > -ritesh
> > 
> > -- 
> > Nirjhar Roy
> > Linux Kernel Developer
> > IBM, Bangalore
> > 
> 
> 

  reply	other threads:[~2025-04-08 14:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01  6:43 [PATCH v2 0/5] Minor cleanups in common/ Nirjhar Roy (IBM)
2025-04-01  6:43 ` [PATCH v2 1/5] generic/749: Remove redundant sourcing of common/rc Nirjhar Roy (IBM)
2025-04-04  3:31   ` Ritesh Harjani
2025-04-01  6:43 ` [PATCH v2 2/5] check: Remove redundant _test_mount in check Nirjhar Roy (IBM)
2025-04-04  3:36   ` Ritesh Harjani
2025-04-08  5:41     ` Nirjhar Roy (IBM)
2025-04-08  5:45     ` Nirjhar Roy (IBM)
2025-04-01  6:43 ` [PATCH v2 3/5] check,common{rc,preamble}: Decouple init_rc() call from sourcing common/rc Nirjhar Roy (IBM)
2025-04-04  4:00   ` Ritesh Harjani
2025-04-04  4:52     ` Nirjhar Roy (IBM)
2025-04-08  5:42     ` Nirjhar Roy (IBM)
2025-04-01  6:43 ` [PATCH v2 4/5] common/config: Introduce _exit wrapper around exit command Nirjhar Roy (IBM)
2025-04-04  5:03   ` Ritesh Harjani
2025-04-01  6:44 ` [PATCH v2 5/5] common: exit --> _exit Nirjhar Roy (IBM)
2025-04-04  5:04   ` Ritesh Harjani
2025-04-07 16:19     ` Zorro Lang
2025-04-07 18:46       ` Ritesh Harjani
2025-04-07 19:12         ` Darrick J. Wong
2025-04-07 19:19           ` Nirjhar Roy (IBM)
2025-04-07 19:13         ` Nirjhar Roy (IBM)
2025-04-08 14:27           ` Zorro Lang
2025-04-08 14:33             ` Darrick J. Wong [this message]
2025-04-08 16:25               ` Nirjhar Roy (IBM)
2025-04-07 18:59       ` Nirjhar Roy (IBM)
2025-04-01 21:37 ` [PATCH v2 0/5] Minor cleanups in common/ Dave Chinner
2025-04-04 14:31   ` Nirjhar Roy (IBM)

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=20250408143346.GD6274@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=david@fromorbit.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nirjhar.roy.lists@gmail.com \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=zlang@kernel.org \
    --cc=zlang@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.