Skip to content

Commit

Permalink
Replace ABORTs followed by statement with ABORT_RET having dummy
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ivmai committed Jan 23, 2012
1 parent f23154f commit 8b4a394
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dbg_mlc.c
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion gcj_mlc.c
Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions include/private/gc_priv.h
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mark.c
Expand Up @@ -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--;
Expand Down
4 changes: 2 additions & 2 deletions os_dep.c
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions typd_mlc.c
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 8b4a394

Please sign in to comment.