[libvirt] [PATCH 6/7] xend_internal.c: assure clang that we do not dereference NULL
Eric Blake
eblake at redhat.com
Wed Apr 14 16:50:12 UTC 2010
On 04/14/2010 10:02 AM, Jim Meyering wrote:
> From: Jim Meyering <meyering at redhat.com>
>
> * src/xen/xend_internal.c (xend_parse_sexp_desc_char): Add three
> uses of sa_assert, each preceding a strchr(value,... to assure
> clang that "value" is non-NULL.
> ---
> src/xen/xend_internal.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
> index c4e73b7..950f1b5 100644
> --- a/src/xen/xend_internal.c
> +++ b/src/xen/xend_internal.c
> @@ -1284,6 +1284,7 @@ xend_parse_sexp_desc_char(virBufferPtr buf,
> virBufferVSprintf(buf, " <source path='%s'/>\n",
> value);
> } else if (STREQ(type, "tcp")) {
> + sa_assert (value);
> const char *offset = strchr(value, ':');
This introduces an expression before a declaration, even when sa_assert
is empty. I know that we already rely on several other C99 features
(like __VA_ARGS__ from the preprocessor), but my understanding has been
that we have been trying to stick with C89 declarations first still.
Does this need to be refactored accordingly?
Besides, xend_parse_sexp_desc_char already dereferences value at line
1224; would it be possible to fix this by marking the argument as
NONNULL, rather than adding sa_assert()?
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100414/30af526a/attachment-0001.sig>
More information about the libvir-list
mailing list