Revert "Reland: Clean up implicit fall through."

This reverts commit 6208b9aa9c.

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>
This commit is contained in:
Julius Werner 2020-11-18 16:31:27 -08:00
parent abcd6d2454
commit 9d4053df76
7 changed files with 14 additions and 7 deletions

View File

@ -84,6 +84,13 @@ struct vb2_public_key;
#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
*

View File

@ -142,7 +142,7 @@ int GptUpdateKernelWithEntry(GptData *gpt, GptEntry *e, uint32_t update_type)
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. */

View File

@ -295,7 +295,7 @@ static vb2_error_t vb2_developer_ui(struct vb2_context *ctx)
/* 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);

View File

@ -67,7 +67,7 @@ static vb2_error_t vb2_enter_vendor_data_ui(struct vb2_context *ctx,
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)) ||

View File

@ -445,7 +445,7 @@ static int do_dump_fmap(int argc, char *argv[])
break;
case 'H':
opt_gaps = 1;
__attribute__ ((fallthrough));
VBOOT_FALLTHROUGH;
case 'h':
opt_format = FMT_HUMAN;
opt_overlap++;
@ -508,7 +508,7 @@ static int do_dump_fmap(int argc, char *argv[])
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,

View File

@ -722,7 +722,7 @@ static int do_sign(int argc, char *argv[])
break;
case OPT_FV:
sign_option.fv_specified = 1;
__attribute__ ((fallthrough));
VBOOT_FALLTHROUGH;
case OPT_INFILE:
sign_option.inout_file_count++;
infile = optarg;

View File

@ -313,7 +313,7 @@ static int GetVdatInt(VdatIntField field)
break;
case VDAT_INT_FW_BOOT2:
value = (sh->flags & VBSD_BOOT_FIRMWARE_VBOOT2 ? 1 : 0);
__attribute__ ((fallthrough));
VBOOT_FALLTHROUGH;
default:
break;
}