PROBLEM: compiler warning from cryptic pointer math
(Using the format from REPORTING-BUGS...)
[1.] compiler warning from cryptic pointer math
[2.] This change simplifies a cryptic macro in fs/readdir.c. Rather than subtracting an uninitialized pointer's d_name field address from the uninitialized pointer base to get the field offset, we just use the normal "offsetof" idiom to directly get the d_name field address from a pointer to zero. We can't use offsetof directly since the variable type we have handy is a pointer, not the structure type itself.
(Our compiler is a gcc-alike that can figure out that it doesn't need to warn about things like "foo - foo" for an uninitialized pointer foo, but the field reference makes it think the pointer is truly being used; the warning made me look more closely at this piece of code.)
[4.] The kernel version is 2.6.17.1.
[X.]
u/cmetcalf/linux/fs/readdir.c 2006-06-23 10:09:07.000000000 -0400 renamed from tmp/tmp.3955.0 2006-06-23 10:10:54.000000000 -0400 +1 -1
@@ -51,7 +51,7 @@ * anyway. Thus the special "fillonedir()" function for that * case (the low-level handlers don't need to care about this). */ -#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) +#define NAME_OFFSET(de) ((int) ((typeof(de))0)->d_name)
#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
#ifdef __ARCH_WANT_OLD_READDIR
Signature · 2 lines
Chris Metcalf, Tilera Corp. http://www.tilera.com