lkml.org 
[lkml]   [2006]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] reduce syslog clutter (take 2)
    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: tilman@imap.cc
    Bonn, Germany
    Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
    Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
    [unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2006-03-09 11:18    [W:0.025 / U:0.088 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site