diff mbox series

[XEN,v2,1/3] x86/emul: auxiliary definition of pseudo keyword fallthrough

Message ID f1dc3c1e70cfa9f7ce505e10624d0771f7697013.1731485149.git.federico.serafini@bugseng.com (mailing list archive)
State New
Headers show
Series x86: address violations of MISRA C Rule 16.3 | expand

Commit Message

Federico Serafini Nov. 13, 2024, 8:17 a.m. UTC
The pseudo keyword fallthrough shall be used to make explicit the
fallthrough intention at the end of a case statement (doing this
using comments is deprecated).

A definition of such pseudo keyword is already present in the
Xen build. This auxiliary definition makes it available also for
for test and fuzzing harness without iterfearing with the one
that the Xen build has.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
---
Changes from v1:
- moved definition in the right file;
- remove useless parenthesis;
- description improved.
---
 tools/tests/x86_emulator/x86-emulate.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Jan Beulich Nov. 13, 2024, 9:52 a.m. UTC | #1
On 13.11.2024 09:17, Federico Serafini wrote:
> --- a/tools/tests/x86_emulator/x86-emulate.h
> +++ b/tools/tests/x86_emulator/x86-emulate.h
> @@ -70,6 +70,16 @@
>  extern uint32_t mxcsr_mask;
>  extern struct cpu_policy cpu_policy;
>  
> +/*
> + * Pseudo keyword 'fallthrough' to make explicit the fallthrough intention at
> + * the end of a case statement block.
> + */
> +#if !defined(__clang__) && (__GNUC__ >= 7)
> +# define fallthrough        __attribute__((__fallthrough__))
> +#else
> +# define fallthrough        do {} while (0)  /* fallthrough */
> +#endif
> +
>  #define MMAP_SZ 16384
>  bool emul_test_init(void);
>  

I'm sure you saw my reply to Stefano where I said "Yes, just with the
addition not at the bottom of the file, but where the other compatibility
definitions are." Yes, you fulfilled the first half, but then you still
put it in the middle of testing-specific definitions / declarations. In
the interest of saving yet another round trip and to avoid yet further
misunderstanding, I'll take care of the further movement while committing.
Then
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan
diff mbox series

Patch

diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emulator/x86-emulate.h
index 00abc829b0..b01bb0cdce 100644
--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -70,6 +70,16 @@ 
 extern uint32_t mxcsr_mask;
 extern struct cpu_policy cpu_policy;
 
+/*
+ * Pseudo keyword 'fallthrough' to make explicit the fallthrough intention at
+ * the end of a case statement block.
+ */
+#if !defined(__clang__) && (__GNUC__ >= 7)
+# define fallthrough        __attribute__((__fallthrough__))
+#else
+# define fallthrough        do {} while (0)  /* fallthrough */
+#endif
+
 #define MMAP_SZ 16384
 bool emul_test_init(void);