summaryrefslogtreecommitdiffhomepage
path: root/types.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-04-27 00:35:20 +0200
committerJo-Philipp Wich <jo@mein.io>2021-04-27 12:18:32 +0200
commit64eec7f90e945696572ee076b75d1f35e8f2248a (patch)
treef61121e8f89e39787a960e621fc8492e57fc4bc0 /types.c
parent4af803d76e4c08ff5661c2b37dbd333f3aba866d (diff)
treewide: ISO C / pedantic compliance
- Shuffle typedefs to avoid need for non-compliant forward declarations - Fix non-compliant empty struct initializers - Remove use of braced expressions - Remove use of anonymous unions - Avoid `void *` pointer arithmetic - Fix several warnings reported by gcc -pedantic mode and clang 11 compilation Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'types.c')
-rw-r--r--types.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/types.c b/types.c
index e786fb1..3ed8aaa 100644
--- a/types.c
+++ b/types.c
@@ -927,7 +927,7 @@ ucv_closure_new(uc_vm *vm, uc_function_t *function, bool arrow_fn)
closure->header.refcount = 1;
closure->function = function;
closure->is_arrow = arrow_fn;
- closure->upvals = function->nupvals ? ((void *)closure + ALIGN(sizeof(*closure))) : NULL;
+ closure->upvals = function->nupvals ? (uc_upvalref_t **)((uintptr_t)closure + ALIGN(sizeof(*closure))) : NULL;
if (vm)
ucv_ref(&vm->values, &closure->ref);
@@ -1590,8 +1590,8 @@ ucv_to_stringbuf(uc_vm *vm, uc_stringbuf_t *pb, uc_value_t *uv, bool json)
ucv_stringbuf_printf(pb, "%sfunction%s%s(...) { [native code] }%s",
json ? "\"" : "",
- cfunction->name ? " " : "",
- cfunction->name ? cfunction->name : "",
+ cfunction->name[0] ? " " : "",
+ cfunction->name[0] ? cfunction->name : "",
json ? "\"" : "");
break;
@@ -1739,6 +1739,7 @@ ucv_equal(uc_value_t *uv1, uc_value_t *uv2)
}
ucv_object_foreach(uv2, key2, val2) {
+ (void)val2;
ucv_object_get(uv1, key2, &b1);
if (!b1)
@@ -1772,7 +1773,7 @@ ucv_gc(uc_vm *vm, bool final)
/* unref unreachable objects */
for (ref = vm->values.next; ref != &vm->values; ref = ref->next) {
- val = (void *)ref - offsetof(uc_array_t, ref);
+ val = (uc_value_t *)((uintptr_t)ref - offsetof(uc_array_t, ref));
if (ucv_is_marked(val))
ucv_clear_mark(val);
@@ -1782,7 +1783,7 @@ ucv_gc(uc_vm *vm, bool final)
/* free destroyed objects */
for (ref = vm->values.next, tmp = ref->next; ref != &vm->values; ref = tmp, tmp = tmp->next) {
- val = (void *)ref - offsetof(uc_array_t, ref);
+ val = (uc_value_t *)((uintptr_t)ref - offsetof(uc_array_t, ref));
if (val->type == UC_NULL) {
ucv_unref(ref);