Some ancient gcc fails to see the variables are initialized in a
separate function and a false positive is produced:
cc1: warnings being treated as errors
conf/domain_conf.c: In function 'virDomainChrGetDomainPtrs':
conf/domain_conf.c:10342: error: 'arrVar' may be used uninitialized in this
function [-Wuninitialized]
conf/domain_conf.c:10343: error: 'cntVar' may be used uninitialized in this
function [-Wuninitialized]
conf/domain_conf.c: In function 'virDomainChrInsert':
conf/domain_conf.c:10362: error: 'arrPtr' may be used uninitialized in this
function [-Wuninitialized]
conf/domain_conf.c:10363: error: 'cntPtr' may be used uninitialized in this
function [-Wuninitialized]
conf/domain_conf.c: In function 'virDomainChrRemove':
conf/domain_conf.c:10374: error: 'arrPtr' may be used uninitialized in this
function [-Wuninitialized]
conf/domain_conf.c:10375: error: 'cntPtr' may be used uninitialized in this
function [-Wuninitialized]
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under build breaker and trivial rules.
src/conf/domain_conf.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 365de77..562d98b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10339,8 +10339,8 @@ virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
const virDomainChrDef ***arrPtr,
size_t *cntPtr)
{
- virDomainChrDef ***arrVar;
- size_t *cntVar;
+ virDomainChrDef ***arrVar = NULL;
+ size_t *cntVar = NULL;
/* Cast away const; we add it back in the final assignment. */
virDomainChrGetDomainPtrsInternal((virDomainDefPtr) vmdef, type,
@@ -10359,8 +10359,8 @@ int
virDomainChrInsert(virDomainDefPtr vmdef,
virDomainChrDefPtr chr)
{
- virDomainChrDefPtr **arrPtr;
- size_t *cntPtr;
+ virDomainChrDefPtr **arrPtr = NULL;
+ size_t *cntPtr = NULL;
virDomainChrGetDomainPtrsInternal(vmdef, chr->deviceType, &arrPtr,
&cntPtr);
@@ -10371,8 +10371,8 @@ virDomainChrDefPtr
virDomainChrRemove(virDomainDefPtr vmdef,
virDomainChrDefPtr chr)
{
- virDomainChrDefPtr ret, **arrPtr;
- size_t i, *cntPtr;
+ virDomainChrDefPtr ret, **arrPtr = NULL;
+ size_t i, *cntPtr = NULL;
virDomainChrGetDomainPtrsInternal(vmdef, chr->deviceType, &arrPtr,
&cntPtr);
--
1.8.1.5
Show replies by date