Re: [PATCH 2/4] openvz: Need to initialize 'ret' for kb_per_pages error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/14/2013 11:08 AM, Guannan Ren wrote:
> On 01/08/2013 11:40 PM, John Ferlan wrote:
>> ---
>>   src/openvz/openvz_conf.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
>> index 09518d5..1ad3feb 100644
>> --- a/src/openvz/openvz_conf.c
>> +++ b/src/openvz/openvz_conf.c
>> @@ -485,7 +485,7 @@ error:
>>   static int
>>   openvzReadMemConf(virDomainDefPtr def, int veid)
>>   {
>> -    int ret;
>> +    int ret = -1;
>>       char *temp = NULL;
>>       unsigned long long barrier, limit;
>>       const char *param;
> 
>    Is this necessary to do this,  ret will be initialized to a value any
> way
>    before any condition clause.

>From Coverity:

(1) Event var_decl: 	Declaring variable "ret" without initializer.
Also see events: 	[uninit_use]
488  	    int ret;

...

494  	    kb_per_pages = openvzKBPerPages();
(2) Event cond_true: 	Condition "kb_per_pages < 0", taking true branch
495  	    if (kb_per_pages < 0)
(3) Event goto: 	Jumping to label "error"
496  	        goto error;
497  	

...

(4) Event label: 	Reached label "error"
548  	error:
(5) Event cond_true: 	Condition "1", taking true branch
549  	    VIR_FREE(temp);
(6) Event uninit_use: 	Using uninitialized value "ret".
Also see events: 	[var_decl]
550  	    return ret;

> 
>    There is no harm to set it initially.
>     ACK
> 
> -- 
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]