Re: The great alpha compile warning hunt

B. James Phillippe (bryan@terran.org)
Thu, 22 Jul 1999 10:49:05 -0700 (PDT)


On Thu, 22 Jul 1999, Sean Hunter wrote:

> I'm busy trying to track down and eliminate a stack of warnings from
> kernel compiles on Alpha. As you know, a lot of these are trivial
> warnings just caused by people making intel assumptions.
>
> 1)size_t == int

IMO the problem is rooted at the definition of size_t to "unsigned int" for
x86 and "unsigned long" for AXP. It should have been "unsigned long" for
each. The two types are the same size on Intel, so nothing lost there.
However, then you could fixup printk simply by specifing %lu for values of
size_t.

I think the size difference in native types is a lesser portability issue
than when people choose different types to represent the same value.

Maybe it's too late to change, and cast in iron to user-space already, like
libc.

> What's the normal way to fix these sorts of things? Is an explicit
> cast eg:
...
> printk(KERN_WARNING "NFS: nr=%d, slots=%d, len=%d\n",
> - nr, (end - p), len);
> + nr, (int)(end - p), len);
...
> ...the approved method? I think this is quite ugly, but have done it
> for all the offending printk's in my config.

This is right. Because "%d" translates to "int" for printk, you must cast
the argument to int no matter what platform you're on (even Intel!) if the
size_t is not defined as int. If size_t were "unsigned long" on all
arches, you could use %lu for printk and never need a cast or get a
compiler warning.

cheers,
-bp

--
# bryan at terran dot org
# http://www.terran.org/~bryan

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