core/unit: use assert for checking internal call sanity

The only way this could be called with an invalid value would be if
somebody forgot to initialize unit type. In such cases, it's better to
fail hard immediately.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-11-08 09:11:07 +01:00
parent fa5a025167
commit ffcf54d4fb

View file

@ -5079,10 +5079,7 @@ bool unit_type_supported(UnitType t) {
static int8_t cache[_UNIT_TYPE_MAX] = {}; /* -1: disabled, 1: enabled: 0: don't know */
int r;
if (_unlikely_(t < 0))
return false;
if (_unlikely_(t >= _UNIT_TYPE_MAX))
return false;
assert(t >= 0 && t < _UNIT_TYPE_MAX);
if (cache[t] == 0) {
char *e;