Skip to content

bootutil: add fallthrough to fix implicit fallthrough warning#2705

Open
supperthomas wants to merge 1 commit intomcu-tools:mainfrom
supperthomas:fix_warning
Open

bootutil: add fallthrough to fix implicit fallthrough warning#2705
supperthomas wants to merge 1 commit intomcu-tools:mainfrom
supperthomas:fix_warning

Conversation

@supperthomas
Copy link
Copy Markdown

@supperthomas supperthomas commented Apr 22, 2026

Add /* fallthrough */ annotation in the switch statement within boot_set_next() to explicitly mark the intended fallthrough from BOOT_MAGIC_UNSET to BOOT_MAGIC_GOOD, suppressing the compiler warning.

The comment style is already used elsewhere in the codebase (loader.c)
and is recognized by GCC -Wimplicit-fallthrough without relying on
any platform-specific macro definitions.

Signed-off-by: Supper Thomas <78900636@qq.com>
@supperthomas supperthomas changed the title bootutil: add __fallthrough to fix implicit fallthrough warning bootutil: add fallthrough to fix implicit fallthrough warning Apr 22, 2026
@supperthomas
Copy link
Copy Markdown
Author

@nordicjm

break;
}
/* Pass */
/* fallthrough */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I follow this, it appears to be a C23 feature and is done using [] style brackets https://en.cppreference.com/c/language/attributes/fallthrough - not that doing that would be acceptable in MCUboot because of supporting old compilers. Do you have a reference to something this fixes?

Copy link
Copy Markdown
Author

@supperthomas supperthomas Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case BOOT_SWAP_TYPE_TEST:
/* fallthrough */
case BOOT_SWAP_TYPE_PERM:
if (check_downgrade_prevention(state) != 0) {
/* Downgrade prevented */

When I enable the fallthrough compilation warning as an error, an error is reported during compilation at this code segment. I have made corresponding modifications by referring to other loader.c files, which should theoretically comply with the modification conventions of MCUboot. If the old compiler fails to handle this part properly, other code areas would presumably encounter the same issue as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nordicjm So, how to fix for the warning error?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants