Re: [Patch 14/16] Remove needless kmalloc casts in the zd1211rw drivers.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Stefan Richter <stefanr@...>
Cc: <jack@...>, <linux-kernel@...>, <trivial@...>
Date: Tuesday, July 31, 2007 - 10:09 pm

Stefan Richter wrote:

zd_addr_t is defined as
typedef u16 __nocast zd_addr_t;

The __nocast annotation forces us to use explicit casts for values of 
this type. This is really useful as we have functions which take an 
address and a value (e.g. register writes). It's very easy to get them 
in the wrong order and have a non-obvious bug. With this mechanism, 
sparse helps us avoid this.

The case with pointers may be a little unintuitive, but it's a small 
price to pay for a bug that bit us hard once before...

The number of other places we have to cast is very small due to use of 
the preprocessor. For example we have:

#define ZD_ADDR(base, offset) \
	((zd_addr_t)(((base) & ADDR_BASE_MASK) | ((offset) & ADDR_OFFSET_MASK)))

#define CTL_REG(offset)  ZD_ADDR(CR_BASE, offset)	/* byte addressing */

Then we have a few hundred registers defined in terms of CTL_REG.


For similar reasons.

Daniel
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [Patch 14/16] Remove needless kmalloc casts in the zd121..., Daniel Drake, (Tue Jul 31, 10:09 pm)