43395f1 virDomainChrGetDomainPtrsInternal: Return an integer

Authored and Committed by mprivozn 7 years ago
    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>
    
        
file modified
+23 -16