]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virDomainChrGetDomainPtrsInternal: Return an integer
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 1 Jun 2016 12:39:01 +0000 (14:39 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 3 Jun 2016 07:15:49 +0000 (09:15 +0200)
commit43395f190b5f1691884d7e2a3cc9eab621715655
treeadf123d14159bf670bf8e400193135dbe3e48a6e
parentf916194c7ee9d212be1a1b2ff28625fca3e13aec
virDomainChrGetDomainPtrsInternal: Return an integer

There's this problem on the recent gcc-6.1:

In file included from conf/domain_conf.c:37:0:
conf/domain_conf.c: In function 'virDomainChrPreAlloc':
conf/domain_conf.c:14109:35: error: potential null pointer dereference [-Werror=null-dereference]
     return VIR_REALLOC_N(*arrPtr, *cntPtr + 1);
                                   ^~
./util/viralloc.h:158:73: note: in definition of macro 'VIR_REALLOC_N'
 # define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count), \
                                                                         ^~~~~
conf/domain_conf.c: In function 'virDomainChrRemove':
conf/domain_conf.c:14133:21: error: potential null pointer dereference [-Werror=null-dereference]
     for (i = 0; i < *cntPtr; i++) {
                     ^~~~~~~

GCC basically fails to see, that the
virDomainChrGetDomainPtrsInternal will never actually return NULL
because it's never called over a domain char device with _LAST
type. But to make it shut up, lets turn this function into
returning an integer and check in the callers if a zero value
value was returned.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c