From 0f6c84214c0965caaa9faea6f1f944b903039f97 Mon Sep 17 00:00:00 2001 From: "W. Andrew Denton" Date: Mon, 18 Oct 2021 11:16:10 -0700 Subject: [PATCH] ethtool: minor changes to resolve review nits. Signed-off-by: W. Andrew Denton --- collector/ethtool_linux.go | 89 ++++++++++++++++----------------- collector/ethtool_linux_test.go | 51 +++++++++---------- 2 files changed, 66 insertions(+), 74 deletions(-) diff --git a/collector/ethtool_linux.go b/collector/ethtool_linux.go index 3116f826..0aa9239a 100644 --- a/collector/ethtool_linux.go +++ b/collector/ethtool_linux.go @@ -225,16 +225,18 @@ func NewEthtoolCollector(logger log.Logger) (Collector, error) { // The bit offsets here correspond to ethtool_link_mode_bit_indices in linux/include/uapi/linux/ethtool.h // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/ethtool.h func (c *ethtoolCollector) updatePortCapabilities(ch chan<- prometheus.Metric, prefix string, device string, linkModes uint32) { - autonegotiate := 0.0 - pause := 0.0 - asymmetricPause := 0.0 - if linkModes&(1<<6) != 0 { + var ( + autonegotiate = 0.0 + pause = 0.0 + asymmetricPause = 0.0 + ) + if linkModes&(1<