svn commit: r315360 - head/lib/libkvm

Ngie Cooper (yaneurabeya) yaneurabeya at gmail.com
Thu Mar 16 04:44:06 UTC 2017


> On Mar 15, 2017, at 21:32, Warner Losh <imp at bsdimp.com> wrote:
> 
> On Wed, Mar 15, 2017 at 8:31 PM, Ngie Cooper <ngie at freebsd.org> wrote:
>> Author: ngie
>> Date: Thu Mar 16 02:31:42 2017
>> New Revision: 315360
>> URL: https://svnweb.freebsd.org/changeset/base/315360
>> 
>> Log:
>>  Return NULL instead of 0 on failure in _kvm_open, kvm_open{,2,files}
>> 
>>  This is being done for the following reasons:
>>  - kvm_open(3), etc says they will return NULL.
>>  - NULL by definition is (void*)0 per POSIX, but can be redefined,
>>    depending on the compiler, etc.
> 
> No, it can't. The C language requires all integral expressions that
> evaluate to zero to convert to the NULL pointer. This is independent
> of the internal representation of the NULL pointer.
> 
> So this change is an NOP for all compilers. It's a good STYLE change.

Someone made an argument a few weeks ago about NULL being definable as a non-zero value on some esoteric architectures or OSes.

I agree though, this is largely stylistic/pedantic for a good cause. If someone set NULL to something non-zero in value, they would be looking for pain :).

-Ngie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20170315/b1b8f578/attachment.sig>


More information about the svn-src-head mailing list