zenovich / runkit

Runkit (official PECL PHP Runkit extension)
http://pecl.php.net/runkit
Other
610 stars 136 forks source link

Fixing 'uninitialized variable' compiler error #58

Closed nateabele closed 10 years ago

nateabele commented 10 years ago

Tried compiling against a snapshot of PHP 5.6 and got the following:

/Users/nate/Projects/runkit/runkit_sandbox.c:1639:6: error: variable 'name' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
        if (callback && callback_is_true &&
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/nate/Projects/runkit/runkit_sandbox.c:1647:6: note: uninitialized use occurs here
        if (name) {
            ^~~~
/Users/nate/Projects/runkit/runkit_sandbox.c:1639:6: note: remove the '&&' if its condition is always true
        if (callback && callback_is_true &&
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/nate/Projects/runkit/runkit_sandbox.c:1639:6: error: variable 'name' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
        if (callback && callback_is_true &&
            ^~~~~~~~
/Users/nate/Projects/runkit/runkit_sandbox.c:1647:6: note: uninitialized use occurs here
        if (name) {
            ^~~~
/Users/nate/Projects/runkit/runkit_sandbox.c:1639:6: note: remove the '&&' if its condition is always true
        if (callback && callback_is_true &&
            ^~~~~~~~~~~
/Users/nate/Projects/runkit/runkit_sandbox.c:1615:12: note: initialize the variable 'name' to silence this warning
        char *name;
                  ^
                   = NULL
2 errors generated.
make: *** [runkit_sandbox.lo] Error 1

This patch allows runkit to compile successfully.

nateabele commented 10 years ago

Also: credit goes to @andreiz for putting up with my noob-ness.