mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-21 22:11:22 +03:00
use attributes to indicate switch fall through instead of comments
This commit is contained in:
parent
199f86dcf1
commit
b5f4d905f9
8
Makefile
8
Makefile
@ -90,13 +90,13 @@ ifeq ($(call cc_ver_ge,4,6),1)
|
||||
endif
|
||||
|
||||
ifeq ($(TOOLCHAIN),gcc)
|
||||
# Implicit fallthrough warnings suppressed by comment
|
||||
# Implicit fallthrough warnings
|
||||
ifeq ($(call cc_ver_ge,7,1),1)
|
||||
COMMON_WARNFLAGS += -Wimplicit-fallthrough=3
|
||||
COMMON_WARNFLAGS += -Wimplicit-fallthrough=5
|
||||
endif
|
||||
else
|
||||
# clang uses [[clang::fallthrough]] to annotate fallthrough instead of comments
|
||||
COMMON_WARNFLAGS += -Wno-implicit-fallthrough
|
||||
# non gcc has different warning syntax
|
||||
COMMON_WARNFLAGS += -Wimplicit-fallthrough
|
||||
endif
|
||||
|
||||
# deal with chaging warning flags for different platforms
|
||||
|
@ -1650,22 +1650,22 @@ css_error node_presentational_hint(void *pw, void *node,
|
||||
css_hint_width(pw, node);
|
||||
css_hint_table_cell_border_padding(pw, node);
|
||||
css_hint_white_space_nowrap(pw, node);
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case DOM_HTML_ELEMENT_TYPE_TR:
|
||||
css_hint_height(pw, node);
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case DOM_HTML_ELEMENT_TYPE_THEAD:
|
||||
case DOM_HTML_ELEMENT_TYPE_TBODY:
|
||||
case DOM_HTML_ELEMENT_TYPE_TFOOT:
|
||||
css_hint_text_align_special(pw, node);
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case DOM_HTML_ELEMENT_TYPE_COL:
|
||||
css_hint_vertical_align_table_cells(pw, node);
|
||||
break;
|
||||
case DOM_HTML_ELEMENT_TYPE_APPLET:
|
||||
case DOM_HTML_ELEMENT_TYPE_IMG:
|
||||
css_hint_margin_hspace_vspace(pw, node);
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case DOM_HTML_ELEMENT_TYPE_EMBED:
|
||||
case DOM_HTML_ELEMENT_TYPE_IFRAME:
|
||||
case DOM_HTML_ELEMENT_TYPE_OBJECT:
|
||||
@ -1688,7 +1688,7 @@ css_error node_presentational_hint(void *pw, void *node,
|
||||
break;
|
||||
case DOM_HTML_ELEMENT_TYPE_CAPTION:
|
||||
css_hint_caption_side(pw, node);
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case DOM_HTML_ELEMENT_TYPE_DIV:
|
||||
css_hint_text_align_special(pw, node);
|
||||
break;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stdio.h>
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "utils/nsurl.h"
|
||||
#include "utils/errors.h"
|
||||
#include "netsurf/types.h"
|
||||
@ -212,7 +213,7 @@ box_move_xy(struct box *b, enum box_walk_dir dir, int *x, int *y)
|
||||
rb = b;
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
|
||||
case BOX_WALK_NEXT_SIBLING:
|
||||
do {
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/log.h"
|
||||
@ -691,6 +692,7 @@ dom_default_action_DOMNodeInsertedIntoDocument_cb(struct dom_event *evt,
|
||||
switch (tag_type) {
|
||||
case DOM_HTML_ELEMENT_TYPE_SCRIPT:
|
||||
dom_SCRIPT_showed_up(htmlc, (dom_html_script_element *) node);
|
||||
fallthrough;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -740,6 +742,7 @@ dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw)
|
||||
case DOM_HTML_ELEMENT_TYPE_TEXTAREA:
|
||||
case DOM_HTML_ELEMENT_TYPE_INPUT:
|
||||
html_texty_element_update(htmlc, (dom_node *)node);
|
||||
fallthrough;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -899,7 +899,7 @@ gadget_mouse_action(html_content *html,
|
||||
}
|
||||
free(oldcoords);
|
||||
}
|
||||
/* Fall through */
|
||||
fallthrough;
|
||||
|
||||
case GADGET_SUBMIT:
|
||||
if (mas->gadget.control->form) {
|
||||
@ -1669,7 +1669,7 @@ void html_set_drag_type(html_content *html, html_drag_type drag_type,
|
||||
|
||||
case HTML_DRAG_SELECTION:
|
||||
assert(drag_owner.no_owner == true);
|
||||
/* Fall through */
|
||||
fallthrough;
|
||||
case HTML_DRAG_TEXTAREA_SELECTION:
|
||||
case HTML_DRAG_CONTENT_SELECTION:
|
||||
msg_data.drag.type = CONTENT_DRAG_SELECTION;
|
||||
@ -1800,7 +1800,7 @@ void html_set_selection(html_content *html, html_selection_type selection_type,
|
||||
break;
|
||||
case HTML_SELECTION_SELF:
|
||||
assert(selection_owner.none == false);
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case HTML_SELECTION_TEXTAREA:
|
||||
case HTML_SELECTION_CONTENT:
|
||||
msg_data.selection.selection = true;
|
||||
|
@ -960,7 +960,6 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
|
||||
|
||||
switch (lh__box_align_self(ctx->flex, b)) {
|
||||
default:
|
||||
/* Fall through. */
|
||||
case CSS_ALIGN_SELF_STRETCH:
|
||||
if (lh__box_size_cross_is_auto(ctx->horizontal, b)) {
|
||||
*box_size_cross += cross_free_space;
|
||||
@ -970,7 +969,7 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Fall through. */
|
||||
fallthrough;
|
||||
case CSS_ALIGN_SELF_FLEX_START:
|
||||
*box_pos_cross = ctx->flex->padding[cross_start] +
|
||||
line->pos +
|
||||
@ -986,7 +985,6 @@ static void layout_flex__place_line_items_cross(struct flex_ctx *ctx,
|
||||
break;
|
||||
|
||||
case CSS_ALIGN_SELF_BASELINE:
|
||||
/* Fall through. */
|
||||
case CSS_ALIGN_SELF_CENTER:
|
||||
*box_pos_cross = ctx->flex->padding[cross_start] +
|
||||
line->pos + cross_free_space / 2 +
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
#include "netsurf/plotters.h"
|
||||
#include "netsurf/css.h"
|
||||
@ -121,7 +122,7 @@ html_redraw_border_plot(const int side,
|
||||
switch (style) {
|
||||
case CSS_BORDER_STYLE_DOTTED:
|
||||
plot_style_bdr.stroke_type = PLOT_OP_TYPE_DOT;
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case CSS_BORDER_STYLE_DASHED:
|
||||
rect.x0 = (p[0] + p[2]) / 2;
|
||||
rect.y0 = (p[1] + p[3]) / 2;
|
||||
@ -131,7 +132,7 @@ html_redraw_border_plot(const int side,
|
||||
break;
|
||||
|
||||
case CSS_BORDER_STYLE_SOLID:
|
||||
/* fall through to default */
|
||||
/* solid is the default */
|
||||
default:
|
||||
if (rectangular || thickness == 1) {
|
||||
|
||||
@ -190,7 +191,7 @@ html_redraw_border_plot(const int side,
|
||||
|
||||
case CSS_BORDER_STYLE_GROOVE:
|
||||
light = 3 - light;
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case CSS_BORDER_STYLE_RIDGE:
|
||||
/* choose correct colours for each part of the border line */
|
||||
if (light <= 1) {
|
||||
@ -300,7 +301,7 @@ html_redraw_border_plot(const int side,
|
||||
|
||||
case CSS_BORDER_STYLE_INSET:
|
||||
light = (light + 2) % 4;
|
||||
/* fall through */
|
||||
fallthrough;
|
||||
case CSS_BORDER_STYLE_OUTSET:
|
||||
/* choose correct colours for each part of the border line */
|
||||
switch (light) {
|
||||
|
@ -495,6 +495,7 @@ exec_src_script(html_content *c,
|
||||
switch (script_type) {
|
||||
case HTML_SCRIPT_SYNC:
|
||||
ret = DOM_HUBBUB_HUBBUB_ERR | HUBBUB_PAUSED;
|
||||
break;
|
||||
|
||||
case HTML_SCRIPT_ASYNC:
|
||||
break;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <dom/dom.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/talloc.h"
|
||||
#include "css/utils.h"
|
||||
|
||||
@ -93,27 +94,27 @@ table_border_is_more_eyecatching(const css_unit_ctx *unit_len_ctx,
|
||||
|
||||
/* 3b -- sort by style */
|
||||
switch (a->style) {
|
||||
case CSS_BORDER_STYLE_DOUBLE: impact++; /* Fall through */
|
||||
case CSS_BORDER_STYLE_SOLID: impact++; /* Fall through */
|
||||
case CSS_BORDER_STYLE_DASHED: impact++; /* Fall through */
|
||||
case CSS_BORDER_STYLE_DOTTED: impact++; /* Fall through */
|
||||
case CSS_BORDER_STYLE_RIDGE: impact++; /* Fall through */
|
||||
case CSS_BORDER_STYLE_OUTSET: impact++; /* Fall through */
|
||||
case CSS_BORDER_STYLE_GROOVE: impact++; /* Fall through */
|
||||
case CSS_BORDER_STYLE_INSET: impact++; /* Fall through */
|
||||
case CSS_BORDER_STYLE_DOUBLE: impact++; fallthrough;
|
||||
case CSS_BORDER_STYLE_SOLID: impact++; fallthrough;
|
||||
case CSS_BORDER_STYLE_DASHED: impact++; fallthrough;
|
||||
case CSS_BORDER_STYLE_DOTTED: impact++; fallthrough;
|
||||
case CSS_BORDER_STYLE_RIDGE: impact++; fallthrough;
|
||||
case CSS_BORDER_STYLE_OUTSET: impact++; fallthrough;
|
||||
case CSS_BORDER_STYLE_GROOVE: impact++; fallthrough;
|
||||
case CSS_BORDER_STYLE_INSET: impact++; fallthrough;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (b->style) {
|
||||
case CSS_BORDER_STYLE_DOUBLE: impact--; /* Fall through */
|
||||
case CSS_BORDER_STYLE_SOLID: impact--; /* Fall through */
|
||||
case CSS_BORDER_STYLE_DASHED: impact--; /* Fall through */
|
||||
case CSS_BORDER_STYLE_DOTTED: impact--; /* Fall through */
|
||||
case CSS_BORDER_STYLE_RIDGE: impact--; /* Fall through */
|
||||
case CSS_BORDER_STYLE_OUTSET: impact--; /* Fall through */
|
||||
case CSS_BORDER_STYLE_GROOVE: impact--; /* Fall through */
|
||||
case CSS_BORDER_STYLE_INSET: impact--; /* Fall through */
|
||||
case CSS_BORDER_STYLE_DOUBLE: impact--; fallthrough;
|
||||
case CSS_BORDER_STYLE_SOLID: impact--; fallthrough;
|
||||
case CSS_BORDER_STYLE_DASHED: impact--; fallthrough;
|
||||
case CSS_BORDER_STYLE_DOTTED: impact--; fallthrough;
|
||||
case CSS_BORDER_STYLE_RIDGE: impact--; fallthrough;
|
||||
case CSS_BORDER_STYLE_OUTSET: impact--; fallthrough;
|
||||
case CSS_BORDER_STYLE_GROOVE: impact--; fallthrough;
|
||||
case CSS_BORDER_STYLE_INSET: impact--; fallthrough;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -128,20 +129,20 @@ table_border_is_more_eyecatching(const css_unit_ctx *unit_len_ctx,
|
||||
|
||||
/** \todo COL/COL_GROUP */
|
||||
switch (a_src) {
|
||||
case BOX_TABLE_CELL: impact++; /* Fall through */
|
||||
case BOX_TABLE_ROW: impact++; /* Fall through */
|
||||
case BOX_TABLE_ROW_GROUP: impact++; /* Fall through */
|
||||
case BOX_TABLE: impact++; /* Fall through */
|
||||
case BOX_TABLE_CELL: impact++; fallthrough;
|
||||
case BOX_TABLE_ROW: impact++; fallthrough;
|
||||
case BOX_TABLE_ROW_GROUP: impact++; fallthrough;
|
||||
case BOX_TABLE: impact++; fallthrough;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/** \todo COL/COL_GROUP */
|
||||
switch (b_src) {
|
||||
case BOX_TABLE_CELL: impact--; /* Fall through */
|
||||
case BOX_TABLE_ROW: impact--; /* Fall through */
|
||||
case BOX_TABLE_ROW_GROUP: impact--; /* Fall through */
|
||||
case BOX_TABLE: impact--; /* Fall through */
|
||||
case BOX_TABLE_CELL: impact--; fallthrough;
|
||||
case BOX_TABLE_ROW: impact--; fallthrough;
|
||||
case BOX_TABLE_ROW_GROUP: impact--; fallthrough;
|
||||
case BOX_TABLE: impact--; fallthrough;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ webp_cache_convert(struct content *c)
|
||||
default:
|
||||
/* WebP has no ABGR function, fall back to default. */
|
||||
webp_fmt.layout = BITMAP_LAYOUT_R8G8B8A8;
|
||||
/* Fall through. */
|
||||
fallthrough;
|
||||
case BITMAP_LAYOUT_R8G8B8A8:
|
||||
decoded = WebPDecodeRGBAInto(source_data, source_size, pixels,
|
||||
rowstride * webpfeatures.height, rowstride);
|
||||
|
@ -385,7 +385,7 @@ static void dukky_html_element_class_from_tag_type(dom_html_element_type type,
|
||||
break;
|
||||
case DOM_HTML_ELEMENT_TYPE__COUNT:
|
||||
assert(type != DOM_HTML_ELEMENT_TYPE__COUNT);
|
||||
/* fallthrough */
|
||||
fallthrough;
|
||||
case DOM_HTML_ELEMENT_TYPE__UNKNOWN:
|
||||
SET_HTML_CLASS(UNKNOWN)
|
||||
break;
|
||||
|
@ -432,7 +432,7 @@ static gboolean nsgtk_download_update(gboolean force_update)
|
||||
switch (dl->status) {
|
||||
case NSGTK_DOWNLOAD_WORKING:
|
||||
pulse_mode = TRUE;
|
||||
/* Fall through */
|
||||
fallthrough;
|
||||
|
||||
case NSGTK_DOWNLOAD_NONE:
|
||||
dl->speed = dl->size_downloaded /
|
||||
@ -449,12 +449,13 @@ static gboolean nsgtk_download_update(gboolean force_update)
|
||||
|
||||
dl_ctx.num_active++;
|
||||
update = TRUE;
|
||||
/* Fall through */
|
||||
fallthrough;
|
||||
|
||||
case NSGTK_DOWNLOAD_COMPLETE:
|
||||
downloaded += dl->size_downloaded;
|
||||
total += dl->size_total;
|
||||
dls++;
|
||||
fallthrough;
|
||||
|
||||
default:
|
||||
;//Do nothing
|
||||
|
@ -270,6 +270,8 @@ nserror nsgtk_search_restyle(struct gtk_search *search)
|
||||
case 4: /* Text icons only */
|
||||
gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
|
||||
GTK_TOOLBAR_TEXT);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ nsws_download_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
case IDOK:
|
||||
if (download1->downloaded != download1->size)
|
||||
return TRUE;
|
||||
/* Fall through */
|
||||
fallthrough;
|
||||
|
||||
case IDCANCEL:
|
||||
nsws_download_clear_data(download1);
|
||||
|
@ -432,7 +432,7 @@ nsws_window_urlbar_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
NSLOG(netsurf, INFO, "Destroyed font object");
|
||||
DeleteObject(hFont);
|
||||
}
|
||||
/* Fall through */
|
||||
fallthrough;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
/* remove properties if window is being destroyed */
|
||||
|
@ -89,4 +89,31 @@
|
||||
*/
|
||||
bool is_dir(const char *path);
|
||||
|
||||
/**
|
||||
* switch fall through
|
||||
*/
|
||||
#if defined __cplusplus && defined __has_cpp_attribute
|
||||
#if __has_cpp_attribute(fallthrough) && __cplusplus >= __has_cpp_attribute(fallthrough)
|
||||
#define fallthrough [[fallthrough]]
|
||||
#elif __has_cpp_attribute(gnu::fallthrough) && __STDC_VERSION__ >= __has_cpp_attribute(gnu::fallthrough)
|
||||
#define fallthrough [[gnu::fallthrough]]
|
||||
#elif __has_cpp_attribute(clang::fallthrough) && __STDC_VERSION__ >= __has_cpp_attribute(clang::fallthrough)
|
||||
#define fallthrough [[clang::fallthrough]]
|
||||
#endif
|
||||
#elif defined __STDC_VERSION__ && defined __has_c_attribute
|
||||
#if __has_c_attribute(fallthrough) && __STDC_VERSION__ >= __has_c_attribute(fallthrough)
|
||||
#define fallthrough [[fallthrough]]
|
||||
#endif
|
||||
#endif
|
||||
#if !defined fallthrough && defined __has_attribute
|
||||
#if __has_attribute(__fallthrough__)
|
||||
#define fallthrough __attribute__((__fallthrough__))
|
||||
#endif
|
||||
#endif
|
||||
#if !defined fallthrough
|
||||
/* early gcc and clang have no implicit fallthrough warning */
|
||||
#define fallthrough do {} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user