From: Zbigniew Jędrzejewski-Szmek Date: Wed, 8 Nov 2023 08:11:07 +0000 (+0100) Subject: core/unit: use assert for checking internal call sanity X-Git-Tag: v255-rc2~31^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffcf54d4fb422e39c3d0a6c5f2ec62889d971bdc;p=thirdparty%2Fsystemd.git 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. --- 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;