Cleanup code around JERRY_UNREACHABLEs (#2342)
`JERRY_UNREACHABLE`s often signal code structure that could be improved: they can usually either be rewritten to `JERRY_ASSERT`s or eliminated by restructuring loops, `if`s or `#if`s. Roughly, the only valid occurences are in default cases of `switch`es. And even they can often be merged into non-default cases. Moreover, it is dangerous to write meaningful code after `JERRY_UNREACHABLE` because it pretends as if there was a way to recover from an impossible situation. This patch rewrites/eliminates `JERRY_UNREACHABLE`s where possible and removes misleading code from after them. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -108,12 +108,9 @@ lit_get_magic_string_size_block_start (lit_utf8_size_t size) /**< magic string s
|
||||
const lit_utf8_byte_t *
|
||||
lit_get_magic_string_ex_utf8 (lit_magic_string_ex_id_t id) /**< extern magic string id */
|
||||
{
|
||||
if (JERRY_CONTEXT (lit_magic_string_ex_array) && id < JERRY_CONTEXT (lit_magic_string_ex_count))
|
||||
{
|
||||
return JERRY_CONTEXT (lit_magic_string_ex_array)[id];
|
||||
}
|
||||
JERRY_ASSERT (JERRY_CONTEXT (lit_magic_string_ex_array) && id < JERRY_CONTEXT (lit_magic_string_ex_count));
|
||||
|
||||
JERRY_UNREACHABLE ();
|
||||
return JERRY_CONTEXT (lit_magic_string_ex_array)[id];
|
||||
} /* lit_get_magic_string_ex_utf8 */
|
||||
|
||||
/**
|
||||
|
||||
@@ -373,14 +373,11 @@ lit_read_code_point_from_utf8 (const lit_utf8_byte_t *buf_p, /**< buffer with ch
|
||||
bytes_count = 3;
|
||||
ret = ((lit_code_point_t) (c & LIT_UTF8_LAST_4_BITS_MASK));
|
||||
}
|
||||
else if ((c & LIT_UTF8_4_BYTE_MASK) == LIT_UTF8_4_BYTE_MARKER)
|
||||
{
|
||||
bytes_count = 4;
|
||||
ret = ((lit_code_point_t) (c & LIT_UTF8_LAST_3_BITS_MASK));
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (false);
|
||||
JERRY_ASSERT ((c & LIT_UTF8_4_BYTE_MASK) == LIT_UTF8_4_BYTE_MARKER);
|
||||
bytes_count = 4;
|
||||
ret = ((lit_code_point_t) (c & LIT_UTF8_LAST_3_BITS_MASK));
|
||||
}
|
||||
|
||||
JERRY_ASSERT (buf_size >= bytes_count);
|
||||
|
||||
Reference in New Issue
Block a user