[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH for-4.10] libxl: handle NULL in libxl__enum_from_string
On 13/10/17 14:01, Ian Jackson wrote: > Wei Liu writes ("Re: [PATCH for-4.10] libxl: handle NULL in > libxl__enum_from_string"): >> I agree they shouldn't be called with NULL. We should guard against >> error (here or the libxl_*_type_from_string) or annotate the input can't >> be NULL. > I mean, who calls any libxl_*_from_string with s==NULL ? > > Also I don't think we should annotate that the input value can't be > NULL, especially in a situation like this where the semantics could > only be "this is wrong". The API (and the internal calling > conventions) are full of functions taking pointer arguments - are we > going to annotate each one of those to say that it cannot be NULL ? > > Instead, what we have actually done so far, is annotate when a pointer > parameter *may* be NULL, and, in that case, what that means: This is exactly what attribute nonnull exists for. As a bonus, using the attribute will have the compiler complain at you if it spots a way NULL gets passed, and UBSAN will add specific instrumentation to check. Alternatively, you could assert(s) which would catch all (ab)uses and also quiesce Coverity. ~Andrew _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |