Browse Source

-Wextra fixes

pull/1/head
Sami Vaarala 11 years ago
parent
commit
7f3feeac24
  1. 4
      src/duk_bi_array.c
  2. 6
      src/duk_bi_math.c
  3. 3
      src/duk_bi_string.c
  4. 24
      src/duk_hbuffer_ops.c

4
src/duk_bi_array.c

@ -875,8 +875,8 @@ int duk_bi_array_prototype_slice(duk_context *ctx) {
end = len + end;
}
}
DUK_ASSERT(start >= 0 && start <= len);
DUK_ASSERT(end >= 0 && end <= len);
DUK_ASSERT(start >= 0 && (duk_uint32_t) start <= len);
DUK_ASSERT(end >= 0 && (duk_uint32_t) end <= len);
idx = 0;
for (i = start; i < end; i++) {

6
src/duk_bi_math.c

@ -176,7 +176,8 @@ duk_ret_t duk_bi_math_object_onearg_shared(duk_context *ctx) {
duk_small_int_t fun_idx = duk_get_magic(ctx);
one_arg_func fun;
DUK_ASSERT(fun_idx >= 0 && fun_idx < sizeof(one_arg_funcs) / sizeof(one_arg_func));
DUK_ASSERT(fun_idx >= 0);
DUK_ASSERT(fun_idx < (duk_small_int_t) (sizeof(one_arg_funcs) / sizeof(one_arg_func)));
fun = one_arg_funcs[fun_idx];
/* FIXME: double typing here: double or duk_double_t? */
duk_push_number(ctx, fun((double) duk_to_number(ctx, 0)));
@ -187,7 +188,8 @@ duk_ret_t duk_bi_math_object_twoarg_shared(duk_context *ctx) {
duk_small_int_t fun_idx = duk_get_magic(ctx);
two_arg_func fun;
DUK_ASSERT(fun_idx >= 0 && fun_idx < sizeof(two_arg_funcs) / sizeof(two_arg_func));
DUK_ASSERT(fun_idx >= 0);
DUK_ASSERT(fun_idx < (duk_small_int_t) (sizeof(two_arg_funcs) / sizeof(two_arg_func)));
fun = two_arg_funcs[fun_idx];
/* FIXME: double typing here: double or duk_double_t? */
duk_push_number(ctx, fun((double) duk_to_number(ctx, 0), (double) duk_to_number(ctx, 1)));

3
src/duk_bi_string.c

@ -151,7 +151,8 @@ duk_ret_t duk_bi_string_prototype_char_code_at(duk_context *ctx) {
boff = duk_heap_strcache_offset_char2byte(thr, h, (duk_uint32_t) pos);
DUK_DDDPRINT("charCodeAt: pos=%d -> boff=%d, str=%!O", pos, boff, h);
DUK_ASSERT(boff >= 0 && boff < DUK_HSTRING_GET_BYTELEN(h));
DUK_ASSERT_DISABLE(boff >= 0);
DUK_ASSERT(boff < DUK_HSTRING_GET_BYTELEN(h));
p_start = DUK_HSTRING_GET_DATA(h);
p_end = p_start + DUK_HSTRING_GET_BYTELEN(h);
p = p_start + boff;

24
src/duk_hbuffer_ops.c

@ -120,10 +120,10 @@ void duk_hbuffer_insert_bytes(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT(offset >= 0); /* unsigned, so always true */
DUK_ASSERT_DISABLE(offset >= 0); /* unsigned, so always true */
DUK_ASSERT(offset <= DUK_HBUFFER_GET_SIZE(buf)); /* equality is OK (= append) */
DUK_ASSERT(data != NULL);
DUK_ASSERT(length >= 0); /* unsigned, so always true */
DUK_ASSERT_DISABLE(length >= 0); /* unsigned, so always true */
if (length == 0) {
return;
@ -218,7 +218,8 @@ size_t duk_hbuffer_insert_cesu8(duk_hthread *thr, duk_hbuffer_dynamic *buf, size
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT(codepoint >= 0 && codepoint <= 0x10ffff); /* if not in this range, results are garbage (but no crash) */
DUK_ASSERT_DISABLE(codepoint >= 0);
DUK_ASSERT(codepoint <= 0x10ffff); /* if not in this range, results are garbage (but no crash) */
/* Intentionally no fast path: insertion is not that central */
@ -323,7 +324,8 @@ size_t duk_hbuffer_append_cesu8(duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT(codepoint >= 0 && codepoint <= 0x10ffff); /* if not in this range, results are garbage (but no crash) */
DUK_ASSERT_DISABLE(codepoint >= 0);
DUK_ASSERT(codepoint <= 0x10ffff); /* if not in this range, results are garbage (but no crash) */
if (codepoint < 0x80 && DUK_HBUFFER_DYNAMIC_GET_SPARE_SIZE(buf) > 0) {
/* fast path: ASCII and there is spare */
@ -369,9 +371,9 @@ void duk_hbuffer_remove_slice(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT(offset >= 0); /* always true */
DUK_ASSERT_DISABLE(offset >= 0); /* always true */
DUK_ASSERT(offset <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
DUK_ASSERT(length >= 0); /* always true */
DUK_ASSERT_DISABLE(length >= 0); /* always true */
DUK_ASSERT(offset + length <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
if (length == 0) {
@ -406,11 +408,11 @@ void duk_hbuffer_insert_slice(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT(dst_offset >= 0); /* always true */
DUK_ASSERT_DISABLE(dst_offset >= 0); /* always true */
DUK_ASSERT(dst_offset <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
DUK_ASSERT(src_offset >= 0); /* always true */
DUK_ASSERT_DISABLE(src_offset >= 0); /* always true */
DUK_ASSERT(src_offset <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
DUK_ASSERT(length >= 0); /* always true */
DUK_ASSERT_DISABLE(length >= 0); /* always true */
DUK_ASSERT(src_offset + length <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
if (length == 0) {
@ -477,9 +479,9 @@ void duk_hbuffer_append_slice(duk_hthread *thr, duk_hbuffer_dynamic *buf, size_t
DUK_ASSERT(thr != NULL);
DUK_ASSERT(buf != NULL);
DUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));
DUK_ASSERT(src_offset >= 0); /* always true */
DUK_ASSERT_DISABLE(src_offset >= 0); /* always true */
DUK_ASSERT(src_offset <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
DUK_ASSERT(length >= 0); /* always true */
DUK_ASSERT_DISABLE(length >= 0); /* always true */
DUK_ASSERT(src_offset + length <= DUK_HBUFFER_GET_SIZE(buf)); /* allow equality */
duk_hbuffer_insert_slice(thr,

Loading…
Cancel
Save