From b900f78088abb87ebec263474b2802593afa0264 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 18 Jan 2019 10:08:23 -0500 Subject: [PATCH] [pragma] More cast-align whitelist --- src/hb-font.cc | 20 +++++++++++++++----- src/hb-ft.cc | 6 ++++++ src/hb-ot-cmap-table.hh | 3 +++ src/hb-ot-font.cc | 6 ++++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/hb-font.cc b/src/hb-font.cc index 0ab04f11c..afd20dfaa 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -51,9 +51,6 @@ * hb_font_funcs_t */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-align" // API taking in *_stride needs it - static hb_bool_t hb_font_get_font_h_extents_nil (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED, @@ -144,8 +141,11 @@ hb_font_get_nominal_glyphs_default (hb_font_t *font, if (!font->get_nominal_glyph (*first_unicode, first_glyph)) return i; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_unicode = &StructAtOffset (first_unicode, unicode_stride); first_glyph = &StructAtOffset (first_glyph, glyph_stride); +#pragma GCC diagnostic pop } return count; } @@ -241,8 +241,11 @@ hb_font_get_glyph_h_advances_default (hb_font_t* font, for (unsigned int i = 0; i < count; i++) { *first_advance = font->get_glyph_h_advance (*first_glyph); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_glyph = &StructAtOffset (first_glyph, glyph_stride); first_advance = &StructAtOffset (first_advance, advance_stride); +#pragma GCC diagnostic pop } return; } @@ -253,7 +256,10 @@ hb_font_get_glyph_h_advances_default (hb_font_t* font, for (unsigned int i = 0; i < count; i++) { *first_advance = font->parent_scale_x_distance (*first_advance); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_advance = &StructAtOffset (first_advance, advance_stride); +#pragma GCC diagnostic pop } } @@ -273,8 +279,11 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font, for (unsigned int i = 0; i < count; i++) { *first_advance = font->get_glyph_v_advance (*first_glyph); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_glyph = &StructAtOffset (first_glyph, glyph_stride); first_advance = &StructAtOffset (first_advance, advance_stride); +#pragma GCC diagnostic pop } return; } @@ -285,7 +294,10 @@ hb_font_get_glyph_v_advances_default (hb_font_t* font, for (unsigned int i = 0; i < count; i++) { *first_advance = font->parent_scale_y_distance (*first_advance); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_advance = &StructAtOffset (first_advance, advance_stride); +#pragma GCC diagnostic pop } } @@ -2039,5 +2051,3 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, trampoline, trampoline_destroy); } - -#pragma GCC diagnostic pop diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 5f6e38087..2f866f48f 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -228,8 +228,11 @@ hb_ft_get_nominal_glyphs (hb_font_t *font HB_UNUSED, done < count && (*first_glyph = FT_Get_Char_Index (ft_font->ft_face, *first_unicode)); done++) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_unicode = &StructAtOffset (first_unicode, unicode_stride); first_glyph = &StructAtOffset (first_glyph, glyph_stride); +#pragma GCC diagnostic pop } /* We don't need to do ft_font->symbol dance here, since HB calls the singular * nominal_glyph() for what we don't handle here. */ @@ -292,8 +295,11 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data, } *first_advance = (v * mult + (1<<9)) >> 10; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_glyph = &StructAtOffset (first_glyph, glyph_stride); first_advance = &StructAtOffset (first_advance, advance_stride); +#pragma GCC diagnostic pop } } diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index c73710406..802231a8c 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -1054,8 +1054,11 @@ struct cmap done < count && get_glyph_funcZ (get_glyph_data, *first_unicode, first_glyph); done++) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_unicode = &StructAtOffset (first_unicode, unicode_stride); first_glyph = &StructAtOffset (first_glyph, glyph_stride); +#pragma GCC diagnostic pop } return done; } diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index c080f0fd9..81bc97fd8 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -112,8 +112,11 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, for (unsigned int i = 0; i < count; i++) { *first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font)); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_glyph = &StructAtOffset (first_glyph, glyph_stride); first_advance = &StructAtOffset (first_advance, advance_stride); +#pragma GCC diagnostic pop } } @@ -132,8 +135,11 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data, for (unsigned int i = 0; i < count; i++) { *first_advance = font->em_scale_y (-(int) vmtx.get_advance (*first_glyph, font)); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" first_glyph = &StructAtOffset (first_glyph, glyph_stride); first_advance = &StructAtOffset (first_advance, advance_stride); +#pragma GCC diagnostic pop } }