mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-24 20:40:11 +01:00
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
5 changed files with 21 additions and 14 deletions
|
|
@ -1711,7 +1711,7 @@ handle_non_csi_escape(struct terminal *terminal, char code)
|
||||||
break;
|
break;
|
||||||
case 'E': /* NEL - Newline */
|
case 'E': /* NEL - Newline */
|
||||||
terminal->column = 0;
|
terminal->column = 0;
|
||||||
// fallthrough
|
FALLTHROUGH;
|
||||||
case 'D': /* IND - Linefeed */
|
case 'D': /* IND - Linefeed */
|
||||||
terminal->row += 1;
|
terminal->row += 1;
|
||||||
if (terminal->row > terminal->margin_bottom) {
|
if (terminal->row > terminal->margin_bottom) {
|
||||||
|
|
@ -1893,7 +1893,7 @@ handle_special_char(struct terminal *terminal, char c)
|
||||||
if (terminal->mode & MODE_LF_NEWLINE) {
|
if (terminal->mode & MODE_LF_NEWLINE) {
|
||||||
terminal->column = 0;
|
terminal->column = 0;
|
||||||
}
|
}
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case '\v':
|
case '\v':
|
||||||
case '\f':
|
case '\f':
|
||||||
terminal->row++;
|
terminal->row++;
|
||||||
|
|
|
||||||
|
|
@ -398,13 +398,13 @@ get_output_work_area(struct desktop_shell *shell,
|
||||||
switch (shell->panel_position) {
|
switch (shell->panel_position) {
|
||||||
case WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP:
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP:
|
||||||
area->y += sh_output->panel_surface->height;
|
area->y += sh_output->panel_surface->height;
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM:
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM:
|
||||||
area->height -= sh_output->panel_surface->height;
|
area->height -= sh_output->panel_surface->height;
|
||||||
break;
|
break;
|
||||||
case WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT:
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT:
|
||||||
area->x += sh_output->panel_surface->width;
|
area->x += sh_output->panel_surface->width;
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT:
|
case WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT:
|
||||||
area->width -= sh_output->panel_surface->width;
|
area->width -= sh_output->panel_surface->width;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -2941,8 +2941,8 @@ wayland_backend_create(struct weston_compositor *compositor,
|
||||||
if (renderer != WESTON_RENDERER_PIXMAN)
|
if (renderer != WESTON_RENDERER_PIXMAN)
|
||||||
break;
|
break;
|
||||||
weston_log_continue("; falling back to Pixman.\n");
|
weston_log_continue("; falling back to Pixman.\n");
|
||||||
|
FALLTHROUGH;
|
||||||
}
|
}
|
||||||
/* fallthrough */
|
|
||||||
case WESTON_RENDERER_PIXMAN:
|
case WESTON_RENDERER_PIXMAN:
|
||||||
if (weston_compositor_init_renderer(compositor,
|
if (weston_compositor_init_renderer(compositor,
|
||||||
WESTON_RENDERER_PIXMAN,
|
WESTON_RENDERER_PIXMAN,
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,13 @@ do { \
|
||||||
#define unreachable(str) assert(!str)
|
#define unreachable(str) assert(!str)
|
||||||
#endif
|
#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.
|
* 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:
|
case 11:
|
||||||
SUB_LINK(10, 2);
|
SUB_LINK(10, 2);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 10:
|
case 10:
|
||||||
SUB_LINK(9, 2);
|
SUB_LINK(9, 2);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 9:
|
case 9:
|
||||||
SUB_LINK(8, 6);
|
SUB_LINK(8, 6);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 8:
|
case 8:
|
||||||
SUB_LINK(7, 6);
|
SUB_LINK(7, 6);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 7:
|
case 7:
|
||||||
SUB_LINK(6, 2);
|
SUB_LINK(6, 2);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 6:
|
case 6:
|
||||||
SUB_LINK(5, 1);
|
SUB_LINK(5, 1);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 5:
|
case 5:
|
||||||
SUB_LINK(4, 3);
|
SUB_LINK(4, 3);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 4:
|
case 4:
|
||||||
SUB_LINK(3, 1);
|
SUB_LINK(3, 1);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 3:
|
case 3:
|
||||||
SUB_LINK(2, 0);
|
SUB_LINK(2, 0);
|
||||||
/* fallthrough */
|
FALLTHROUGH;
|
||||||
case 2:
|
case 2:
|
||||||
SUB_LINK(1, 0);
|
SUB_LINK(1, 0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue