[libvirt] [PATCH] build: silence a clang false positive

* src/qemu/qemu_monitor.c (qemuMonitorIOWriteWithFD): Work around recent clang shortcoming in analysis. --- False positive encountered with the latest F-13 clang :( src/qemu/qemu_monitor.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 443d216..abf1338 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1,7 +1,7 @@ /* * qemu_monitor.c: interaction with QEMU monitor console * - * Copyright (C) 2006-2009 Red Hat, Inc. + * Copyright (C) 2006-2010 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -374,6 +374,9 @@ qemuMonitorIOWriteWithFD(qemuMonitorPtr mon, msg.msg_controllen = sizeof(control); cmsg = CMSG_FIRSTHDR(&msg); + /* Some static analyzers, like clang 2.6-0.6.pre2, fail to see + that our use of CMSG_FIRSTHDR will not return NULL. */ + sa_assert(cmsg); cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; -- 1.6.6.1

Eric Blake wrote:
* src/qemu/qemu_monitor.c (qemuMonitorIOWriteWithFD): Work around recent clang shortcoming in analysis. ... diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c ... cmsg = CMSG_FIRSTHDR(&msg); + /* Some static analyzers, like clang 2.6-0.6.pre2, fail to see + that our use of CMSG_FIRSTHDR will not return NULL. */ + sa_assert(cmsg); cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS;
ACK. Note that with clang-2.7, which is in rawhide, this sa_assert is not needed.

On 05/05/2010 01:59 PM, Jim Meyering wrote:
Eric Blake wrote:
* src/qemu/qemu_monitor.c (qemuMonitorIOWriteWithFD): Work around recent clang shortcoming in analysis. ... diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c ... cmsg = CMSG_FIRSTHDR(&msg); + /* Some static analyzers, like clang 2.6-0.6.pre2, fail to see + that our use of CMSG_FIRSTHDR will not return NULL. */ + sa_assert(cmsg); cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS;
ACK.
Thanks; pushed.
Note that with clang-2.7, which is in rawhide, this sa_assert is not needed.
Fair enough, but it will be a few months before that version propagates into common usage :) -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Jim Meyering