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:
Akos Kiss
2018-05-25 07:27:30 +02:00
committed by GitHub
parent acb3e71436
commit 4779451284
24 changed files with 168 additions and 256 deletions
@@ -740,8 +740,10 @@ ecma_date_to_string_format (ecma_number_t datetime_number, /**< datetime */
number_length = 2;
break;
}
case LIT_CHAR_UPPERCASE_Z: /* Time zone seconds part. */
default:
{
JERRY_ASSERT (*format_p == LIT_CHAR_UPPERCASE_Z); /* Time zone seconds part. */
int32_t time_zone = (int32_t) ecma_date_local_time_zone (datetime_number);
if (time_zone < 0)
@@ -753,11 +755,6 @@ ecma_date_to_string_format (ecma_number_t datetime_number, /**< datetime */
number_length = 2;
break;
}
default:
{
JERRY_UNREACHABLE ();
break;
}
}
format_p++;