From dac86026a6bae5a8a03cfe885bf93f32e5f48614 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 3 Jun 2014 17:57:00 -0400 Subject: [PATCH] Fix some cppcheck warnings Bug 77800 - cppcheck reports --- src/hb-common.cc | 4 +++- src/hb-ot-layout-common-private.hh | 2 +- src/hb-private.hh | 2 +- src/hb-shape-plan.cc | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hb-common.cc b/src/hb-common.cc index 96725c4e1..afaecce0c 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -299,9 +299,11 @@ hb_language_from_string (const char *str, int len) if (len >= 0) { + /* NUL-terminate it. */ len = MIN (len, (int) sizeof (strbuf) - 1); - str = (char *) memcpy (strbuf, str, len); + memcpy (strbuf, str, len); strbuf[len] = '\0'; + str = strbuf; } hb_language_item_t *item = lang_find_or_insert (str); diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 02d0d0f87..4c6792fbc 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -513,7 +513,7 @@ struct Feature closure->list_base && closure->list_base < this) { unsigned int new_offset_int = (unsigned int) orig_offset - - ((char *) this - (char *) closure->list_base); + (((char *) this) - ((char *) closure->list_base)); Offset new_offset; /* Check that it did not overflow. */ diff --git a/src/hb-private.hh b/src/hb-private.hh index 1a1926da8..f36187586 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -193,7 +193,7 @@ ASSERT_STATIC (sizeof (hb_var_int_t) == 4); /* Check _assertion in a method environment */ #define _ASSERT_POD1(_line) \ - inline void _static_assertion_on_line_##_line (void) const \ + HB_UNUSED inline void _static_assertion_on_line_##_line (void) const \ { _ASSERT_INSTANCE_POD1 (_line, *this); /* Make sure it's POD. */ } # define _ASSERT_POD0(_line) _ASSERT_POD1 (_line) # define ASSERT_POD() _ASSERT_POD0 (__LINE__) diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc index e354f2917..5ffc6b136 100644 --- a/src/hb-shape-plan.cc +++ b/src/hb-shape-plan.cc @@ -104,8 +104,6 @@ hb_shape_plan_create (hb_face_t *face, unsigned int num_user_features, const char * const *shaper_list) { - assert (props->direction != HB_DIRECTION_INVALID); - hb_shape_plan_t *shape_plan; hb_feature_t *features = NULL; @@ -120,6 +118,8 @@ hb_shape_plan_create (hb_face_t *face, return hb_shape_plan_get_empty (); } + assert (props->direction != HB_DIRECTION_INVALID); + hb_face_make_immutable (face); shape_plan->default_shaper_list = shaper_list == NULL; shape_plan->face_unsafe = face;