Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jun 2018 20:03:13 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Eitan Adler <eadler@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r335041 - head/lib/libc/stdlib
Message-ID:  <20180613194008.W2003@besplex.bde.org>
In-Reply-To: <201806130852.w5D8qH9a093758@repo.freebsd.org>
References:  <201806130852.w5D8qH9a093758@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 13 Jun 2018, Eitan Adler wrote:

> Log:
>  libc: remove explicit cast NULL in atoi
>
>  There isn't any reason to cast NULL so just remove it. Noticed when
>  cleaning up top.

There are many reasons to cast NULL for all members of the ato*() family:
- it is required if no prototype is in scope
- C99 specifies ato*() in terms of strtol*() and uses the cast to NULL,
   probably because this is simplest.  Omitting the cast is just wrong
   if no prototype is in scope.  Writing the explicit cast is simpler than
   writing caveats that the stated equivalence is only valid if a prototype
   is in scope.
- POSIX specifies ato*() in terms of strtol*() and uses the cast to NULL,
   exactly as in C99, probably because it defers to the C standard and
   doesn't and doesn't risk breaking it by changing its wording except when
   extending it.

FreeBSD used to do the same here, and should do the same here and elsewhere
by copying better wording from POSIX whenever possible.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180613194008.W2003>