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

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

 




On 4/8/25 00:42, Darrick J. Wong wrote:
On Tue, Apr 08, 2025 at 12:16:42AM +0530, Ritesh Harjani wrote:
Zorro Lang <zlang@xxxxxxxxxx> writes:
<snip>

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.
To prevent such misuse in future, should we add a warning/echo message
if the no. of arguments passed to _exit() is not 1?
Why not set status only if the caller provides an argument?

	test -n "$1" && status="$1"

And if the caller doesn't provide any, should status hold some default value? I have suggested something in [1]

[1] https://lore.kernel.org/all/3c1d608d-4ea0-4e24-9abc-95eb226101c2@xxxxxxxxx/

--NR


perhaps?

--D

-ritesh

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