Revert "Reland: Clean up implicit fall through."
This reverts commit 6208b9aa9c4e8b7c9ff8063965c9f9aa519c1740.
Upstream coreboot has raised concerns that relying on GCC 7+ features
for host utilities is too restrictive, so revert this and go back to
customizing fallthrough annotations by compiler. Cleaned out some of the
C++-specific stuff because vboot isn't built with C++.
BRANCH=None
BUG=None
TEST=Built with clang and GCC.
Change-Id: I75d796d289b0a6c249fc8ac2dadb1453be468642
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2547821
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
diff --git a/firmware/2lib/include/2common.h b/firmware/2lib/include/2common.h
index dbc6264..0d66458 100644
--- a/firmware/2lib/include/2common.h
+++ b/firmware/2lib/include/2common.h
@@ -84,6 +84,13 @@
#endif
#endif
+#if (defined(__GNUC__) && __GNUC__ >= 7) || \
+ (defined(__clang__) && __has_attribute(fallthrough))
+#define VBOOT_FALLTHROUGH __attribute__((fallthrough))
+#else
+#define VBOOT_FALLTHROUGH ((void)0)
+#endif
+
/**
* Round up a number to a multiple of VB2_WORKBUF_ALIGN
*
diff --git a/firmware/lib/cgptlib/cgptlib.c b/firmware/lib/cgptlib/cgptlib.c
index 3fbb2fd..4c091d0 100644
--- a/firmware/lib/cgptlib/cgptlib.c
+++ b/firmware/lib/cgptlib/cgptlib.c
@@ -142,7 +142,7 @@
break;
}
/* Out of tries, so drop through and mark partition bad. */
- __attribute__ ((fallthrough));
+ VBOOT_FALLTHROUGH;
}
case GPT_UPDATE_ENTRY_BAD: {
/* Giving up on this partition entirely. */
diff --git a/firmware/lib/vboot_ui_legacy_clamshell.c b/firmware/lib/vboot_ui_legacy_clamshell.c
index a1ffe5b..027b49e 100644
--- a/firmware/lib/vboot_ui_legacy_clamshell.c
+++ b/firmware/lib/vboot_ui_legacy_clamshell.c
@@ -295,7 +295,7 @@
/* Only disable virtual dev switch if allowed by GBB */
if (!(gbb->flags & VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM))
break;
- __attribute__ ((fallthrough));
+ VBOOT_FALLTHROUGH;
case ' ':
/* See if we should disable virtual dev-mode switch. */
VB2_DEBUG("sd->flags=%#x\n", sd->flags);
diff --git a/firmware/lib/vboot_ui_legacy_wilco.c b/firmware/lib/vboot_ui_legacy_wilco.c
index 59a4968..7838bcf 100644
--- a/firmware/lib/vboot_ui_legacy_wilco.c
+++ b/firmware/lib/vboot_ui_legacy_wilco.c
@@ -67,7 +67,7 @@
return VB2_SUCCESS;
case 'a'...'z':
key = toupper(key);
- __attribute__ ((fallthrough));
+ VBOOT_FALLTHROUGH;
case '0'...'9':
case 'A'...'Z':
if ((len > 0 && is_vowel(key)) ||
diff --git a/futility/cmd_dump_fmap.c b/futility/cmd_dump_fmap.c
index ff7252c..3a0e14e 100644
--- a/futility/cmd_dump_fmap.c
+++ b/futility/cmd_dump_fmap.c
@@ -445,7 +445,7 @@
break;
case 'H':
opt_gaps = 1;
- __attribute__ ((fallthrough));
+ VBOOT_FALLTHROUGH;
case 'h':
opt_format = FMT_HUMAN;
opt_overlap++;
@@ -508,7 +508,7 @@
case FMT_NORMAL:
printf("hit at 0x%08x\n",
(uint32_t) ((char *)fmap - (char *)base_of_rom));
- __attribute__ ((fallthrough));
+ VBOOT_FALLTHROUGH;
default:
retval = normal_fmap(fmap,
argc - optind - 1,
diff --git a/futility/cmd_sign.c b/futility/cmd_sign.c
index c95b8c9..6243e3a 100644
--- a/futility/cmd_sign.c
+++ b/futility/cmd_sign.c
@@ -722,7 +722,7 @@
break;
case OPT_FV:
sign_option.fv_specified = 1;
- __attribute__ ((fallthrough));
+ VBOOT_FALLTHROUGH;
case OPT_INFILE:
sign_option.inout_file_count++;
infile = optarg;
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 25a55d8..bb10c39 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -313,7 +313,7 @@
break;
case VDAT_INT_FW_BOOT2:
value = (sh->flags & VBSD_BOOT_FIRMWARE_VBOOT2 ? 1 : 0);
- __attribute__ ((fallthrough));
+ VBOOT_FALLTHROUGH;
default:
break;
}