Fix misc warnings reported by cppcheck
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 10 Jun 2013 18:39:51 +0000 (14:39 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 10 Jun 2013 19:08:49 +0000 (15:08 -0400)
https://bugs.freedesktop.org/show_bug.cgi?id=65544

src/hb-common.cc
src/hb-coretext.cc
src/hb-font-private.hh
src/hb-private.hh
src/hb-shape.cc
test/api/test-font.c
util/ansi-print.cc
util/hb-ot-shape-closure.cc
util/hb-shape.cc
util/shape-consumer.hh
util/view-cairo.hh

index 540d252..7c6d262 100644 (file)
@@ -243,8 +243,8 @@ hb_language_from_string (const char *str, int len)
   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';
index 8f94795..66db97b 100644 (file)
@@ -178,7 +178,6 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
                     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 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
   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 @@ _hb_coretext_shape (hb_shape_plan_t    *shape_plan,
       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];
index 48fbb0e..3a42f07 100644 (file)
@@ -336,16 +336,21 @@ struct hb_font_t {
                                              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;
index 8121640..13465c6 100644 (file)
@@ -595,7 +595,7 @@ _hb_debug_msg_va (const char *what,
 #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);
index 67ef7e6..c28fdfa 100644 (file)
@@ -197,7 +197,7 @@ hb_feature_to_string (hb_feature_t *feature,
   assert (len < ARRAY_LENGTH (s));
   len = MIN (len, size - 1);
   memcpy (buf, s, len);
-  s[len] = '\0';
+  buf[len] = '\0';
 }
 
 
index 40540c4..6b6a503 100644 (file)
@@ -136,7 +136,6 @@ _test_font_nil_funcs (hb_font_t *font)
   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);
 }
index e166c91..0fc3719 100644 (file)
@@ -157,6 +157,7 @@ struct biimage_t
   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); }
index fd9756b..7c81a7d 100644 (file)
@@ -79,8 +79,9 @@ struct shape_closure_consumer_t : option_group_t
        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
index 852f9cf..b62f744 100644 (file)
@@ -33,7 +33,10 @@ struct output_buffer_t
   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)
   {
index 8fd7ec3..422c8cd 100644 (file)
@@ -34,8 +34,10 @@ template <typename output_t>
 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)
   {
index f273464..8fe74fa 100644 (file)
 #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 ();