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

[Xen-changelog] [xen stable-4.5] blktap: Fix two 'maybe uninitialized' variables



commit 845e8c1653242bbd9b9de5a081182db0f3f39054
Author:     Dario Faggioli <dario.faggioli@xxxxxxxxxx>
AuthorDate: Fri Jun 20 16:09:00 2014 +0200
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Wed Jan 6 11:32:18 2016 +0000

    blktap: Fix two 'maybe uninitialized' variables
    
    [ Cross-ported to blktap1 from 345e44a85d71a
      "blktap2: Fix two 'maybe uninitialized' variables" -iwj;
      Remainder of commit message is from blktap2's version. ]
    
    for which gcc 4.9.0 complains about, like this:
    
    block-qcow.c: In function `get_cluster_offset':
    block-qcow.c:431:3: error: `tmp_ptr' may be used uninitialized in this 
function
    [-Werror=maybe-uninitialized]
       memcpy(tmp_ptr, l1_ptr, 4096);
       ^
    block-qcow.c:606:7: error: `tmp_ptr2' may be used uninitialized in this
    function [-Werror=maybe-uninitialized]
       if (write(s->fd, tmp_ptr2, 4096) != 4096) {
           ^
    cc1: all warnings being treated as errors
    
/home/dario/Sources/xen/xen/xen.git/tools/blktap2/drivers/../../../tools/Rules.mk:89:
     recipe for target 'block-qcow.o' failed
    make[5]: *** [block-qcow.o] Error 1
    
    The proper behavior is to return upon allocation failure.
    About what to return, 0 seems the best option, looking
    at both the function and the call sites.
    
    Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
    
    Backport-requested-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
    Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/blktap/drivers/block-qcow.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tools/blktap/drivers/block-qcow.c 
b/tools/blktap/drivers/block-qcow.c
index 0e4e9cf..8fb6023 100644
--- a/tools/blktap/drivers/block-qcow.c
+++ b/tools/blktap/drivers/block-qcow.c
@@ -440,6 +440,7 @@ static uint64_t get_cluster_offset(struct tdqcow_state *s,
 
                if (posix_memalign((void **)&tmp_ptr, 4096, 4096) != 0) {
                        DPRINTF("ERROR allocating memory for L1 table\n");
+                        return 0;
                }
                memcpy(tmp_ptr, l1_ptr, 4096);
 
@@ -613,6 +614,7 @@ found:
                
                if (posix_memalign((void **)&tmp_ptr2, 4096, 4096) != 0) {
                        DPRINTF("ERROR allocating memory for L1 table\n");
+                        return 0;
                }
                memcpy(tmp_ptr2, l2_ptr, 4096);
                lseek(s->fd, l2_offset + (l2_sector << 12), SEEK_SET);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.5

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.