From f8b05efa7f5a87220f531230986d9b8de1ee4e89 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 21 Feb 2016 19:02:23 +0900 Subject: [PATCH] don't call pic_panic on internal logic flaw --- contrib/40.srfi/src/106.c | 6 +----- extlib/benz/gc.c | 24 ++++-------------------- extlib/benz/state.c | 8 +------- extlib/benz/var.c | 2 +- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/contrib/40.srfi/src/106.c b/contrib/40.srfi/src/106.c index 72633481..5f1e4c3a 100644 --- a/contrib/40.srfi/src/106.c +++ b/contrib/40.srfi/src/106.c @@ -219,11 +219,7 @@ pic_socket_socket_recv(pic_state *pic) ensure_socket_is_open(pic, sock); - buf = pic_blob(pic, pic_blob_value(pic, NULL, size), NULL); - if (buf == NULL && size > 0) { - /* XXX: Is it really OK? */ - pic_panic(pic, "memory exhausted"); - } + buf = pic_alloca(pic, size); errno = 0; do { diff --git a/extlib/benz/gc.c b/extlib/benz/gc.c index 8dc5286b..375c4dab 100644 --- a/extlib/benz/gc.c +++ b/extlib/benz/gc.c @@ -403,16 +403,8 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) } break; } - case PIC_TYPE_NIL: - case PIC_TYPE_TRUE: - case PIC_TYPE_FALSE: - case PIC_TYPE_FLOAT: - case PIC_TYPE_INT: - case PIC_TYPE_CHAR: - case PIC_TYPE_EOF: - case PIC_TYPE_UNDEF: - case PIC_TYPE_INVALID: - pic_panic(pic, "logic flaw"); + default: + PIC_UNREACHABLE(); } } @@ -574,16 +566,8 @@ gc_finalize_object(pic_state *pic, struct pic_object *obj) case PIC_TYPE_CP: break; - case PIC_TYPE_NIL: - case PIC_TYPE_TRUE: - case PIC_TYPE_FALSE: - case PIC_TYPE_FLOAT: - case PIC_TYPE_INT: - case PIC_TYPE_CHAR: - case PIC_TYPE_EOF: - case PIC_TYPE_UNDEF: - case PIC_TYPE_INVALID: - pic_panic(pic, "logic flaw"); + default: + PIC_UNREACHABLE(); } } diff --git a/extlib/benz/state.c b/extlib/benz/state.c index aac2910e..b8d975d4 100644 --- a/extlib/benz/state.c +++ b/extlib/benz/state.c @@ -178,13 +178,7 @@ pic_init_core(pic_state *pic) pic_defun(pic, "features", pic_features); - pic_try { - pic_load_cstr(pic, &pic_boot[0][0]); - } - pic_catch { - pic_print_backtrace(pic, xstdout); - pic_panic(pic, ""); - } + pic_load_cstr(pic, &pic_boot[0][0]); } pic_state * diff --git a/extlib/benz/var.c b/extlib/benz/var.c index 8f4b2ef7..72105734 100644 --- a/extlib/benz/var.c +++ b/extlib/benz/var.c @@ -17,7 +17,7 @@ var_get(pic_state *pic, pic_value var) return pic_weak_ref(pic, weak, var); } } - pic_panic(pic, "logic flaw"); + PIC_UNREACHABLE(); } static pic_value