Re: [PATCH] reduce syslog clutter (take 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Randy.Dunlap wrote:

>> +#if defined(CONFIG_MODULES) && defined(THIS_MODULE)
>> +#define KMSG_LOCATION_PREFIX THIS_MODULE ? THIS_MODULE->name : __FILE__
>
> Can we get parens around the expression, please?

Will do.

> and does it make sense to test
> #if defined(THIS_MODULE)
> #define KMSG_LOCATION_PREFIX (THIS_MODULE ? ...

Unfortunately, it does.

> If that does make sense (the double testing of THIS_MODULE),
> please explain why it does.

We have the following cases:

- compiling without module support, source file not including linux/module.h
  -> !defined(CONFIG_MODULES) && !defined(THIS_MODULE)
   -> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
      fails with undefined symbol THIS_MODULE

- compiling with module support, source file not including linux/module.h
  -> defined(CONFIG_MODULES) && !defined(THIS_MODULE)
   -> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
      fails with undefined symbol THIS_MODULE

- compiling without module support, source file including linux/module.h
  -> !defined(CONFIG_MODULES) && defined(THIS_MODULE)
   -> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
      fails because THIS_MODULE is defined as a NULL pointer to
      struct module which in this case is an incomplete type (*sigh*)

- compiling with module support, source file including linux/module.h,
  not compiling as a module
  -> defined(CONFIG_MODULES) && defined(THIS_MODULE)
     && THIS_MODULE == ((struct module *)0)
   -> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
      succeeds (hooray), but THIS_MODULE is a NULL pointer, though this
      time the type it points to is at least completely defined

- compiling with module support, source file including linux/module.h,
  compiling as a module
  -> defined(CONFIG_MODULES) && defined(THIS_MODULE)
     && THIS_MODULE == &__this_module
   -> compiling the expression (THIS_MODULE ? THIS_MODULE->name : __FILE__)
      succeeds and THIS_MODULE can actualy be dereferenced

I would like the code to compile and run successfully in all these cases.

--
Tilman Schmidt                    E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux