From 2027ff50af7572ffb08331f6bc79c39ad7d4f5f4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 11 May 2020 14:43:11 +0200 Subject: [PATCH] ethtool: use NM_MORE_ASSERT_ONCE() in _ASSERT_data() to assert immutable data only once _ASSERT_data() checks static, immutable data. Even with more asserts enabled, there is no need to do that every time. Use NM_MORE_ASSERT_ONCE(). Note that NM_MORE_ASSERT_ONCE() will return constant FALSE, when build without a sufficiently high assertion level. That means, the compiler will just optimize the rest away. --- shared/nm-libnm-core-intern/nm-ethtool-utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/nm-libnm-core-intern/nm-ethtool-utils.c b/shared/nm-libnm-core-intern/nm-ethtool-utils.c index 2bc182cf15..f080b5c173 100644 --- a/shared/nm-libnm-core-intern/nm-ethtool-utils.c +++ b/shared/nm-libnm-core-intern/nm-ethtool-utils.c @@ -135,9 +135,11 @@ static const guint8 _by_name[_NM_ETHTOOL_ID_NUM] = { static void _ASSERT_data (void) { -#if NM_MORE_ASSERTS > 10 int i; + if (!NM_MORE_ASSERT_ONCE (10)) + return; + G_STATIC_ASSERT_EXPR (_NM_ETHTOOL_ID_FIRST == 0); G_STATIC_ASSERT_EXPR (_NM_ETHTOOL_ID_LAST == _NM_ETHTOOL_ID_NUM - 1); G_STATIC_ASSERT_EXPR (_NM_ETHTOOL_ID_NUM > 0); @@ -173,7 +175,6 @@ _ASSERT_data (void) } } } -#endif } static int