lkml.org 
[lkml]   [2007]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: (trivia) remove useless typecast around `jif' variable
Jan Engelhardt wrote:
> On Mar 5 2007 19:12, Michael Tokarev wrote:
>
>> Date: Mon, 5 Mar 2007 19:12:51 +0300 (MSK)
>> From: Michael Tokarev <mjt@tls.msk.ru>
>> To: undisclosed-recipients: ;
>
> I have no clue what you sent it to, so I added linux-kernel again.

Oops.. I forgot to add the To: header (it was only sent to lkml).
][
> In case we wanted to use different types, we would also have to
> change the accompanying %lu into %llu. Only changing jif to u64 will
> cause a problem, as the compiler does _not_ automatically
> promote/demote types in varargs that already have a certain size. In
> other words,

Sure thing, the change will be needed. But the thing is - with the
cast in place, compiler will be completely silent, while w/o the cast
it will produce a warning (or at least it's able to).

Generally, casts are bad, that's the point. Especially redundrand
ones like here.

As a side note, I dislike when people remove casts from functions
returning void*. For example,

struct somestruct *foo;

foo = (struct somestruct *)kmalloc(sizeof(struct somestruct));

With the cast in place, the compiler will warn if somestruct will
be changed to something else, but without the cast, the compiler
will happily accept the (now wrong) line.

[]
> will throw a warning (rightfully if you ask me).

Yes, that's what i was referring to when said "let the compiler
do some work for us".

/mjt
-
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: 2007-03-05 21:21    [W:3.654 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site