lkml.org 
[lkml]   [2006]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] timers, pointers to functions and type safety

* Al Viro <viro@ftp.linux.org.uk> wrote:

> > This is going to make a lot of data structures smaller, when the
> > timer_list is embedded in the structure itself and for the lot,
> > which ignores the timer callback argument anyway.
>
> container_of => still lousy type safety. All over the sodding place.

the question is: which is more important, the type safety of a
container_of() [or type cast], which if we get it wrong produces a
/very/ trivial crash that is trivial to fix - or embedded timers data
structure size all around the kernel? I believe the latter is more
important.

and we could have a runtime debugging option to tie the type of the
structure to the timer list entry. For example by using
__builtin_classify_type(), sizeof() and offsetof() to fingerprint timer
structs at init_timer time, and then checking for that at container_of()
time - or something like that. In fact, gcc should really give us a
better way to categorize types than __builtin_classify_type(). We could
probably improve the situation by having some global registry of types
known to the kernel, via a huge switch() around
__builtin_types_compatible_p().

Ingo
-
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: 2006-12-04 12:53    [W:0.078 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site