Re: [PATCH 10/30] staging: nvec: Introduce new internal API for msg alloc/free

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

 



What I'm trying to explain is that kernel style is minimalist.  Focus
on writing the simplest, most readable code you can.  Kernel coders
are 10 times more likely to use "int i" than they are to use
"unsigned int i".

$ git grep "       int i;" | wc -l
13956
$ git grep "       unsigned int i;" | wc -l
1508

"int" is the default number in C and "unsigned int" has a modifier
and so it's a tiny bit special.  When you use "unsigned int" you're
drawing attention to your variable because it is not just a normal
number.  Someone reviewing that code immediately thinks, "How high
is NVEC_POOL_SIZE exactly?"  Certainly that was my thought when I
saw it declared as a size_t.

But in fact the for loop is a boring ordinary for loop.  You've
tricked the reviewers, and you've distracted them from the 5 second
sleep elsewhere in your code.

Obviously, I'm exaggerating a bit and in this case it doesn't matter
one way or the other.  Go ahead and declare it as unsigned so long
as you understand about kernel style.  Don't be clever, fancy or
special.  Don't optimize.  Don't stand out.  And don't do more work
than you have to.

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