From b5f4d905f958ebfce9be2ab8daa5d42b62f7277d Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 5 Mar 2024 08:29:15 +0000 Subject: use attributes to indicate switch fall through instead of comments --- content/handlers/css/hints.c | 10 +++--- content/handlers/html/box_inspect.c | 3 +- content/handlers/html/dom_event.c | 3 ++ content/handlers/html/interaction.c | 6 ++-- content/handlers/html/layout_flex.c | 4 +-- content/handlers/html/redraw_border.c | 9 +++--- content/handlers/html/script.c | 1 + content/handlers/html/table.c | 49 +++++++++++++++-------------- content/handlers/image/webp.c | 2 +- content/handlers/javascript/duktape/dukky.c | 2 +- 10 files changed, 47 insertions(+), 42 deletions(-) (limited to 'content/handlers') diff --git a/content/handlers/css/hints.c b/content/handlers/css/hints.c index 145cf8185..0f246a64c 100644 --- a/content/handlers/css/hints.c +++ b/content/handlers/css/hints.c @@ -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; diff --git a/content/handlers/html/box_inspect.c b/content/handlers/html/box_inspect.c index 181f58cf8..6591b6446 100644 --- a/content/handlers/html/box_inspect.c +++ b/content/handlers/html/box_inspect.c @@ -25,6 +25,7 @@ #include #include +#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 { diff --git a/content/handlers/html/dom_event.c b/content/handlers/html/dom_event.c index d389a21b4..d42882515 100644 --- a/content/handlers/html/dom_event.c +++ b/content/handlers/html/dom_event.c @@ -25,6 +25,7 @@ #include #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; } diff --git a/content/handlers/html/interaction.c b/content/handlers/html/interaction.c index 9e359c98f..0a843e026 100644 --- a/content/handlers/html/interaction.c +++ b/content/handlers/html/interaction.c @@ -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; diff --git a/content/handlers/html/layout_flex.c b/content/handlers/html/layout_flex.c index 61adcaa6c..bde3c5bd1 100644 --- a/content/handlers/html/layout_flex.c +++ b/content/handlers/html/layout_flex.c @@ -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 + diff --git a/content/handlers/html/redraw_border.c b/content/handlers/html/redraw_border.c index 39ed432cd..3a1f6f308 100644 --- a/content/handlers/html/redraw_border.c +++ b/content/handlers/html/redraw_border.c @@ -25,6 +25,7 @@ #include #include +#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) { diff --git a/content/handlers/html/script.c b/content/handlers/html/script.c index 962386d68..554fc4f70 100644 --- a/content/handlers/html/script.c +++ b/content/handlers/html/script.c @@ -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; diff --git a/content/handlers/html/table.c b/content/handlers/html/table.c index 4ffcceab9..f8762e862 100644 --- a/content/handlers/html/table.c +++ b/content/handlers/html/table.c @@ -26,6 +26,7 @@ #include #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; } diff --git a/content/handlers/image/webp.c b/content/handlers/image/webp.c index da13316bc..c04c0efd2 100644 --- a/content/handlers/image/webp.c +++ b/content/handlers/image/webp.c @@ -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); diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c index c0a2749a9..a780b0067 100644 --- a/content/handlers/javascript/duktape/dukky.c +++ b/content/handlers/javascript/duktape/dukky.c @@ -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; -- cgit v1.2.3