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]
Date:	Tue, 07 Aug 2007 17:56:49 -0400
From:	Jeff Garzik <jeff@...zik.org>
To:	Brian King <brking@...ux.vnet.ibm.com>
CC:	santil@...ux.vnet.ibm.com, rcjenn@...ux.vnet.ibm.com,
	netdev@...r.kernel.org, linuxppc-dev@...abs.org
Subject: Re: [PATCH 6/6] ibmveth: Remove use of bitfields

Brian King wrote:
> Removes the use of bitfields from the ibmveth driver. This results
> in slightly smaller object code.
> 
> Signed-off-by: Brian King <brking@...ux.vnet.ibm.com>
> ---
> 
>  linux-2.6-bjking1/drivers/net/ibmveth.c |   90 ++++++++++++++++----------------
>  linux-2.6-bjking1/drivers/net/ibmveth.h |   56 ++++++++-----------
>  2 files changed, 68 insertions(+), 78 deletions(-)

strong ACK :)

Though I also encourage you to avoid #defines for named constants, in 
favor of

enum {
	IBMVETH_BUF_VALID	= (1U << 31),
	IBMVETH_BUF_TOGGLE	= (1U << 30),
	IBMVETH_BUF_NO_CSUM	= (1U << 25),
	IBMVETH_BUF_CSUM_GOOD	= (1U << 24),
	IBMVETH_BUF_LEN_MASK	= 0x00FFFFFF,
};

This illustrates:

1) The "1 << n" notation is FAR easier to read and compare with data 
sheets.  You're just adding to the trouble by requiring the reviewer's 
brain to convert hex numbers to bits, even if most engineers can do this 
in their sleep.

2) The named constants are available to the C compiler, which is more 
friendly to debuggers.  It also supplies type information to the C compiler.

3) Similar to #2, wading through C pre-processor output is much easier 
when the symbols don't disappear.

These are recommendations, not requirements, but I've found these 
techniques superior to cpp in many other drivers.

	Jeff


-
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