Skip to contentSkip to conversation

Question about module.[c,h] - kernel 2.4.18

DISCUSSION Ron Gage 2 participants 2 messages May 12, 2002

lore
Share & tools
lore

Ron Gage

author
#0 lore raw

Hi folks:

I am in the process of doing some compile cleanups - a la kernel janitors project type stuff.

I came across a fairly major inconsistancy in module.c and module.h and I was hoping someone could tell me just how whacked my view of this is...

The code in question from module.c...

struct module kernel_module =
{

        size_of_struct:         sizeof(struct module),
        name:                   "",
        uc:                     {ATOMIC_INIT(1)},
        flags:                  MOD_RUNNING,
        syms:                   __start___ksymtab,
        ex_table_start:         __start___ex_table,
        ex_table_end:           __stop___ex_table,
        kallsyms_start:         __start___kallsyms,
        kallsyms_end:           __stop___kallsyms,

};

Looks fairly straight forward, but it is missing several elements from the module struct. The module struct is defined as follows:

struct module

{
        unsigned long size_of_struct;   /* == sizeof(module) */
        struct module *next;
        const char *name;
        unsigned long size;

        union
        {
                atomic_t usecount;
                long pad;
        } uc;                           /* Needs to keep its size - so

says rth */

        unsigned long flags;            /* AUTOCLEAN et al */

        unsigned nsyms;
        unsigned ndeps;

        struct module_symbol *syms;
        struct module_ref *deps;
        struct module_ref *refs;
        int (*init)(void);
        void (*cleanup)(void);
        const struct exception_table_entry *ex_table_start;
        const struct exception_table_entry *ex_table_end;
#ifdef __alpha__
        unsigned long gp;
#endif
        /* Members past this point are extensions to the basic
           module support and are optional.  Use mod_member_present()
           to examine them.  */
        const struct module_persist *persist_start;
        const struct module_persist *persist_end;
        int (*can_unload)(void);
        int runsize;                    /* In modutils, not currently

used */
const char *kallsyms_start; /* All symbols for kernel
debugging */
const char *kallsyms_end;
const char *archdata_start; /* arch specific data for module
*/
const char *archdata_end;
const char *kernel_data; /* Reserved for kernel internal
use */
};

In essence, there are 20 elements to the module struct (i386), but module.c only initializes 9 of those elements. This gives 11 uninitialized elements (and compile warnings). These warnings are what I am trying to kill off.

Does anyone see any problems with initializing the remaining elements of this struct?

Signature · 2 lines
Ron Gage - Saginaw, MI
([email protected])
#1 lore raw
Quoted 7 lines · Ron Gage

I came across a fairly major inconsistancy in module.c and module.h and I was hoping someone could tell me just how whacked my view of this is...
In essence, there are 20 elements to the module struct (i386), but module.c only initializes 9 of those elements. This gives 11 uninitialized elements (and compile warnings). These warnings are what I am trying to kill off.

struct module has static storage duration, all elements are automatically set to 0 unless otherwise defined.

Which compiler is giving warnings? If you are using a compiler that requires all elements of a static storage variable be initialized then it appears to be in violation of the C standard.

6.7.8 Initialization

19 The initialization shall occur in initializer list order, each
initializer provided for a particular subobject overriding any previously listed initializer for the same subobject; all subobjects that are not initialized explicitly shall be initialized implicitly the same as objects that have static storage duration.

Static storage duration objects are set to 0.