Re: [PATCH V2 1/3] staging/rtl8192u: fix coding style problems

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

 



Hi Joe,

On Thu, Jun 21, 2012 at 4:48 AM, Joe Perches <joe@xxxxxxxxxxx> wrote:
> On Wed, 2012-06-20 at 16:08 -0700, Greg Kroah-Hartman wrote:
>> On Wed, Jun 20, 2012 at 12:35:42AM +0530, Devendra Naga wrote:
>> > fixed some of the coding style problems reported by checkpatch
> []
>> > @@ -66,11 +69,10 @@ short eprom_r(struct net_device *dev)
>> >  {
>> >     short bit;
>> >
>> > -   bit=(read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT) );
>> > +   bit = (read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT));
>> >     udelay(EPROM_DELAY);
>> >
>> > -   if(bit) return 1;
>> > -   return 0;
>> > +   return !!bit;
>>
>> Oh come on, really?  !! is more "clear" here?
>
> Depends on the reader.  !! is pretty common.
>
>> No, please be painfully obvious, that's the only way to write kernel
>> code.  Not like this.
>
> I'd just make the return a bool instead.
>
 taking another variable and assign it like bool ret = !!bit, and
returning ret?, i think this doesn't look better.
> Also, there are unnecessary parens that could
> be removed to make the code clearer.
>
> (1<<EPROM_R_SHIFT), (1<<EPROM_W_SHIFT) and
> (1<<EPROM_CK_SHIFT) could be new #defines too.
>
>
Will do.

thanks joe.


Devendra.
_______________________________________________
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