[ofa-general] [PATCH] Non-supported functions should return NULL when returning pointers

Jon Mason jon at opengridcomputing.com
Thu Jan 17 09:44:39 PST 2008


On Wed, Jan 16, 2008 at 09:00:17AM +0200, Jack Morgenstein wrote:
> On Wednesday 16 January 2008 01:50, Jon Mason wrote:
> > Non-supported functions should return NULL when returning pointers.
> > Some/Most user space programs will not check for a (void *) to -ENOSYS,
> > which can look like a real address until referenced.
> > 
> This patch breaks consistency with all the other drivers, and with libibverbs.
> During the debugging cycle, user programs will get segmentation faults, and fix
> their code. 

I didn't see any other user space libs that return a (void *) -ENOSYS.

Since -ENOSYS could be a valid memory location, this is not the proper
thing to do.  Returning NULL will push the user space apps down the
correct error path, and allow them to fail gracefully.  Getting a seg
fault and crashing the app is not a good way to handle this, as this can
lead to many problems after the product has shipped.  If these errors are
handled correctly, then this greatly reduces this.

Thanks,
Jon

> 
> - Jack



More information about the general mailing list