[Openmp-commits] [PATCH] D17909: Initialize two variables in kmp_tasking.

Samuel Antao via Openmp-commits openmp-commits at lists.llvm.org
Sat Mar 5 11:03:39 PST 2016


sfantao created this revision.
sfantao added a reviewer: jlpeyton.
sfantao added a subscriber: openmp-commits.

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.

http://reviews.llvm.org/D17909

Files:
  runtime/src/kmp_tasking.c

Index: runtime/src/kmp_tasking.c
===================================================================
--- runtime/src/kmp_tasking.c
+++ runtime/src/kmp_tasking.c
@@ -2965,7 +2965,7 @@
     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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17909.49881.patch
Type: text/x-patch
Size: 524 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20160305/548c3936/attachment.bin>


More information about the Openmp-commits mailing list