[libvirt] [PATCH v2 4/4] virDomainFormatSchedDef: Avoid false positive NULL dereference
Peter Krempa
pkrempa at redhat.com
Thu Jun 2 11:38:00 UTC 2016
On Thu, Jun 02, 2016 at 12:42:53 +0200, Michal Privoznik wrote:
> Okay, I admit that our code here is complex. It's not easy to
> spot that NULL deref can't really happen here. So it's no wonder
> that a dumb compiler fails to see all the connections and
> produces the following errors:
>
> CC conf/libvirt_conf_la-domain_conf.lo
> conf/domain_conf.c: In function 'virDomainDefFormatInternal':
> conf/domain_conf.c:22162:22: error: potential null pointer dereference [-Werror=null-dereference]
> if (sched->policy == i)
> ~~~~~^~~~~~~~
> conf/domain_conf.c:22191:26: error: potential null pointer dereference [-Werror=null-dereference]
> priority = sched->priority;
> ~~~~~~~~~^~~~~~~~~~~~~~~~~
> conf/domain_conf.c:22197:30: error: potential null pointer dereference [-Werror=null-dereference]
> if (sched->priority == priority)
> ~~~~~^~~~~~~~~~
> conf/domain_conf.c:22162:22: error: potential null pointer dereference [-Werror=null-dereference]
> if (sched->policy == i)
> ~~~~~^~~~~~~~
> conf/domain_conf.c:22191:26: error: potential null pointer dereference [-Werror=null-dereference]
> priority = sched->priority;
> ~~~~~~~~~^~~~~~~~~~~~~~~~~
> conf/domain_conf.c:22197:30: error: potential null pointer dereference [-Werror=null-dereference]
> if (sched->priority == priority)
> ~~~~~^~~~~~~~~~
I think you can trime a few of those.
> cc1: all warnings being treated as errors
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
> src/conf/domain_conf.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
ACK
More information about the libvir-list
mailing list