[PATCH libinput 1/5] util: allow list_remove() on a NULL node

Jon A. Cruz jonc at osg.samsung.com
Mon Jun 29 20:53:20 PDT 2015


On 06/29/2015 04:32 PM, Peter Hutterer wrote:
> On Mon, Jun 29, 2015 at 04:00:51PM -0700, Ping Cheng wrote:
>> I guess Bill meant "||" should be used instead of "&&"? One of the == NULL
>> would lead to a crash...
> 
> that'd would hide potential memory corruption or other bugs and won't show
> up until later. if both are NULL, the code is correct. if one is NULL, we
> should crash immediately because if our list is corrupted, there's no
> sensible way of recovering.
> 


Exactly what I was thinking...

Except that it might be worth adding some comment somewhere that
explains the intent.

A comment could be warranted here *if* this were an exception.
However... there is an overall design intent with Wayland/Weston to
intentionally allow such corruption to immediately cause crashes. That
would seem to indicate something in perhaps a README/CONTRIBUTING or such.

On the other hand, it could be considered non-obvious that the both-null
case is the valid uninitialized situation and thus could warrant a
comment after all. Given that there already was some misreading of
Peter's intent, it might help maintenance to add a simple one.

-- 
Jon A. Cruz - Senior Open Source Developer
Samsung Open Source Group
jonc at osg.samsung.com


More information about the wayland-devel mailing list