diff options
-rw-r--r-- | meson.build | 43 | ||||
-rw-r--r-- | pango/break.c | 24 | ||||
-rw-r--r-- | pango/glyphstring.c | 8 | ||||
-rw-r--r-- | pango/pango-attributes.c | 18 | ||||
-rw-r--r-- | pango/pango-bidi-type.c | 1 | ||||
-rw-r--r-- | pango/pango-emoji.c | 3 | ||||
-rw-r--r-- | pango/pango-layout.c | 53 | ||||
-rw-r--r-- | pango/pango-markup.c | 3 | ||||
-rw-r--r-- | pango/pango-renderer.c | 8 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 2 | ||||
-rw-r--r-- | tests/test-font.c | 2 | ||||
-rw-r--r-- | tests/test-itemize.c | 2 | ||||
-rw-r--r-- | tests/test-shape.c | 5 | ||||
-rw-r--r-- | tests/testattributes.c | 1 | ||||
-rw-r--r-- | tests/testboundaries_ucd.c | 7 | ||||
-rw-r--r-- | tests/testmisc.c | 2 |
16 files changed, 124 insertions, 58 deletions
diff --git a/meson.build b/meson.build index 92d4a548..63f6e6ce 100644 --- a/meson.build +++ b/meson.build @@ -62,15 +62,50 @@ if cc.get_id() == 'msvc' test_c_only_flags = [] elif cc.get_id() == 'gcc' or cc.get_id() == 'clang' test_c_only_flags = [ + '-Wno-c++11-extensions', + '-Wno-missing-include-dirs', + '-Wno-typedef-redefinition', + '-Wduplicated-branches', + '-Wduplicated-cond', + '-Wformat=2', + '-Wformat-nonliteral', + '-Wformat-security', + '-Wignored-qualifiers', '-Wimplicit-function-declaration', - '-Wstrict-prototypes', - '-Wmissing-prototypes', + '-Wlogical-op', + '-Wmisleading-indentation', + '-Wmissing-format-attribute', + '-Wmissing-include-dirs', + '-Wmissing-noreturn', '-Wnested-externs', '-Wold-style-definition', - '-Wno-int-conversion', - '-Wno-discarded-qualifiers', + '-Wpointer-arith', + '-Wshadow', + '-Wstrict-prototypes', + '-Wswitch-default', + '-Wswitch-enum', + '-Wundef', + '-Wuninitialized', + '-Wunused', + '-Werror=address', + '-Werror=array-bounds', + '-Werror=empty-body', '-Werror=implicit', + '-Werror=implicit-fallthrough', + '-Werror=init-self', + '-Werror=int-to-pointer-cast', + '-Werror=main', + '-Werror=missing-braces', + '-Werror=missing-declarations', + '-Werror=missing-prototypes', + '-Werror=nonnull', '-Werror=pointer-to-int-cast', + '-Werror=redundant-decls', + '-Werror=return-type', + '-Werror=sequence-point', + '-Werror=trigraphs', + '-Werror=vla', + '-Werror=write-strings', ] test_cflags = test_c_only_flags + [ diff --git a/pango/break.c b/pango/break.c index b8f70855..b2586da2 100644 --- a/pango/break.c +++ b/pango/break.c @@ -356,7 +356,7 @@ pango_default_break (const gchar *text, makes_hangul_syllable = (prev_end == this_start) || (prev_end + 1 == this_start); } - switch (type) + switch ((int)type) { case G_UNICODE_SPACE_SEPARATOR: case G_UNICODE_LINE_SEPARATOR: @@ -387,7 +387,7 @@ pango_default_break (const gchar *text, /* Find the GraphemeBreakType of wc */ GB_type = GB_Other; - switch ((int) type) + switch ((int)type) { case G_UNICODE_FORMAT: if (G_UNLIKELY (wc == 0x200C)) @@ -471,8 +471,6 @@ pango_default_break (const gchar *text, { if (prev_GB_type == GB_RI_Odd) GB_type = GB_RI_Even; - else if (prev_GB_type == GB_RI_Even) - GB_type = GB_RI_Odd; else GB_type = GB_RI_Odd; break; @@ -484,6 +482,9 @@ pango_default_break (const gchar *text, if (wc >= 0x1F3FB && wc <= 0x1F3FF) GB_type = GB_Extend; break; + + default: + break; } /* Rule GB11 */ @@ -587,6 +588,8 @@ pango_default_break (const gchar *text, if (wc == 0x058A) WB_type = WB_ALetter; /* ALetter exceptions */ break; + default: + break; } if (WB_type == WB_Other) @@ -600,6 +603,8 @@ pango_default_break (const gchar *text, if (wc != 0x003A && wc != 0xFE13 && wc != 0x002E) WB_type = WB_MidNum; /* MidNum */ break; + default: + break; } if (WB_type == WB_Other) @@ -683,6 +688,8 @@ pango_default_break (const gchar *text, if (break_type != G_UNICODE_BREAK_COMPLEX_CONTEXT && script != PANGO_SCRIPT_HIRAGANA) WB_type = WB_ALetter; /* ALetter */ break; + default: + break; } if (WB_type == WB_Other) @@ -870,6 +877,9 @@ pango_default_break (const gchar *text, SB_type = SB_STerm; break; + + default: + break; } if (SB_type == SB_Other) @@ -1016,7 +1026,7 @@ pango_default_break (const gchar *text, /* Rule LB1: assign a line breaking class to each code point of the input. */ - switch (break_type) + switch ((int)break_type) { case G_UNICODE_BREAK_AMBIGUOUS: case G_UNICODE_BREAK_SURROGATE: @@ -1037,7 +1047,7 @@ pango_default_break (const gchar *text, break; default: - ; + break; } /* If it's not a grapheme boundary, it's not a line break either */ @@ -1080,8 +1090,6 @@ pango_default_break (const gchar *text, { if (prev_LB_type == LB_RI_Odd) LB_type = LB_RI_Even; - else if (prev_LB_type == LB_RI_Even) - LB_type = LB_RI_Odd; else LB_type = LB_RI_Odd; } diff --git a/pango/glyphstring.c b/pango/glyphstring.c index e937549a..89dec64e 100644 --- a/pango/glyphstring.c +++ b/pango/glyphstring.c @@ -391,7 +391,7 @@ pango_glyph_string_index_to_x (PangoGlyphString *glyphs, int cluster_chars = 0; int cluster_offset = 0; - char *p; + const char *p; g_return_if_fail (glyphs != NULL); g_return_if_fail (length >= 0); @@ -520,7 +520,7 @@ pango_glyph_string_x_to_index (PangoGlyphString *glyphs, int end_index = -1; int cluster_chars = 0; - char *p; + const char *p; gboolean found = FALSE; @@ -616,7 +616,7 @@ pango_glyph_string_x_to_index (PangoGlyphString *glyphs, { if (index) { - char *p = text + start_index; + const char *p = text + start_index; int i = 0; while (i + 1 <= cp) @@ -635,7 +635,7 @@ pango_glyph_string_x_to_index (PangoGlyphString *glyphs, { if (index) { - char *p = text + start_index; + const char *p = text + start_index; int i = 0; while (i + 1 < cp) diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 15814e38..28dc4105 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -1456,7 +1456,7 @@ pango_attr_text_transform_new (PangoTextTransform transform) PangoAttrInt * pango_attribute_as_int (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_STYLE: case PANGO_ATTR_WEIGHT: @@ -1500,7 +1500,7 @@ pango_attribute_as_int (PangoAttribute *attr) PangoAttrFloat * pango_attribute_as_float (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_SCALE: case PANGO_ATTR_LINE_HEIGHT: @@ -1525,7 +1525,7 @@ pango_attribute_as_float (PangoAttribute *attr) PangoAttrString * pango_attribute_as_string (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_FAMILY: return (PangoAttrString *)attr; @@ -1551,7 +1551,7 @@ pango_attribute_as_string (PangoAttribute *attr) PangoAttrSize * pango_attribute_as_size (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_SIZE: case PANGO_ATTR_ABSOLUTE_SIZE: @@ -1578,7 +1578,7 @@ pango_attribute_as_size (PangoAttribute *attr) PangoAttrColor * pango_attribute_as_color (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_FOREGROUND: case PANGO_ATTR_BACKGROUND: @@ -1608,7 +1608,7 @@ pango_attribute_as_color (PangoAttribute *attr) PangoAttrFontDesc * pango_attribute_as_font_desc (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_FONT_DESC: return (PangoAttrFontDesc *)attr; @@ -1634,7 +1634,7 @@ pango_attribute_as_font_desc (PangoAttribute *attr) PangoAttrFontFeatures * pango_attribute_as_font_features (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_FONT_FEATURES: return (PangoAttrFontFeatures *)attr; @@ -1660,7 +1660,7 @@ pango_attribute_as_font_features (PangoAttribute *attr) PangoAttrLanguage * pango_attribute_as_language (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_LANGUAGE: return (PangoAttrLanguage *)attr; @@ -1686,7 +1686,7 @@ pango_attribute_as_language (PangoAttribute *attr) PangoAttrShape * pango_attribute_as_shape (PangoAttribute *attr) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { case PANGO_ATTR_SHAPE: return (PangoAttrShape *)attr; diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c index 32858f7e..40123a60 100644 --- a/pango/pango-bidi-type.c +++ b/pango/pango-bidi-type.c @@ -79,6 +79,7 @@ pango_bidi_type_for_unichar (gunichar ch) case FRIBIDI_TYPE_RLI: return PANGO_BIDI_TYPE_RLI; case FRIBIDI_TYPE_FSI: return PANGO_BIDI_TYPE_FSI; case FRIBIDI_TYPE_PDI: return PANGO_BIDI_TYPE_PDI; + case _FRIBIDI_TYPE_SENTINEL: default: return PANGO_BIDI_TYPE_ON; } diff --git a/pango/pango-emoji.c b/pango/pango-emoji.c index 334970d6..e1f16dba 100644 --- a/pango/pango-emoji.c +++ b/pango/pango-emoji.c @@ -205,7 +205,10 @@ typedef gboolean bool; enum { false = FALSE, true = TRUE }; typedef unsigned char *emoji_text_iter_t; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" #include "emoji_presentation_scanner.c" +#pragma GCC diagnostic pop PangoEmojiIter * diff --git a/pango/pango-layout.c b/pango/pango-layout.c index bf7a97e7..9114e9a1 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -2641,7 +2641,8 @@ direction_simple (PangoDirection d) return -1; case PANGO_DIRECTION_NEUTRAL : return 0; - /* no default, compiler should complain if a new values is added */ + default: + break; } /* not reached */ return 0; @@ -3661,7 +3662,7 @@ get_need_hyphen (PangoItem *item, } } - switch (g_unichar_type (wc)) + switch ((int)g_unichar_type (wc)) { case G_UNICODE_SPACE_SEPARATOR: case G_UNICODE_LINE_SEPARATOR: @@ -4200,6 +4201,9 @@ process_line (PangoLayout *layout, * justification */ wrapped = TRUE; goto done; + + default: + break; } } @@ -4278,7 +4282,7 @@ static gboolean affects_itemization (PangoAttribute *attr, gpointer data) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { /* These affect font selection */ case PANGO_ATTR_LANGUAGE: @@ -4310,7 +4314,7 @@ static gboolean affects_break_or_shape (PangoAttribute *attr, gpointer data) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { /* Affects breaks */ case PANGO_ATTR_ALLOW_BREAKS: @@ -5322,30 +5326,27 @@ pango_layout_line_get_extents_and_height (PangoLayoutLine *line, switch (private->cache_status) { case CACHED: - { - if (ink_rect) - *ink_rect = private->ink_rect; - if (logical_rect) - *logical_rect = private->logical_rect; - if (height) - *height = private->height; - return; - } + if (ink_rect) + *ink_rect = private->ink_rect; + if (logical_rect) + *logical_rect = private->logical_rect; + if (height) + *height = private->height; + return; + case NOT_CACHED: - { - caching = TRUE; - if (!ink_rect) - ink_rect = &private->ink_rect; - if (!logical_rect) - logical_rect = &private->logical_rect; - if (!height) - height = &private->height; - break; - } + caching = TRUE; + if (!ink_rect) + ink_rect = &private->ink_rect; + if (!logical_rect) + logical_rect = &private->logical_rect; + if (!height) + height = &private->height; + break; + case LEAKED: - { - break; - } + default: + break; } if (ink_rect) diff --git a/pango/pango-markup.c b/pango/pango-markup.c index f82aacef..22064103 100644 --- a/pango/pango-markup.c +++ b/pango/pango-markup.c @@ -378,6 +378,9 @@ start_element_handler (GMarkupParseContext *context, if (strcmp ("u", element_name) == 0) parse_func = u_parse_func; break; + + default: + break; } if (parse_func == NULL) diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c index 21d09573..c91cb6ee 100644 --- a/pango/pango-renderer.c +++ b/pango/pango-renderer.c @@ -250,6 +250,8 @@ draw_underline (PangoRenderer *renderer, rect->width, 3 * rect->height); break; + default: + break; } } @@ -274,6 +276,8 @@ draw_overline (PangoRenderer *renderer, rect->width, rect->height); break; + default: + break; } } @@ -388,6 +392,8 @@ add_underline (PangoRenderer *renderer, current_rect->height = new_rect.height; } break; + default: + break; } if (renderer->underline == state->underline && @@ -439,6 +445,8 @@ add_overline (PangoRenderer *renderer, current_rect->height = new_rect.height; } break; + default: + break; } if (renderer->priv->overline == state->overline && diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 9c008411..dcc2c08d 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -1649,6 +1649,8 @@ is_alias_family (const char *family_name) return (g_ascii_strcasecmp (family_name, "sans") == 0 || g_ascii_strcasecmp (family_name, "serif") == 0 || g_ascii_strcasecmp (family_name, "system-ui") == 0); + default: + return FALSE; } return FALSE; diff --git a/tests/test-font.c b/tests/test-font.c index f291cec8..1d3290c7 100644 --- a/tests/test-font.c +++ b/tests/test-font.c @@ -160,7 +160,7 @@ test_metrics (void) static void test_extents (void) { - char *str = "Composer"; + const char *str = "Composer"; GList *items; PangoItem *item; PangoGlyphString *glyphs; diff --git a/tests/test-itemize.c b/tests/test-itemize.c index 926eb3ae..105b453d 100644 --- a/tests/test-itemize.c +++ b/tests/test-itemize.c @@ -55,7 +55,7 @@ static gboolean affects_itemization (PangoAttribute *attr, gpointer data) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { /* These affect font selection */ case PANGO_ATTR_LANGUAGE: diff --git a/tests/test-shape.c b/tests/test-shape.c index a04291e4..152acd26 100644 --- a/tests/test-shape.c +++ b/tests/test-shape.c @@ -57,7 +57,7 @@ static gboolean affects_itemization (PangoAttribute *attr, gpointer data) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { /* These affect font selection */ case PANGO_ATTR_LANGUAGE: @@ -89,11 +89,12 @@ static gboolean affects_break_or_shape (PangoAttribute *attr, gpointer data) { - switch (attr->klass->type) + switch ((int)attr->klass->type) { /* Affects breaks */ case PANGO_ATTR_ALLOW_BREAKS: /* Affects shaping */ + case PANGO_ATTR_INSERT_HYPHENS: case PANGO_ATTR_FONT_FEATURES: case PANGO_ATTR_SHOW: return TRUE; diff --git a/tests/testattributes.c b/tests/testattributes.c index 13cf6810..f950a204 100644 --- a/tests/testattributes.c +++ b/tests/testattributes.c @@ -157,6 +157,7 @@ test_binding (PangoAttribute *attr) case FONT_FEATURES: g_assert_nonnull (pango_attribute_as_font_features (attr)); break; + case INVALID: default: g_assert_not_reached (); } diff --git a/tests/testboundaries_ucd.c b/tests/testboundaries_ucd.c index 0cd301f7..d9f08a57 100644 --- a/tests/testboundaries_ucd.c +++ b/tests/testboundaries_ucd.c @@ -263,6 +263,9 @@ do_test (const gchar *filename, case G_IO_STATUS_NORMAL: line[terminator_pos] = '\0'; break; + + default: + break; } g_test_message ("Parsing line: %s", line); @@ -276,7 +279,7 @@ do_test (const gchar *filename, if (! attrs_equal (attrs, expected_attrs, num_attrs, bits)) { gchar *str = make_test_string (string, attrs, bits); - gchar *comments = strchr (line, '#'); + char *comments = strchr (line, '#'); if (comments) /* don't print the # comment in the error message. print it separately */ { *comments = '\0'; @@ -284,7 +287,7 @@ do_test (const gchar *filename, } else { - comments = ""; + comments = (char *)""; } g_test_message ("%s: line %d failed", filename, i); diff --git a/tests/testmisc.c b/tests/testmisc.c index da24388b..60694134 100644 --- a/tests/testmisc.c +++ b/tests/testmisc.c @@ -314,7 +314,7 @@ test_get_cursor_crash (void) PangoLayout *layout; int i; - char *string = "foo\n\rbar\r\nbaz\n\nqux\n\n.."; + const char *string = "foo\n\rbar\r\nbaz\n\nqux\n\n.."; context = pango_font_map_create_context (pango_cairo_font_map_get_default ()); |