[lkml]   [1997]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRFC - addition to Documentation/CodingStyle
    I'd like to add the following to CodingStyle, either at the end of
    chapter 3 (naming) or as a standlone chapter (scoping). Any comments?

    ============= start

    Only variables and functions that are used by another source should be
    declared as global. Variables and functions that are only used by the
    current source should be declared as static. Declaring a name as
    static has several advantages :-

    It makes it obvious that it is only used in the current source. No
    need to hunt through the rest of the kernel to see if any other code
    refers to the name.

    The compiler will flag unused static variables, it cannot flag unused
    global variables.

    It greatly reduces the chance that two sources will have the same
    global symbol. Otherwise the linker complains about multiply defined

    No need to define static names in header files, reducing the cross
    source impact of a change.

    To save space on rescue and install disks, modules may be stripped.
    Static names can be removed (saving space), global ones cannot.

    ============= end

    A note on that last point. At the moment it is not really safe to
    strip modules. Some modules already define the insmod target variables
    as static. Blindly stripping such a module deletes the static symbols
    and insmod does not work very well.

    With the addition of MODULE_PARM, it is now safe to define the insmod
    variables and functions (including init_module and cleanup_module) as
    static. Then do a selective strip of the module, discarding most
    static names and keeping those required by insmod. A script to do this
    is being tested at the moment.

     \ /
      Last update: 2005-03-22 13:38    [W:0.017 / U:48.564 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site