[Openmp-commits] [openmp] r263316 - Initialize two variables in kmp_tasking.

Samuel Antao via Openmp-commits openmp-commits at lists.llvm.org
Fri Mar 11 16:55:17 PST 2016


Author: sfantao
Date: Fri Mar 11 18:55:17 2016
New Revision: 263316

URL: http://llvm.org/viewvc/llvm-project?rev=263316&view=rev
Log:
Initialize two variables in kmp_tasking.

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.

Reviewers: tlwilmar, jlpeyton

Subscribers: tlwilmar, openmp-commits

Differential Revision: http://reviews.llvm.org/D17909

Modified:
    openmp/trunk/runtime/src/kmp_tasking.c

Modified: openmp/trunk/runtime/src/kmp_tasking.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_tasking.c?rev=263316&r1=263315&r2=263316&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_tasking.c (original)
+++ openmp/trunk/runtime/src/kmp_tasking.c Fri Mar 11 18:55:17 2016
@@ -2965,7 +2965,7 @@ __kmp_taskloop_linear(ident_t *loc, int
     kmp_uint64 tc;
     kmp_uint64 lower = *lb; // compiler provides global bounds here
     kmp_uint64 upper = *ub;
-    kmp_uint64 i, num_tasks, extras;
+    kmp_uint64 i, num_tasks = 0, extras = 0;
     kmp_info_t *thread = __kmp_threads[gtid];
     kmp_taskdata_t *current_task = thread->th.th_current_task;
     kmp_task_t *next_task;




More information about the Openmp-commits mailing list