From ffcf54d4fb422e39c3d0a6c5f2ec62889d971bdc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 8 Nov 2023 09:11:07 +0100 Subject: [PATCH] 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. --- src/core/unit.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/unit.c b/src/core/unit.c index e865c393a3b..66ac9c91ec0 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -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; -- 2.47.3