libnm: avoid "-Walloc-size" warning in nm_team_link_watcher_new_ethtool()

gcc-14.0.1-0.2.fc40 warns:

    CC       src/libnm-core-impl/libnm_core_impl_la-nm-setting-team.lo
  ../src/libnm-core-impl/nm-setting-team.c: In function nm_team_link_watcher_new_ethtool:
  ../src/libnm-core-impl/nm-setting-team.c:127:13: error: allocation of insufficient size 16 for type NMTeamLinkWatcher with size 48 [-Werror=alloc-size]
    127 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
        |             ^
This commit is contained in:
Thomas Haller 2024-01-23 10:17:21 +01:00 committed by Beniamino Galvani
parent 9c67bf9ab6
commit 5715feebe7

View file

@ -123,6 +123,7 @@ nm_team_link_watcher_new_ethtool(int delay_up, int delay_down, GError **error)
}
NM_PRAGMA_WARNING_DISABLE("-Warray-bounds")
NM_PRAGMA_WARNING_DISABLE("-Walloc-size")
watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
@ -131,6 +132,7 @@ nm_team_link_watcher_new_ethtool(int delay_up, int delay_down, GError **error)
watcher->ethtool.delay_up = delay_up;
watcher->ethtool.delay_down = delay_down;
NM_PRAGMA_WARNING_REENABLE
NM_PRAGMA_WARNING_REENABLE
return watcher;