Browse Source

Fix misc unref variable and const cast warnings

pull/573/head
Sami Vaarala 9 years ago
parent
commit
c5f8cca0b0
  1. 2
      src/duk_heap.h
  2. 6
      src/duk_heap_stringtable.c
  3. 1
      src/duk_hobject_props.c
  4. 2
      src/duk_hstring.h
  5. 2
      src/duk_hthread.h
  6. 2
      src/duk_hthread_builtins.c
  7. 2
      src/duk_js_ops.c

2
src/duk_heap.h

@ -160,7 +160,7 @@
/* heap string indices are autogenerated in duk_strings.h */
#if defined(DUK_USE_ROM_STRINGS)
#define DUK_HEAP_GET_STRING(heap,idx) \
((duk_hstring *) duk_rom_strings_stridx[(idx)])
((duk_hstring *) DUK_LOSE_CONST(duk_rom_strings_stridx[(idx)]))
#else /* DUK_USE_ROM_STRINGS */
#if defined(DUK_USE_HEAPPTR16)
#define DUK_HEAP_GET_STRING(heap,idx) \

6
src/duk_heap_stringtable.c

@ -847,7 +847,7 @@ DUK_LOCAL duk_hstring *duk__do_intern(duk_heap *heap, const duk_uint8_t *str, du
#endif
#if defined(DUK_USE_HSTRING_EXTDATA) && defined(DUK_USE_EXTSTR_INTERN_CHECK)
extdata = (const duk_uint8_t *) DUK_USE_EXTSTR_INTERN_CHECK(heap->heap_udata, (void *) str, (duk_size_t) blen);
extdata = (const duk_uint8_t *) DUK_USE_EXTSTR_INTERN_CHECK(heap->heap_udata, (void *) DUK_LOSE_CONST(str), (duk_size_t) blen);
#else
extdata = (const duk_uint8_t *) NULL;
#endif
@ -900,9 +900,9 @@ DUK_LOCAL duk_hstring *duk__do_lookup(duk_heap *heap, const duk_uint8_t *str, du
*/
for (i = 0; i < (duk_small_uint_t) (sizeof(duk_rom_strings) / sizeof(duk_hstring *)); i++) {
duk_hstring *romstr;
romstr = (duk_hstring *) duk_rom_strings[i];
romstr = (duk_hstring *) DUK_LOSE_CONST(duk_rom_strings[i]);
if (blen == DUK_HSTRING_GET_BYTELEN(romstr) &&
DUK_MEMCMP(str, (void *) DUK_HSTRING_GET_DATA(romstr), blen) == 0) {
DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(romstr), blen) == 0) {
DUK_DD(DUK_DDPRINT("intern check: rom string: %!O, computed hash 0x%08lx, rom hash 0x%08lx",
romstr, (unsigned long) *out_strhash, (unsigned long) DUK_HSTRING_GET_HASH(romstr)));
DUK_ASSERT(*out_strhash == DUK_HSTRING_GET_HASH(romstr));

1
src/duk_hobject_props.c

@ -161,6 +161,7 @@ DUK_LOCAL duk_uint32_t duk__push_tval_to_hstring_arr_idx(duk_context *ctx, duk_t
/* String is an own (virtual) property of a lightfunc. */
DUK_LOCAL duk_bool_t duk__key_is_lightfunc_ownprop(duk_hthread *thr, duk_hstring *key) {
DUK_UNREF(thr);
return (key == DUK_HTHREAD_STRING_LENGTH(thr) ||
key == DUK_HTHREAD_STRING_NAME(thr));
}

2
src/duk_hstring.h

@ -106,7 +106,7 @@
((x)->extdata)
#define DUK_HSTRING_GET_DATA(x) \
(DUK_HSTRING_HAS_EXTDATA((x)) ? \
DUK_HSTRING_GET_EXTDATA((duk_hstring_external *) (x)) : ((const duk_uint8_t *) ((x) + 1)))
DUK_HSTRING_GET_EXTDATA((const duk_hstring_external *) (x)) : ((const duk_uint8_t *) ((x) + 1)))
#else
#define DUK_HSTRING_GET_DATA(x) \
((const duk_uint8_t *) ((x) + 1))

2
src/duk_hthread.h

@ -123,7 +123,7 @@
#if defined(DUK_USE_ROM_STRINGS)
#define DUK_HTHREAD_GET_STRING(thr,idx) \
((duk_hstring *) duk_rom_strings_stridx[(idx)])
((duk_hstring *) DUK_LOSE_CONST(duk_rom_strings_stridx[(idx)]))
#else /* DUK_USE_ROM_STRINGS */
#if defined(DUK_USE_HEAPPTR16)
#define DUK_HTHREAD_GET_STRING(thr,idx) \

2
src/duk_hthread_builtins.c

@ -151,7 +151,7 @@ DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {
for (i = 0; i < DUK_NUM_BUILTINS; i++) {
duk_hobject *h;
h = (duk_hobject *) duk_rom_builtins_bidx[i];
h = (duk_hobject *) DUK_LOSE_CONST(duk_rom_builtins_bidx[i]);
DUK_ASSERT(h != NULL);
thr->builtins[i] = h;
}

2
src/duk_js_ops.c

@ -1236,6 +1236,8 @@ DUK_INTERNAL duk_bool_t duk_js_in(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv
DUK_INTERNAL duk_hstring *duk_js_typeof(duk_hthread *thr, duk_tval *tv_x) {
duk_small_int_t stridx = 0;
DUK_UNREF(thr);
switch (DUK_TVAL_GET_TAG(tv_x)) {
case DUK_TAG_UNDEFINED: {
stridx = DUK_STRIDX_LC_UNDEFINED;

Loading…
Cancel
Save