lkml.org 
[lkml]   [2006]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH -mm] sys_semctl gcc 4.1 warning fix

    Oh fsck! gcc is hosed. I just tried out this BS module:

    ---
    #include <linux/module.h>

    int g = 0;

    void func_int(int *y)
    {
    *y = 0;
    }

    int warn_here(void)
    {
    int x;

    printk("x=%d\n",x);

    return 0;
    }

    int but_not_here(void)
    {
    int y;

    printk("y=%d\n",y);
    if (g) {
    func_int(&y);
    }
    return 0;
    }

    static int __init blah_init(void)
    {
    warn_here();
    but_not_here();
    return 0;
    }

    static void __exit blah_exit(void)
    {
    printk(KERN_INFO "Bye bye!\n");
    }

    module_init(blah_init);
    module_exit(blah_exit);

    MODULE_AUTHOR("My name here");
    MODULE_DESCRIPTION("blah!");
    MODULE_LICENSE("GPL");
    ---

    And this is what I got!

    CC [M] /home/rostedt/c/modules/warning.o
    /home/rostedt/c/modules/warning.c: In function 'warn_here':
    /home/rostedt/c/modules/warning.c:14: warning: 'x' is used uninitialized in this function
    Building modules, stage 2.


    Why the fsck isn't the func but_not_here not getting a warning for the
    first use of printk?? If I remove the if statement it gives me the
    warning. Hell, that if statement isn't even entered (g = 0).

    If you remove the warn_here function altogether, this module gets no
    warnings!!!

    OK, this really bothers me :(

    btw, if you are wondering. I did load the module, and here's the output
    from dmesg:

    x=-124784640
    y=-124784640

    And I even tried it with removing warn me, compiled with no warnings and
    then got this:

    y=134514958

    Huh!

    -- Steve

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-05-10 19:48    [W:0.021 / U:0.588 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site