From 48eaee471f0d5348eede5d338932c4318b8f2d53 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 17 Oct 2023 09:25:06 +0200 Subject: [PATCH] device: remove duplicated checks when resetting ethtool settings `_ethtool_*_reset()` functions already check that the state is not NULL, no need to check it before. The only exception was for "feature" settings, where the check was missing. --- src/core/devices/nm-device.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 2f7b4f81b8..9e45d46765 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -2385,6 +2385,8 @@ _ethtool_features_reset(NMDevice *self, NMPlatform *platform, EthtoolState *etht gs_free NMEthtoolFeatureStates *features = NULL; features = g_steal_pointer(ðtool_state->features); + if (!features) + return; if (!nm_platform_ethtool_set_features(platform, ethtool_state->ifindex, @@ -2404,8 +2406,7 @@ _ethtool_features_set(NMDevice *self, { gs_free NMEthtoolFeatureStates *features = NULL; - if (ethtool_state->features) - _ethtool_features_reset(self, platform, ethtool_state); + _ethtool_features_reset(self, platform, ethtool_state); if (nm_setting_ethtool_init_features(s_ethtool, ethtool_state->requested) == 0) return; @@ -2719,14 +2720,10 @@ _ethtool_state_reset(NMDevice *self) if (!ethtool_state) return; - if (ethtool_state->features) - _ethtool_features_reset(self, platform, ethtool_state); - if (ethtool_state->coalesce) - _ethtool_coalesce_reset(self, platform, ethtool_state); - if (ethtool_state->ring) - _ethtool_ring_reset(self, platform, ethtool_state); - if (ethtool_state->pause) - _ethtool_pause_reset(self, platform, ethtool_state); + _ethtool_features_reset(self, platform, ethtool_state); + _ethtool_coalesce_reset(self, platform, ethtool_state); + _ethtool_ring_reset(self, platform, ethtool_state); + _ethtool_pause_reset(self, platform, ethtool_state); } static void