• Gargi Sharma's avatar
    staging: lustre: lnet: Constify kernel_param_ops structure · fb1c3256
    Gargi Sharma authored
    The structure is used as an argument to module_param macro. This
    macro calls a bunch of other macros and finally assigns the instance
    of the kernel_param_ops structure to the const struct
    kernel_param_ops* field of a variable of type kernel_param. Hence,
    const can be added to the structure.
    
    Coccinelle Script:
    
    @r disable optional_qualifier@
    identifier i;
    position p;
    @@
    static struct kernel_param_ops i@p = { ... };
    
    @ok1@
    identifier r.i;
    expression e;
    position p;
    @@
    e = i@p
    
    @script:python s@
    i << r.i;
    t;
    @@
    coccinelle.t = i[10:];
    
    @ok2@
    declarer name module_param;
    expression e1,e2;
    position p;
    @@
    module_param(e1,s.t@p,e2);
    
    @bad@
    position p != {r.p,ok1.p,ok2.p};
    identifier r.i;
    @@
    e@i@p
    
    @depends on !bad disable optional_qualifier@
    identifier r.i;
    @@
    static
    +const
    struct kernel_param_ops i = { ... };
    Signed-off-by: default avatarGargi Sharma <gs051095@gmail.com>
    Reviewed-by: default avatarJames Simmons <jsimmons@infradead.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    fb1c3256
debug.c 11.6 KB