lkml.org 
[lkml]   [2008]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Pull] Some documentation patches

On Monday 2008-03-31 16:31, Dmitri Vorobiev wrote:
>> @@ -107,8 +107,8 @@ complete. Here's the example version:
>>
>> static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
>> {
>> - loff_t *spos = (loff_t *) v;
>> - *pos = ++(*spos);
>> + loff_t *spos = v;
>> + *pos = ++*spos;
>
> Excuse me, what's the point in this change and the next one? IMO, removing
> the explicit type cast makes the code less obvious.

Why should it be less obvious? Exactly left to the (loff_t *) you
already have loff_t *, so you know where you are going from v,
whose type is also obviously visible right in the line above.
Casts can hide errors. The cast is redundant, it does not
cover up a compiler warning. Even so, casts can hide programming
errors, as in http://jengelh.hopto.org/2007/0616-nocast.php .

> Relying upon operator priorities instead of explicit
> operator grouping using parentheses can confuse people, too.

In case of *a++ I would agree -- you would need to know whether * or
++ has the higher precedence (hint: ++ has). But in ++*a it does not
matter how much precedence either has, it always means the same.
Just like an arithmetic expression "x*-5".
--
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: 2008-04-01 22:03    [W:0.048 / U:1.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site