From 8b4a394117585927b44cd807dbd734a99f7dc7a7 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Mon, 23 Jan 2012 08:17:19 +0400 Subject: [PATCH] Replace ABORTs followed by statement with ABORT_RET having dummy condition (to suppress 'statement unreachable' compiler warnings caused by abort tagged as 'no-return') * dbg_mlc.c (GC_debug_realloc): Replace ABORT() with ABORT_RET(). * gcj_mlc.c (mark_stack_limit): Likewise. * os_dep.c (catch_exception_raise_state, catch_exception_raise_state_identity): Likewise. * typd_mlc.c (GC_descr_obj_size, GC_push_complex_descriptor): Likewise. * include/private/gc_priv.h (ABORT_RET): New macro. * mark.c (GC_mark_from): Put ABORT_RET instead of "cannot happen" comment. --- dbg_mlc.c | 2 +- gcj_mlc.c | 2 +- include/private/gc_priv.h | 5 +++++ mark.c | 2 +- os_dep.c | 4 ++-- typd_mlc.c | 8 ++++---- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dbg_mlc.c b/dbg_mlc.c index c6b76fe..f061236 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -869,7 +869,7 @@ GC_API void * GC_CALL GC_debug_realloc(void * p, size_t lb, GC_EXTRA_PARAMS) default: result = NULL; /* initialized to prevent warning. */ GC_err_printf("GC_debug_realloc: encountered bad kind\n"); - ABORT("Bad kind"); + ABORT_RET("Bad kind"); } if (result != NULL) { diff --git a/gcj_mlc.c b/gcj_mlc.c index a5f3fe5..5bbcbc6 100644 --- a/gcj_mlc.c +++ b/gcj_mlc.c @@ -61,7 +61,7 @@ STATIC struct GC_ms_entry * GC_gcj_fake_mark_proc(word * addr GC_ATTR_UNUSED, struct GC_ms_entry * mark_stack_limit GC_ATTR_UNUSED, word env GC_ATTR_UNUSED) { - ABORT("No client gcj mark proc is specified"); + ABORT_RET("No client gcj mark proc is specified"); return mark_stack_ptr; } diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 7945f19..32f1eba 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -447,6 +447,11 @@ typedef char * ptr_t; /* A generic pointer to which we can add */ # endif # endif +/* Same as ABORT but does not have 'no-return' attribute. */ +/* ABORT on dummy condition (which is always true). */ +#define ABORT_RET(msg) { if ((signed_word)GC_current_warn_proc != -1) \ + ABORT(msg); } + /* Exit abnormally, but without making a mess (e.g. out of memory) */ # ifdef PCR # define EXIT() PCR_Base_Exit(1,PCR_waitForever) diff --git a/mark.c b/mark.c index 4d70b59..1e58424 100644 --- a/mark.c +++ b/mark.c @@ -785,8 +785,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack, } goto retry; default: - /* Can't happen. */ limit = 0; /* initialized to prevent warning. */ + ABORT_RET("GC_mark_from: bad state"); } } else /* Small object with length descriptor */ { mark_stack_top--; diff --git a/os_dep.c b/os_dep.c index fbd9b81..27af6c9 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3852,7 +3852,7 @@ catch_exception_raise_state(mach_port_name_t exception_port GC_ATTR_UNUSED, thread_state_t old_state GC_ATTR_UNUSED, int old_stateCnt GC_ATTR_UNUSED, thread_state_t new_state GC_ATTR_UNUSED, int new_stateCnt GC_ATTR_UNUSED) { - ABORT("Unexpected catch_exception_raise_state invocation"); + ABORT_RET("Unexpected catch_exception_raise_state invocation"); return(KERN_INVALID_ARGUMENT); } @@ -3865,7 +3865,7 @@ catch_exception_raise_state_identity( thread_state_t old_state GC_ATTR_UNUSED, int old_stateCnt GC_ATTR_UNUSED, thread_state_t new_state GC_ATTR_UNUSED, int new_stateCnt GC_ATTR_UNUSED) { - ABORT("Unexpected catch_exception_raise_state_identity invocation"); + ABORT_RET("Unexpected catch_exception_raise_state_identity invocation"); return(KERN_INVALID_ARGUMENT); } diff --git a/typd_mlc.c b/typd_mlc.c index 57fabdb..caba301 100644 --- a/typd_mlc.c +++ b/typd_mlc.c @@ -431,8 +431,8 @@ STATIC word GC_descr_obj_size(complex_descriptor *d) return(GC_descr_obj_size(d -> sd.sd_first) + GC_descr_obj_size(d -> sd.sd_second)); default: - ABORT("Bad complex descriptor"); - /*NOTREACHED*/ return 0; /*NOTREACHED*/ + ABORT_RET("Bad complex descriptor"); + return 0; } } @@ -488,8 +488,8 @@ STATIC mse * GC_push_complex_descriptor(word *addr, complex_descriptor *d, return(msp); } default: - ABORT("Bad complex descriptor"); - /*NOTREACHED*/ return 0; /*NOTREACHED*/ + ABORT_RET("Bad complex descriptor"); + return 0; } } -- 2.7.4