Re: [PATCH 04/20] staging: brcm80211: various __iomem additions to softmac.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 10, 2011 at 04:23:28PM +0200, Rafał Miłecki wrote:
> > -#define CCREGS_FAST(si) (((char *)((si)->curmap) + PCI_16KB0_CCREGS_OFFSET))
> > +#define CCREGS_FAST(si) (((char __iomem *)((si)->curmap) + \
> > +                         PCI_16KB0_CCREGS_OFFSET))
> 
> I've a question (not to just you), should we prefer u8/u16/u32 types in code?
> If so, you could think to changing this since you already touch this code.
> 

The char is just so that the addition works, the caller will have to
cast it again.  It's up to the author to decide.

If you're going to be doing bitwise operations then you can run into
signedness bugs using char.

	printf("0x%x\n", (int) 0 | (char) -1);       /* 0xffffffff */
	printf("0x%x\n", (int) 0 | (unsigned char) -1);    /* 0xff */

Also if you are going to save hex digits to it, then it should be u8.
You occasionally see bugs like this:

	char x = 0xff;

	if (x == 0xff)
		printf("dead code here.\n");
	else
		printf("signed chars only reach up to 0x7f\n");

regards,
dan carpenter
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux