Skip to contentSkip to conversation

xen/grant: Mute gcc warning in steal_linear_address()

PATCH In review Zhenzhong Duan 4 participants 5 messages Aug 30, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/grant: Mute gcc warning in steal_linear_address()

Move reference of ol1e ahead or else we see below warning.

cc1: warnings being treated as errors
grant_table.c: In function 'replace_grant_pv_mapping':
grant_table.c:142: warning: 'ol1e.l1' may be used uninitialized in this function

---
 xen/arch/x86/pv/grant_table.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
xen/arch/x86/pv/grant_table.c +3 -3
index 6b7d855..5180334 100644
@@ -167,6 +167,9 @@ static bool steal_linear_address(unsigned long linear, l1_pgentry_t *out)
     ol1e = *pl1e;
     okay = UPDATE_ENTRY(l1, pl1e, ol1e, l1e_empty(), mfn_x(gl1mfn), curr, 0);
 
+    if ( okay )
+        *out = ol1e;
+
  out_unlock:
     page_unlock(page);
  out_put:
@@ -174,9 +177,6 @@ static bool steal_linear_address(unsigned long linear, l1_pgentry_t *out)
  out_unmap:
     unmap_domain_page(pl1e);
 
-    if ( okay )
-        *out = ol1e;
-
  out:
     return okay;
 }
Signature · 6 lines
1.7.3

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Zhenzhong Duan

Move reference of ol1e ahead or else we see below warning.

cc1: warnings being treated as errors
grant_table.c: In function 'replace_grant_pv_mapping':
grant_table.c:142: warning: 'ol1e.l1' may be used uninitialized in this function

I don't think there is a bug in the code. The compiler isn't smart enough to figure out ol1e won't be used when okay is false.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Zhenzhong Duan
Quoted 7 lines · Zhenzhong Duan

Move reference of ol1e ahead or else we see below warning.

cc1: warnings being treated as errors
grant_table.c: In function 'replace_grant_pv_mapping':
grant_table.c:142: warning: 'ol1e.l1' may be used uninitialized in this function

Which version of GCC?  This is a compiler bug, and it would be useful to highlight which version in the commit message.

The patch itself is fine.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Zhenzhong Duan
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 30.08.18 at 06:06, <[email protected]> wrote:

Move reference of ol1e ahead or else we see below warning.

cc1: warnings being treated as errors
grant_table.c: In function 'replace_grant_pv_mapping':
grant_table.c:142: warning: 'ol1e.l1' may be used uninitialized in this function

I'm fine with the change, but going forward please be more specific with your descriptions: Whether or not warnings get emitted for a certain piece of code often highly depends on compiler version. Let us know which version you've run this into with. For the record, I'm building on a wide range of gcc versions every once in a while, and I've not come across this warning so far (or else I would have sent a patch). The really old versions (4.1.x for example) can't really be used anymore for certain other reasons anyway, and I think it's about time we at least raise the bar a little (also for binutils, which iirc was the actual problem with here, using a version matching in original release time with gcc 4.1.x).

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 10 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 30.08.18 at 06:06, <[email protected]> wrote:

Move reference of ol1e ahead or else we see below warning.

cc1: warnings being treated as errors
grant_table.c: In function 'replace_grant_pv_mapping':
grant_table.c:142: warning: 'ol1e.l1' may be used uninitialized in this function

Quoted 11 lines

I'm fine with the change, but going forward please be more specific with your descriptions: Whether or not warnings get emitted for a certain piece of code often highly depends on compiler version. Let us know which version you've run this into with. For the record, I'm building on a wide range of gcc versions every once in a while, and I've not come across this warning so far (or else I would have sent a patch). The really old versions (4.1.x for example) can't really be used anymore for certain other reasons anyway, and I think it's about time we at least raise the bar a little (also for binutils, which iirc was the actual problem with here, using a version matching in original release time with gcc 4.1.x).

gcc version 4.1.2 20080704 (Red Hat 4.1.2-55)

Thanks
Zhenzhong

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel