compat/memory: fix build with old gcc
PATCH 1/1 compat/memory: fix build with old gcc
struct xen_add_to_physmap_batch's size field being uint16_t causes old compiler versions to warn about the pointless range check done inside compat_handle_okay().
xen/common/compat/memory.c +7 -5
@@ -206,18 +206,20 @@ int compat_memory_op(unsigned int cmd, X {unsigned int limit = (COMPAT_ARG_XLAT_SIZE -sizeof (*nat.atpb)) / (sizeof (nat.atpb->idxs.p) +sizeof (nat.atpb->gpfns.p)); +/* Use an intermediate variable to suppress warnings on old gcc: */ +unsigned int size = cmp.atpb.size;xen_ulong_t *idxs = (void *)(nat.atpb +1 );xen_pfn_t *gpfns = (void *)(idxs + limit);if (copy_from_guest (&cmp.atpb, compat,1 ) || - !compat_handle_okay (cmp.atpb.idxs, cmp.atpb.size) || - !compat_handle_okay (cmp.atpb.gpfns, cmp.atpb.size) || - !compat_handle_okay (cmp.atpb.errs, cmp.atpb.size) ) + !compat_handle_okay (cmp.atpb.idxs, size) || + !compat_handle_okay (cmp.atpb.gpfns, size) || + !compat_handle_okay (cmp.atpb.errs, size) )return -EFAULT ; end_extent = start_extent + limit; -if ( end_extent > cmp.atpb.size ) - end_extent = cmp.atpb.size; +if ( end_extent > size ) + end_extent = size; idxs -= start_extent; gpfns -= start_extent;
compat/memory: fix build with old gcc
struct xen_add_to_physmap_batch's size field being uint16_t causes old compiler versions to warn about the pointless range check done inside compat_handle_okay().
xen/common/compat/memory.c +7 -5
@@ -206,18 +206,20 @@ int compat_memory_op(unsigned int cmd, X {unsigned int limit = (COMPAT_ARG_XLAT_SIZE -sizeof (*nat.atpb)) / (sizeof (nat.atpb->idxs.p) +sizeof (nat.atpb->gpfns.p)); +/* Use an intermediate variable to suppress warnings on old gcc: */ +unsigned int size = cmp.atpb.size;xen_ulong_t *idxs = (void *)(nat.atpb +1 );xen_pfn_t *gpfns = (void *)(idxs + limit);if (copy_from_guest (&cmp.atpb, compat,1 ) || - !compat_handle_okay (cmp.atpb.idxs, cmp.atpb.size) || - !compat_handle_okay (cmp.atpb.gpfns, cmp.atpb.size) || - !compat_handle_okay (cmp.atpb.errs, cmp.atpb.size) ) + !compat_handle_okay (cmp.atpb.idxs, size) || + !compat_handle_okay (cmp.atpb.gpfns, size) || + !compat_handle_okay (cmp.atpb.errs, size) )return -EFAULT ; end_extent = start_extent + limit; -if ( end_extent > cmp.atpb.size ) - end_extent = cmp.atpb.size; +if ( end_extent > size ) + end_extent = size; idxs -= start_extent; gpfns -= start_extent;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
struct xen_add_to_physmap_batch's size field being
uint16_tcauses old compiler versions to warn about the pointless range check done insidecompat_handle_okay().Signed-off-by Jan Beulich <[email protected]>Tested-by Andrew Cooper <[email protected]>
As far as the release goes this is fine IMHO.
Quoted 35 lines
xen/common/compat/memory.c +7
-5@@ -206,18 +206,20 @@ int compat_memory_op(unsigned int cmd, X {unsigned int limit = (COMPAT_ARG_XLAT_SIZE -sizeof (*nat.atpb)) / (sizeof (nat.atpb->idxs.p) +sizeof (nat.atpb->gpfns.p)); +/* Use an intermediate variable to suppress warnings on old gcc: */ +unsigned int size = cmp.atpb.size;xen_ulong_t *idxs = (void *)(nat.atpb +1 );xen_pfn_t *gpfns = (void *)(idxs + limit);if (copy_from_guest (&cmp.atpb, compat,1 ) || - !compat_handle_okay (cmp.atpb.idxs, cmp.atpb.size) || - !compat_handle_okay (cmp.atpb.gpfns, cmp.atpb.size) || - !compat_handle_okay (cmp.atpb.errs, cmp.atpb.size) ) + !compat_handle_okay (cmp.atpb.idxs, size) || + !compat_handle_okay (cmp.atpb.gpfns, size) || + !compat_handle_okay (cmp.atpb.errs, size) )return -EFAULT ; end_extent = start_extent + limit; -if ( end_extent > cmp.atpb.size ) - end_extent = cmp.atpb.size; +if ( end_extent > size ) + end_extent = size; idxs -= start_extent; gpfns -= start_extent;_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
struct xen_add_to_physmap_batch's size field being
uint16_tcauses old compiler versions to warn about the pointless range check done insidecompat_handle_okay().Signed-off-by Jan Beulich <[email protected]>Tested-by Andrew Cooper <[email protected]>
Quoted 33 lines
xen/common/compat/memory.c +7
-5@@ -206,18 +206,20 @@ int compat_memory_op(unsigned int cmd, X {unsigned int limit = (COMPAT_ARG_XLAT_SIZE -sizeof (*nat.atpb)) / (sizeof (nat.atpb->idxs.p) +sizeof (nat.atpb->gpfns.p)); +/* Use an intermediate variable to suppress warnings on old gcc: */ +unsigned int size = cmp.atpb.size;xen_ulong_t *idxs = (void *)(nat.atpb +1 );xen_pfn_t *gpfns = (void *)(idxs + limit);if (copy_from_guest (&cmp.atpb, compat,1 ) || - !compat_handle_okay (cmp.atpb.idxs, cmp.atpb.size) || - !compat_handle_okay (cmp.atpb.gpfns, cmp.atpb.size) || - !compat_handle_okay (cmp.atpb.errs, cmp.atpb.size) ) + !compat_handle_okay (cmp.atpb.idxs, size) || + !compat_handle_okay (cmp.atpb.gpfns, size) || + !compat_handle_okay (cmp.atpb.errs, size) )return -EFAULT ; end_extent = start_extent + limit; -if ( end_extent > cmp.atpb.size ) - end_extent = cmp.atpb.size; +if ( end_extent > size ) + end_extent = size;idxs -= start_extent; gpfns -= start_extent;