[PATCH 1/8 V2] staging: rtl8192e: Remove typedefs - Part I

Joe Perches joe at perches.com
Mon Jul 18 15:12:25 UTC 2011


On Mon, 2011-07-18 at 09:33 -0500, Larry Finger wrote:
> On 07/17/2011 10:53 PM, Joe Perches wrote:
> > On Sun, 2011-07-17 at 22:19 -0500, Larry Finger wrote:
> >> As part of the cleanup of the driver, typedef statements are removed.
> > Please separate the changes by specific struct.
> > What you've done makes it a bit hard to verify.
> > For instance:
> >> @@ -117,15 +116,15 @@ void Dot11d_Reset(struct rtllib_device *ieee)
> >>   void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr,
> >>   	                    u16 CoutryIeLen, u8* pCoutryIe)
> >>   {
> >> -	PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
> >> +	struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev);
> >>   	u8 i, j, NumTriples, MaxChnlNum;
> >> -	PCHNL_TXPOWER_TRIPLE pTriple;
> >> +	struct chnl_txpower_triple *pTriple;
> > []
> >> @@ -146,7 +145,7 @@ void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr,
> >>   			MaxChnlNum = pTriple->FirstChnl + j;
> >>   		}
> >> -		pTriple = (PCHNL_TXPOWER_TRIPLE)((u8*)pTriple + 3);
> >> +		pTriple = pTriple + 3;
> > Not the same code.
> I don't think the casts are needed. Is that wrong?

Yes.  Pointer addition is not normal addition,
it's like array indexing.

"pointer + integer" is the same as
"pointer + (integer * sizeof(*pointer))"

The original code is just defective and unreadable
because the CHNL_TXPOWER_TRIPLE struct isn't packed
and could be any size.

-typedef struct _CHNL_TXPOWER_TRIPLE {
+struct chnl_txpower_triple {
        u8 FirstChnl;
        u8  NumChnls;
        u8  MaxTxPowerInDbm;
-} CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE;
+};

Anyway, the right code in a separate patch should
probably be pTriple++;

> > Sorry, I'm not going to check the rest of the code
> > until this sort of thing is a bit easier to read.
> I made the changes by editing the patch files. That was easiest for me.
> If you really want about 200 patches, then that is what I will supply.

If you do the changes without other modifications
via a tool like coccinelle, then there shouldn't
be any other changes.

It's the other changes that can be an issue.

Those other changes like this pointer conversion
should be in separate patches.




More information about the devel mailing list