This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: nonnull Re: [PATCH] Fix type warnings from clang compiler.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Fri, 11 Sep 2015 13:11:11 -0700
- Subject: Re: nonnull Re: [PATCH] Fix type warnings from clang compiler.
> extern Elf *dwfl_module_getelf (Dwfl_Module *, GElf_Addr *bias)
> __nonnull_attribute__ (1, 2);
>
> I believe in this case the first argument should not be nonnull.
> Since we would expect people to be able to chain for example the
> dwfl_addrmodule () call followed by a dwfl_module_getelf () call.
>
> So the correct fix in that case seems to be the removal of the nonnull
> attribute for the first argument and leave the NULL check against mod in
> the implementation.
Agreed.
> There is one other case where I am not totally sure the nonnull
> attribute was intended is for the internal function
> __libdw_visit_scopes. It was rewritten from having just one (pre)visit
> function to having both a previsit and postvisit callback function. In
> all cases we are using it with a previsit one. But maybe the intention
> was that you could only supply a postvisit one and keep the previsit one
> NULL?
That sounds like a generally reasonable thing, and obviously I always did
the reasonable thing because I'm so reasonable. But as it is an internal
function with few callers, tailoring it slightly to its extant callers is
certainly sensible.