This is an archive of the discontinued LLVM Phabricator instance.

Initialize two variables in kmp_tasking.
ClosedPublic

Authored by sfantao on Mar 5 2016, 11:03 AM.

Details

Summary

Two initialized local variables are causing clang to produce warnings:

./src/projects/openmp/runtime/src/kmp_tasking.c:3019:5: error: variable 'num_tasks' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
    default:
    ^~~~~~~
./src/projects/openmp/runtime/src/kmp_tasking.c:3027:21: note: uninitialized use occurs here
    for( i = 0; i < num_tasks; ++i ) {
                    ^~~~~~~~~
./src/projects/openmp/runtime/src/kmp_tasking.c:2968:28: note: initialize the variable 'num_tasks' to silence this warning
    kmp_uint64 i, num_tasks, extras;
                           ^
                            = 0
./src/projects/openmp/runtime/src/kmp_tasking.c:3019:5: error: variable 'extras' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
    default:
    ^~~~~~~
./src/projects/openmp/runtime/src/kmp_tasking.c:3022:52: note: uninitialized use occurs here
    KMP_DEBUG_ASSERT(tc == num_tasks * grainsize + extras);
                                                   ^~~~~~
./src/projects/openmp/runtime/src/kmp_debug.h:62:60: note: expanded from macro 'KMP_DEBUG_ASSERT'
        #define KMP_DEBUG_ASSERT( cond )       KMP_ASSERT( cond )
                                                           ^
./src/projects/openmp/runtime/src/kmp_debug.h:60:51: note: expanded from macro 'KMP_ASSERT'
        #define KMP_ASSERT( cond )             ( (cond) ? 0 : __kmp_debug_assert( #cond, __FILE__, __LINE__ ) )
                                                  ^
./src/projects/openmp/runtime/src/kmp_tasking.c:2968:36: note: initialize the variable 'extras' to silence this warning
    kmp_uint64 i, num_tasks, extras;
                                   ^
                                    = 0
2 errors generated.

This patch initializes these two variables.

Diff Detail

Event Timeline

sfantao updated this revision to Diff 49881.Mar 5 2016, 11:03 AM
sfantao retitled this revision from to Initialize two variables in kmp_tasking..
sfantao updated this object.
sfantao added a reviewer: jlpeyton.
sfantao added a subscriber: openmp-commits.
tlwilmar accepted this revision.Mar 11 2016, 10:23 AM
tlwilmar added a reviewer: tlwilmar.
tlwilmar added a subscriber: tlwilmar.

Looks good to me.

This revision is now accepted and ready to land.Mar 11 2016, 10:25 AM
jlpeyton accepted this revision.Mar 11 2016, 12:03 PM
jlpeyton edited edge metadata.

LGTM as well.

sfantao closed this revision.Mar 11 2016, 5:00 PM