Re: mmotm 2009-04-24-18-14 uploaded - NVidia indigestion

From: Valdis . Kletnieks
Date: Mon Apr 27 2009 - 14:46:30 EST


On Sat, 25 Apr 2009 07:24:34 +0200, Nick Piggin said:

> > #include <linux/version.h>
> > #include <linux/utsname.h>
> > int main() {
> > if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) {
> > return 0;
> > } else {
> > return 1;
> > }

> Yeah BUILD_BUG_ON does work like that. I can't for the life of me
> understand why it triggered though. Is anything in your external
> code calling kmalloc_slab directly?

See above - I didn't think LINUX_VERSION_CODE cared about kmalloc, but
I could be wrong on this. ;)

> What's the preprocessor output look like?

The problem appears to be that if you only include version.h and utsname.h,
and *don't* actually reference kmalloc_slab, it doesn't know that the size_t
is actually a constant, so it whinges. Most modules end up doing at least
one kmalloc(), so kmalloc() and kmalloc_slab() get inlined, the constant 'size'
gets propogated, and life is good. If you *don't* call kmalloc(), bad things
happen. ;)

Attachment: pgp00000.pgp
Description: PGP signature