[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v3 78/78] meson.build: increase -Wimplicit-fallthrough to 5
|
From: |
Emmanouil Pitsidianakis |
|
Subject: |
[RFC PATCH v3 78/78] meson.build: increase -Wimplicit-fallthrough to 5 |
|
Date: |
Fri, 13 Oct 2023 11:46:46 +0300 |
Make GCC's implicit fall-through static analysis stricter by requiring
the use of the fallthrough attribute statement instead of comments.
This makes the QEMU code style more consistent.
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
---
docs/devel/style.rst | 23 +++++++++++++++++++++++
meson.build | 2 +-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/docs/devel/style.rst b/docs/devel/style.rst
index 2f68b50079..f473dd24e9 100644
--- a/docs/devel/style.rst
+++ b/docs/devel/style.rst
@@ -634,6 +634,29 @@ are still some caveats to beware of
return g_steal_pointer(&foo);
}
+Implicit switch case fall-through
+=================================
+
+The C language allows switch cases to "fall-through" when a "break" statement
+is missing at the end of a case. This, however, introduces ambiguity in the
+code, as it's not always clear if the missing break is intentional or a bug.
+
+As this behaviour allows for bugs we do not allow "implicit fall-through".
+
+In order to identify intentional fall-through cases, we have adopted a
+pseudo-keyword macro 'fallthrough' which expands to gcc's extension
+__attribute__((__fallthrough__)). `Statement Attributes
+<https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html>`_
+
+All switch/case blocks must end in one of:
+
+.. code-block:: c
+
+ break;
+ fallthrough;
+ continue;
+ goto <label>;
+ return [expression];
QEMU Specific Idioms
********************
diff --git a/meson.build b/meson.build
index 79aef19bdc..e8805f0e0c 100644
--- a/meson.build
+++ b/meson.build
@@ -452,7 +452,7 @@ warn_flags = [
'-Wnested-externs',
'-Wendif-labels',
'-Wexpansion-to-defined',
- '-Wimplicit-fallthrough=2',
+ '-Wimplicit-fallthrough=5',
'-Wmissing-format-attribute',
'-Wno-initializer-overrides',
'-Wno-missing-include-dirs',
--
2.39.2
- [RFC PATCH v3 69/78] hw/rdma/rdma_backend.c: add fallthrough pseudo-keyword, (continued)
- [RFC PATCH v3 69/78] hw/rdma/rdma_backend.c: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 65/78] hw/nvme: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 67/78] hw/pci-host/pnv_phb3.c: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 70/78] hw/rtc: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 71/78] hw/s390x: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 75/78] migration: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 74/78] hw/cxl/cxl-device-utils.c: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 72/78] hw/ssi: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 78/78] meson.build: increase -Wimplicit-fallthrough to 5,
Emmanouil Pitsidianakis <=
- [RFC PATCH v3 62/78] hw/gpio: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 73/78] hw/watchdog/wdt_diag288.c: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 77/78] tests/unit/test-char.c: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- [RFC PATCH v3 76/78] qemu-img.c: add fallthrough pseudo-keyword, Emmanouil Pitsidianakis, 2023/10/13
- Re: [RFC PATCH v3 00/78] Strict disable implicit fallthrough, Philippe Mathieu-Daudé, 2023/10/13
- Re: [RFC PATCH v3 00/78] Strict disable implicit fallthrough, Richard Henderson, 2023/10/13