Fix misc warnings reported by cppcheck https://bugs.freedesktop.org/show_bug.cgi?id=65544
diff --git a/src/hb-common.cc b/src/hb-common.cc index 540d252..7c6d262 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc
@@ -243,8 +243,8 @@ if (!str || !len || !*str) return HB_LANGUAGE_INVALID; - char strbuf[32]; if (len >= 0) { + char strbuf[64]; len = MIN (len, (int) sizeof (strbuf) - 1); str = (char *) memcpy (strbuf, str, len); strbuf[len] = '\0';
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index 8f94795..66db97b 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc
@@ -178,7 +178,6 @@ unsigned int num_features) { hb_face_t *face = font->face; - hb_coretext_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); hb_coretext_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); #define FAIL(...) \ @@ -232,7 +231,6 @@ CFArrayRef glyph_runs = CTLineGetGlyphRuns (line); unsigned int num_runs = CFArrayGetCount (glyph_runs); - bool success = true; buffer->len = 0; const CFRange range_all = CFRangeMake (0, 0); @@ -287,7 +285,6 @@ double advance = (j + 1 < num_glyphs ? positions[j + 1].x : positions[0].x + run_width) - positions[j].x; hb_glyph_info_t *info = &buffer->info[buffer->len]; - hb_glyph_position_t *pos = &buffer->pos[buffer->len]; info->codepoint = glyphs[j]; info->cluster = string_indices[j];
diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh index 48fbb0e..3a42f07 100644 --- a/src/hb-font-private.hh +++ b/src/hb-font-private.hh
@@ -336,16 +336,21 @@ hb_direction_t direction, hb_position_t *x, hb_position_t *y) { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { - hb_bool_t ret = get_glyph_h_origin (glyph, x, y); - if (!ret && (ret = get_glyph_v_origin (glyph, x, y))) { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) + { + if (!get_glyph_h_origin (glyph, x, y) && + get_glyph_v_origin (glyph, x, y)) + { hb_position_t dx, dy; guess_v_origin_minus_h_origin (glyph, &dx, &dy); *x -= dx; *y -= dy; } - } else { - hb_bool_t ret = get_glyph_v_origin (glyph, x, y); - if (!ret && (ret = get_glyph_h_origin (glyph, x, y))) { + } + else + { + if (!get_glyph_v_origin (glyph, x, y) && + get_glyph_h_origin (glyph, x, y)) + { hb_position_t dx, dy; guess_v_origin_minus_h_origin (glyph, &dx, &dy); *x += dx; *y += dy;
diff --git a/src/hb-private.hh b/src/hb-private.hh index 8121640..13465c6 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh
@@ -595,7 +595,7 @@ #define ULBAR "\342\225\257" /* U+256F BOX DRAWINGS LIGHT ARC UP AND LEFT */ #define LBAR "\342\225\264" /* U+2574 BOX DRAWINGS LIGHT LEFT */ static const char bars[] = VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR VBAR; - fprintf (stderr, "%2d %s" VRBAR "%s", + fprintf (stderr, "%2u %s" VRBAR "%s", level, bars + sizeof (bars) - 1 - MIN ((unsigned int) sizeof (bars), (unsigned int) (sizeof (VBAR) - 1) * level), level_dir ? (level_dir > 0 ? DLBAR : ULBAR) : LBAR);
diff --git a/src/hb-shape.cc b/src/hb-shape.cc index 67ef7e6..c28fdfa 100644 --- a/src/hb-shape.cc +++ b/src/hb-shape.cc
@@ -197,7 +197,7 @@ assert (len < ARRAY_LENGTH (s)); len = MIN (len, size - 1); memcpy (buf, s, len); - s[len] = '\0'; + buf[len] = '\0'; }
diff --git a/test/api/test-font.c b/test/api/test-font.c index 40540c4..6b6a503 100644 --- a/test/api/test-font.c +++ b/test/api/test-font.c
@@ -136,7 +136,6 @@ g_assert (!hb_font_get_glyph (font, 17, 2, &glyph)); g_assert_cmpint (glyph, ==, 0); - x = 13; x = hb_font_get_glyph_h_kerning (font, 17, 19); g_assert_cmpint (x, ==, 0); }
diff --git a/util/ansi-print.cc b/util/ansi-print.cc index e166c91..0fc3719 100644 --- a/util/ansi-print.cc +++ b/util/ansi-print.cc
@@ -157,6 +157,7 @@ biimage_t (unsigned int width, unsigned int height) : width (width), height (height), + bg (0), fg (0), unicolor (true), data ((uint8_t *) malloc (sizeof (data[0]) * width * height)) {} ~biimage_t (void) { free (data); }
diff --git a/util/hb-ot-shape-closure.cc b/util/hb-ot-shape-closure.cc index fd9756b..7c81a7d 100644 --- a/util/hb-ot-shape-closure.cc +++ b/util/hb-ot-shape-closure.cc
@@ -79,8 +79,9 @@ first = false; else printf (" "); - char glyph_name[32]; - if (show_glyph_names) { + if (show_glyph_names) + { + char glyph_name[64]; hb_font_get_glyph_name (font, i, glyph_name, sizeof (glyph_name)); printf ("%s", glyph_name); } else
diff --git a/util/hb-shape.cc b/util/hb-shape.cc index 852f9cf..b62f744 100644 --- a/util/hb-shape.cc +++ b/util/hb-shape.cc
@@ -33,7 +33,10 @@ output_buffer_t (option_parser_t *parser) : options (parser, g_strjoinv ("/", (gchar**) hb_buffer_serialize_list_formats ())), - format (parser) {} + format (parser), + gs (NULL), + line_no (0), + font (NULL) {} void init (const font_options_t *font_opts) {
diff --git a/util/shape-consumer.hh b/util/shape-consumer.hh index 8fd7ec3..422c8cd 100644 --- a/util/shape-consumer.hh +++ b/util/shape-consumer.hh
@@ -34,8 +34,10 @@ struct shape_consumer_t { shape_consumer_t (option_parser_t *parser) - : shaper (parser), - output (parser) {} + : failed (false), + shaper (parser), + output (parser), + font (NULL) {} void init (const font_options_t *font_opts) {
diff --git a/util/view-cairo.hh b/util/view-cairo.hh index f273464..8fe74fa 100644 --- a/util/view-cairo.hh +++ b/util/view-cairo.hh
@@ -31,10 +31,12 @@ #define VIEW_CAIRO_HH -struct view_cairo_t { +struct view_cairo_t +{ view_cairo_t (option_parser_t *parser) : output_options (parser, helper_cairo_supported_formats), - view_options (parser) {} + view_options (parser), + lines (0), scale (1.0) {} ~view_cairo_t (void) { if (debug) cairo_debug_reset_static_data ();