Fix some cppcheck warnings

Bug 77800 - cppcheck reports
This commit is contained in:
Behdad Esfahbod 2014-06-03 17:57:00 -04:00
parent c306410cab
commit dac86026a6
4 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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. */

View File

@ -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__)

View File

@ -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;