Re: [PATCH v2 5/5] common: exit --> _exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 4/8/25 20:03, Darrick J. Wong wrote:
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@xxxxxxxxxx> writes:

On Fri, Apr 04, 2025 at 10:34:47AM +0530, Ritesh Harjani wrote:
"Nirjhar Roy (IBM)" <nirjhar.roy.lists@xxxxxxxxx> 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@xxxxxxxxx>
<...>
---
@@ -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.  */

Yeah, right. I like Darrick's suggestion to explicitly set the value of status in _exit() only if it is passed (test -n "$1" && status="$1"). This will preserve any intentional pre-set value of status. I have sent a [v3] for this series but haven't modified the definition of _exit. I will wait for further comments on [v3] and make this change (along with the other changes that will be suggested).

[v3] https://lore.kernel.org/all/cover.1744090313.git.nirjhar.roy.lists@xxxxxxxxx/

--NR


--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


--
Nirjhar Roy
Linux Kernel Developer
IBM, Bangalore





[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux