Skip to content

Commit

Permalink
gnttab: work around "may be used uninitialized" warning
Browse files Browse the repository at this point in the history
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: 52531c7 ("xen/gnttab: Rework resource acquisition")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
  • Loading branch information
jbeulich committed Mar 12, 2021
1 parent aa50f45 commit 9dc4638
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion xen/common/grant_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9dc4638

Please sign in to comment.