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

[xen staging] gnttab: work around "may be used uninitialized" warning



commit 9dc46386d89d83c73c41c2b19be83a73957c4393
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Mar 12 17:35:54 2021 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Mar 12 17:35:54 2021 +0100

    gnttab: work around "may be used uninitialized" warning
    
    Sadly I was wrong to suggest dropping vaddrs' initializer during review
    of v2 of the patch introducing this code. gcc 4.3 can't cope.
    
    Fixes: 52531c734ea1 ("xen/gnttab: Rework resource acquisition")
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Release-Acked-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
---
 xen/common/grant_table.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index f937c1d350..ab30e2e8cf 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -4026,7 +4026,7 @@ int gnttab_acquire_resource(
     struct grant_table *gt = d->grant_table;
     unsigned int i, final_frame;
     mfn_t tmp;
-    void **vaddrs;
+    void **vaddrs = NULL;
     int rc = -EINVAL;
 
     if ( !nr_frames )
@@ -4055,6 +4055,17 @@ int gnttab_acquire_resource(
         break;
     }
 
+    /*
+     * Some older toolchains can't spot that vaddrs won't remain uninitialized
+     * on non-error paths, and hence it needs setting to NULL at the top of the
+     * function.  Leave some runtime safety.
+     */
+    if ( !vaddrs )
+    {
+        ASSERT_UNREACHABLE();
+        rc = -ENODATA;
+    }
+
     /* Any errors?  Bad id, or from growing the table? */
     if ( rc )
         goto out;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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