lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20231220172025.3b9c452b@dellmb>
Date: Wed, 20 Dec 2023 17:20:25 +0100
From: Marek BehĂșn <kabel@...nel.org>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: Pavel Machek <pavel@....cz>, Lee Jones <lee@...nel.org>, Andrew Lunn
 <andrew@...n.ch>, Jakub Kicinski <kuba@...nel.org>, Daniel Golle
 <daniel@...rotopia.org>, "David S. Miller" <davem@...emloft.net>, Li Zetao
 <lizetao1@...wei.com>, linux-kernel@...r.kernel.org,
 linux-leds@...r.kernel.org
Subject: Re: [PATCH v4 1/2] leds: trigger: netdev: display only supported
 link speed attribute

On Tue, 19 Dec 2023 17:53:52 +0100
Christian Marangi <ansuelsmth@...il.com> wrote:

> +	for_each_set_bit(mode, supported_link_modes, __ETHTOOL_LINK_MODE_MASK_NBITS) {
> +		struct ethtool_link_ksettings link_ksettings;
> +
> +		ethtool_params_from_link_mode(&link_ksettings, mode);
> +
> +		if (attr == &dev_attr_link_10.attr &&
> +		    link_ksettings.base.speed == SPEED_10)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_100.attr &&
> +		    link_ksettings.base.speed == SPEED_100)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_1000.attr &&
> +		    link_ksettings.base.speed == SPEED_1000)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_2500.attr &&
> +		    link_ksettings.base.speed == SPEED_2500)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_5000.attr &&
> +		    link_ksettings.base.speed == SPEED_5000)
> +			return attr->mode;
> +
> +		if (attr == &dev_attr_link_10000.attr &&
> +		    link_ksettings.base.speed == SPEED_10000)
> +			return attr->mode;

Hi Christian,

ugly code repetition. Use a macro or a switch or something.

Marek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ