[Helper] Add a rofi_fallthrough macro to tell compiler fallthrough is intentional
This commit is contained in:
@@ -455,6 +455,19 @@ void helper_select_next_matching_mode(void);
|
||||
* Switch to the previous matching method.
|
||||
*/
|
||||
void helper_select_previous_matching_mode(void);
|
||||
|
||||
/**
|
||||
* Method to indicate fallthrough. This will help
|
||||
* gcc/llvm warning/static code analysis.
|
||||
*/
|
||||
#if __has_attribute(__fallthrough__)
|
||||
#define rofi_fallthrough __attribute__((__fallthrough__))
|
||||
#else
|
||||
#define rofi_fallthrough \
|
||||
do { \
|
||||
} while (0) /* fallthrough */
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
/**@} */
|
||||
|
@@ -396,30 +396,30 @@ static void rofi_view_calculate_window_position(RofiViewState *state) {
|
||||
switch (location) {
|
||||
case WL_NORTH_WEST:
|
||||
state->x = CacheState.mon.x;
|
||||
/* FALLTHRU */
|
||||
rofi_fallthrough;
|
||||
case WL_NORTH:
|
||||
state->y = CacheState.mon.y;
|
||||
break;
|
||||
case WL_NORTH_EAST:
|
||||
state->y = CacheState.mon.y;
|
||||
/* FALLTHRU */
|
||||
rofi_fallthrough;
|
||||
case WL_EAST:
|
||||
state->x = CacheState.mon.x + CacheState.mon.w;
|
||||
break;
|
||||
case WL_SOUTH_EAST:
|
||||
state->x = CacheState.mon.x + CacheState.mon.w;
|
||||
/* FALLTHRU */
|
||||
rofi_fallthrough;
|
||||
case WL_SOUTH:
|
||||
state->y = CacheState.mon.y + CacheState.mon.h;
|
||||
break;
|
||||
case WL_SOUTH_WEST:
|
||||
state->y = CacheState.mon.y + CacheState.mon.h;
|
||||
/* FALLTHRU */
|
||||
rofi_fallthrough;
|
||||
case WL_WEST:
|
||||
state->x = CacheState.mon.x;
|
||||
break;
|
||||
case WL_CENTER:;
|
||||
/* FALLTHRU */
|
||||
rofi_fallthrough;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2057,10 +2057,10 @@ void rofi_view_trigger_action(RofiViewState *state, BindingsScope scope,
|
||||
return;
|
||||
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END:
|
||||
target = NULL;
|
||||
/* FALLTHRU */
|
||||
rofi_fallthrough;
|
||||
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN:
|
||||
state->mouse.motion_target = target;
|
||||
/* FALLTHRU */
|
||||
rofi_fallthrough;
|
||||
case WIDGET_TRIGGER_ACTION_RESULT_HANDLED:
|
||||
return;
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <widgets/textbox.h>
|
||||
#include <widgets/widget.h>
|
||||
|
||||
#include "helper.h"
|
||||
#include "settings.h"
|
||||
#include "theme.h"
|
||||
#include "view.h"
|
||||
@@ -120,7 +121,7 @@ struct _listview {
|
||||
xcb_timestamp_t last_click;
|
||||
listview_mouse_activated_cb mouse_activated;
|
||||
void *mouse_activated_data;
|
||||
|
||||
|
||||
listview_page_changed_cb page_callback;
|
||||
|
||||
char *listview_name;
|
||||
@@ -757,7 +758,7 @@ static WidgetTriggerActionResult listview_element_trigger_action(
|
||||
break;
|
||||
case ACCEPT_HOVERED_CUSTOM:
|
||||
custom = TRUE;
|
||||
/* FALLTHRU */
|
||||
rofi_fallthrough;
|
||||
case ACCEPT_HOVERED_ENTRY:
|
||||
listview_set_selected(lv, lv->last_offset + i);
|
||||
lv->mouse_activated(lv, custom, lv->mouse_activated_data);
|
||||
|
@@ -1172,13 +1172,13 @@ static gboolean x11_button_to_nk_bindings_scroll(guint32 x11_button,
|
||||
switch (x11_button) {
|
||||
case 4:
|
||||
*steps = -1;
|
||||
/* fallthrough */
|
||||
rofi_fallthrough;
|
||||
case 5:
|
||||
*axis = NK_BINDINGS_SCROLL_AXIS_VERTICAL;
|
||||
break;
|
||||
case 6:
|
||||
*steps = -1;
|
||||
/* fallthrough */
|
||||
rofi_fallthrough;
|
||||
case 7:
|
||||
*axis = NK_BINDINGS_SCROLL_AXIS_HORIZONTAL;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user