Bug 721335

Summary: Defects revealed by Coverity scan
Product: Red Hat Enterprise Linux 6 Reporter: Michal Luscon <mluscon>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1CC: ajia, dyuan, eblake, kdudka, mzhan, rwu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.9.4-rc1-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 11:16:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 711151    
Bug Blocks:    

Description Michal Luscon 2011-07-14 10:39:01 UTC
Description of problem:

libvirt-0.8.7/src/storage/storage_backend.c:795 - unterminated_case: This case (value 2) is not terminated by a 'break' statement.

libvirt-0.8.7/src/lxc/veth.c:132 - Returning potentially uninitialized value "rc".

Version-Release number of selected component (if applicable):
0.8.7-18.1

Additional info:

These defects were probably introduced by Red Hat patches.

Comment 2 Eric Blake 2011-07-14 12:04:35 UTC
(In reply to comment #0)
> Description of problem:
> 
> libvirt-0.8.7/src/storage/storage_backend.c:795 - unterminated_case: This case
> (value 2) is not terminated by a 'break' statement.

Dup of bug 711151.

> 
> libvirt-0.8.7/src/lxc/veth.c:132 - Returning potentially uninitialized value
> "rc".

Fixed by upstream commit:

commit c59176c109457161861fd883111373410d3b3a66
Author: Daniel P. Berrange <berrange>
Date:   Thu Mar 17 15:54:24 2011 +0000

    Fix uninitialized variable & error reporting in LXC veth setup
    
    THe veth setup in LXC had a couple of flaws, first brInit did
    not report any error when it failed. Second vethCreate() did
    not correctly initialize the variable containing the return
    code, so could report failure even when it succeeded.
    
    * src/lxc/lxc_driver.c: Report error when brInit fails
    * src/lxc/veth.c: Fix uninitialized variable

Comment 7 Alex Jia 2011-08-08 10:00:24 UTC
It seems the above patch hasn't resolved the first issue:
libvirt-0.8.7/src/storage/storage_backend.c:795 - unterminated_case: This case
(value 2) is not terminated by a 'break' statement.

Need to add 'break' into default branch of switch statement followed by virCommandAddArg(cmd, "-e") line to avoid this warning, it looks like this:


 643 static int
 644 virStorageBackendCreateQemuImg(virConnectPtr conn,
 645                                virStoragePoolObjPtr pool,
 646                                virStorageVolDefPtr vol,
 647                                virStorageVolDefPtr inputvol,
 648                                unsigned int flags)
 649 {
 
 ......
 796         switch (imgformat) {
 ......
 814         default:
 815             VIR_INFO("Unable to set backing store format for %s with %s",
 816                      vol->target.path, create_tool);
 817 
 818             virCommandAddArg(cmd, vol->target.path);
 819             virCommandAddArgFormat(cmd, "%lluK", size_arg);
 820             if (do_encryption)
 821                 virCommandAddArg(cmd, "-e");
 822             break;
 823         }

Alex

Comment 8 Alex Jia 2011-08-08 10:09:59 UTC
This patch is used for resolving the first issue:
https://www.redhat.com/archives/libvir-list/2011-August/msg00262.html

Comment 9 Kamil Dudka 2011-08-08 10:16:50 UTC
(In reply to comment #7)
> It seems the above patch hasn't resolved the first issue:
> libvirt-0.8.7/src/storage/storage_backend.c:795 - unterminated_case: This case
> (value 2) is not terminated by a 'break' statement.

You are right.

> Need to add 'break' into default branch of switch statement followed by
> virCommandAddArg(cmd, "-e") line to avoid this warning, it looks like this:

Not really, you need to add 'break' _before_ the default branch.

The defect went away with this upstream commit:

http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=1ccc16c

Comment 10 Kamil Dudka 2011-08-08 10:31:57 UTC
(In reply to comment #8)
> This patch is used for resolving the first issue:
> https://www.redhat.com/archives/libvir-list/2011-August/msg00262.html

There is no point in adding break at the end of a switch.  As far as I understand the fragment of the code, this patch solves nothing.  Where is actually the git repository where the patch landed to?

Comment 11 Alex Jia 2011-08-08 14:06:29 UTC
(In reply to comment #9)
> (In reply to comment #7)
> > It seems the above patch hasn't resolved the first issue:
> > libvirt-0.8.7/src/storage/storage_backend.c:795 - unterminated_case: This case
> > (value 2) is not terminated by a 'break' statement.
> 
> You are right.
> 
> > Need to add 'break' into default branch of switch statement followed by
> > virCommandAddArg(cmd, "-e") line to avoid this warning, it looks like this:
> 
> Not really, you need to add 'break' _before_ the default branch.
> 
> The defect went away with this upstream commit:
> 
> http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=1ccc16c

Yeah, it's my fault, I'm working on latest libvirt git tree, hence I can see 'break' _before_ the default branch.

Alex

Comment 12 Eric Blake 2011-08-08 14:06:41 UTC
Nothing further is needed for this BZ - libvirt 0.9.4-1.el6 should already have all issued patched, per comment 2.

Comment 13 Alex Jia 2011-08-08 14:09:33 UTC
(In reply to comment #10)
> (In reply to comment #8)
> > This patch is used for resolving the first issue:
> > https://www.redhat.com/archives/libvir-list/2011-August/msg00262.html
> 
> There is no point in adding break at the end of a switch.  As far as I
> understand the fragment of the code, this patch solves nothing.  Where is
> actually the git repository where the patch landed to?

Agree, it's not necessary to add break at the end of a switch.

Kamil, thanks for your comments.

Ale

Comment 14 Alex Jia 2011-08-08 14:11:43 UTC
This bug has been fixed based on Comment 2 and Comment 8, so change the bug to VERIFIED status.

Comment 18 Michal Luscon 2011-09-23 09:09:04 UTC
Coverity scan found new added defect in the libvirt package - 

/src/qemu/qemu_process.c:2605 - Assigning: "obj" = 0.
/src/qemu/qemu_process.c:2607 - Passing null variable "obj" to function "virDomainObjIsActive", which dereferences it.

version - libvirt-0.9.4-11.el6

If you would like to have this in new bugzilla entry, please contact me.

Comment 19 Alex Jia 2011-09-23 09:30:41 UTC
(In reply to comment #18)
> Coverity scan found new added defect in the libvirt package - 

Hi Michal,
This issue has been fixed on libvirt upstream, and we have a bug to trace some issues are raised by Coverity: 

Patch for upstream:
https://www.redhat.com/archives/libvir-list/2011-September/msg00859.html

Bug tracing:
https://bugzilla.redhat.com/show_bug.cgi?id=739704


Thanks,
Alex

Comment 20 errata-xmlrpc 2011-12-06 11:16:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1513.html