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] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B6EFE@saturn3.aculab.com>
Date:	Wed, 2 May 2012 09:44:22 +0100
From:	"David Laight" <David.Laight@...LAB.COM>
To:	"Linus Walleij" <linus.walleij@...aro.org>,
	<netdev@...r.kernel.org>, <linux-usb@...r.kernel.org>,
	"Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
	"David S. Miller" <davem@...emloft.net>,
	"Felipe Balbi" <balbi@...com>
Cc:	"Jussi Kivilinna" <jussi.kivilinna@...et.fi>,
	"Haiyang Zhang" <haiyangz@...rosoft.com>,
	"Wei Yongjun" <yongjun_wei@...ndmicro.com.cn>,
	"Ben Hutchings" <ben@...adent.org.uk>
Subject: RE: [PATCH 01/14 v3] usb/net: rndis: inline the cpu_to_le32() macro

> -----Original Message-----
> From: netdev-owner@...r.kernel.org 
> [mailto:netdev-owner@...r.kernel.org] On Behalf Of Linus Walleij
> Sent: 01 May 2012 19:15
> To: netdev@...r.kernel.org; linux-usb@...r.kernel.org; Greg 
> Kroah-Hartman; David S. Miller; Felipe Balbi
> Cc: Jussi Kivilinna; Haiyang Zhang; Wei Yongjun; Ben 
> Hutchings; Linus Walleij
> Subject: [PATCH 01/14 v3] usb/net: rndis: inline the 
> cpu_to_le32() macro
> 
> The header file <linux/usb/rndis_host.h> used a number of #defines
> that included the cpu_to_le32() macro to assure the result will be
> in LE endianness. Inlining this into the code instead of using it
> in the code definitions yields consolidation opportunities later
> on as you will see in the following patches. The individual
> drivers also used local defines - all are switched over to the
> pattern of doing the conversion at the call sites instead.
> 
> Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
> ---
>  drivers/net/usb/rndis_host.c      |   52 +++++++-------
>  drivers/net/wireless/rndis_wlan.c |  138 
> +++++++++++++++++++------------------
>  include/linux/usb/rndis_host.h    |   84 +++++++++++-----------
>  3 files changed, 139 insertions(+), 135 deletions(-)
> 
> diff --git a/drivers/net/usb/rndis_host.c 
> b/drivers/net/usb/rndis_host.c
> index c8f1b5b..05cad0b 100644
> --- a/drivers/net/usb/rndis_host.c
> +++ b/drivers/net/usb/rndis_host.c
> @@ -78,10 +78,10 @@ static void rndis_msg_indicate(struct 
> usbnet *dev, struct rndis_indicate *msg,
>  		dev->driver_info->indication(dev, msg, buflen);
>  	} else {
>  		switch (msg->status) {
> -		case RNDIS_STATUS_MEDIA_CONNECT:
> +		case cpu_to_le32(RNDIS_STATUS_MEDIA_CONNECT):
>  			dev_info(udev, "rndis media connect\n");
>  			break;

I don't actually see how this helps!
It seems to make the code more unreadable and more likely to
be wrong (due to typos/coding slipups etc).
I didn't see anything in the earlier versions of the patches
where leaving the constants 'host endian' helped.

I also actually suspect that the generated code for some of the
switch statements would be better if the 'status' were byteswapped.
In particular it might allow the compiler to use a jump table
(when all the case labels are in one set of values).

	David


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ