lkml.org 
[lkml]   [2005]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: RFC: turn kmalloc+memset(,0,) into kcalloc
On Tue, 5 Apr 2005, Roland Dreier wrote:

> > or simply
> > if (!(ptr = kcalloc(n, size, ...)))
> > goto out;
> > and save an additional line of screen realestate while you are at it...
>
> No, please don't do that. The general kernel style is to avoid
> assignments within conditionals.
>
It may be the prefered style to avoid assignments in conditionals, but in
that case we have a lot of cleanup to do. What I wrote above is quite
common in the current tree - a simple egrep -r "if\ *\(\!\(.+=" * in
2.6.12-rc2-mm1 will find you somewhere between 1000 and 2000 cases
scattered all over the tree.

Personally I don't see why thy should not be used. They are short, not any
harder to read (IMHO), save screen space & are quite common in userspace
code as well (so people should be used to seeing them).

If such statements are generally frawned upon then I'd suggest an addition
be made to Documentation/CodingStyle mentioning that fact, and I wonder if
patches to clean up current users would be welcome?


--
Jesper Juhl

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-04-06 13:31    [W:2.401 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site