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

[PATCH v2 2/2] xen/x86_emulate: address violations of MISRA C:2012 Rule 14.4



From: Maria Celeste Cesario <maria.celeste.cesario@xxxxxxxxxxx>

The xen sources contain violations of MISRA C:2012 Rule 14.4 whose
headline states:
"The controlling expression of an if statement and the controlling
expression of an iteration-statement shall have essentially Boolean type".

Add comparisons to avoid using enum constants as controlling expressions
to comply with Rule 14.4.
No functional change.

Signed-off-by: Maria Celeste Cesario  <maria.celeste.cesario@xxxxxxxxxxx>
Signed-off-by: Simone Ballarin  <simone.ballarin@xxxxxxxxxxx>
---
Changes in v2:
- move changes on hpet.c and msi.c to x86/IOMMU patch.
- rename prefix from xen/x86 to xen/x86_emulate.
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c 
b/xen/arch/x86/x86_emulate/x86_emulate.c
index cf780da501..00b7365ed3 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1320,7 +1320,7 @@ x86_emulate(
         ea.bytes = 2;
         goto srcmem_common;
     case SrcMem:
-        if ( state->simd_size )
+        if ( state->simd_size != simd_none )
             break;
         ea.bytes = (d & ByteOp) ? 1 : op_bytes;
     srcmem_common:
@@ -1460,7 +1460,7 @@ x86_emulate(
         /* Becomes a normal DstMem operation from here on. */
     case DstMem:
         generate_exception_if(ea.type == OP_MEM && evex.z, X86_EXC_UD);
-        if ( state->simd_size )
+        if ( state->simd_size != simd_none )
         {
             generate_exception_if(lock_prefix, X86_EXC_UD);
             break;
@@ -8176,7 +8176,7 @@ x86_emulate(
         goto done;
     }
 
-    if ( state->rmw )
+    if ( state->rmw != rmw_NONE )
     {
         ea.val = src.val;
         op_bytes = dst.bytes;
@@ -8205,7 +8205,7 @@ x86_emulate(
 
         dst.type = OP_NONE;
     }
-    else if ( state->simd_size )
+    else if ( state->simd_size != simd_none )
     {
         generate_exception_if(!op_bytes, X86_EXC_UD);
         generate_exception_if((vex.opcx && (d & TwoOp) &&
-- 
2.40.0




 


Rackspace

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