helpers: Add FALLTHROUGH macro
Use gcc and clang's 'fallthrough' attribute instead of a comment to fall through switch statements. This allows to request fall through inside a block and prevents issues with preprocessed files. Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
parent
d11c72fee3
commit
d1ee47361c
|
@ -1711,7 +1711,7 @@ handle_non_csi_escape(struct terminal *terminal, char code)
|
|||
break;
|
||||
case 'E': /* NEL - Newline */
|
||||
terminal->column = 0;
|
||||
// fallthrough
|
||||
FALLTHROUGH;
|
||||
case 'D': /* IND - Linefeed */
|
||||
terminal->row += 1;
|
||||
if (terminal->row > terminal->margin_bottom) {
|
||||
|
@ -1893,7 +1893,7 @@ handle_special_char(struct terminal *terminal, char c)
|
|||
if (terminal->mode & MODE_LF_NEWLINE) {
|
||||
terminal->column = 0;
|
||||
}
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case '\v':
|
||||
case '\f':
|
||||
terminal->row++;
|
||||
|
|
|
@ -398,13 +398,13 @@ get_output_work_area(struct desktop_shell *shell,
|
|||
switch (shell->panel_position) {
|
||||
case WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP:
|
||||
area->y += sh_output->panel_surface->height;
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM:
|
||||
area->height -= sh_output->panel_surface->height;
|
||||
break;
|
||||
case WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT:
|
||||
area->x += sh_output->panel_surface->width;
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT:
|
||||
area->width -= sh_output->panel_surface->width;
|
||||
break;
|
||||
|
|
|
@ -2941,8 +2941,8 @@ wayland_backend_create(struct weston_compositor *compositor,
|
|||
if (renderer != WESTON_RENDERER_PIXMAN)
|
||||
break;
|
||||
weston_log_continue("; falling back to Pixman.\n");
|
||||
FALLTHROUGH;
|
||||
}
|
||||
/* fallthrough */
|
||||
case WESTON_RENDERER_PIXMAN:
|
||||
if (weston_compositor_init_renderer(compositor,
|
||||
WESTON_RENDERER_PIXMAN,
|
||||
|
|
|
@ -235,6 +235,13 @@ do { \
|
|||
#define unreachable(str) assert(!str)
|
||||
#endif
|
||||
|
||||
#if __has_attribute(fallthrough)
|
||||
/* Supported at least by gcc and clang. */
|
||||
#define FALLTHROUGH __attribute__((fallthrough))
|
||||
#else
|
||||
#define FALLTHROUGH do {} while(0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns number of bits set in 32-bit value x.
|
||||
*
|
||||
|
|
|
@ -728,31 +728,31 @@ create_subsurface_tree(struct client *client, struct wl_surface **surfs,
|
|||
|
||||
case 11:
|
||||
SUB_LINK(10, 2);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 10:
|
||||
SUB_LINK(9, 2);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 9:
|
||||
SUB_LINK(8, 6);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 8:
|
||||
SUB_LINK(7, 6);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 7:
|
||||
SUB_LINK(6, 2);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 6:
|
||||
SUB_LINK(5, 1);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 5:
|
||||
SUB_LINK(4, 3);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 4:
|
||||
SUB_LINK(3, 1);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 3:
|
||||
SUB_LINK(2, 0);
|
||||
/* fallthrough */
|
||||
FALLTHROUGH;
|
||||
case 2:
|
||||
SUB_LINK(1, 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue