From: Yu Watanabe Date: Wed, 19 Mar 2025 00:38:36 +0000 (+0900) Subject: bitfield: check if specified index is non-negative X-Git-Tag: v258-rc1~1042^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c995855266fa8355cf7ed8133e581360b38bad83;p=thirdparty%2Fsystemd.git bitfield: check if specified index is non-negative Hopefully silences false-positive warnings by Coverity e.g. CID#1590746. --- diff --git a/src/basic/bitfield.h b/src/basic/bitfield.h index 048e08d7534..c6eaaa484fe 100644 --- a/src/basic/bitfield.h +++ b/src/basic/bitfield.h @@ -7,6 +7,7 @@ #define _INDEX_TO_MASK(type, i, uniq) \ ({ \ int UNIQ_T(_i, uniq) = (i); \ + assert(UNIQ_T(_i, uniq) >= 0); \ assert(UNIQ_T(_i, uniq) < (int)sizeof(type) * 8); \ ((type)1) << UNIQ_T(_i, uniq); \ })