[Openmp-commits] [PATCH] D152289: [OpenMP] Minor improvement in error msg and fixes few Coverity reported issues

Nawrin Sultana via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Jul 5 10:08:26 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG50a95e3e6bab: [OpenMP] Minor improvement in error msg and fixes few coverity reported issues (authored by Nawrin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152289/new/

https://reviews.llvm.org/D152289

Files:
  openmp/runtime/src/kmp_affinity.h
  openmp/runtime/src/kmp_runtime.cpp
  openmp/runtime/src/kmp_settings.cpp
  openmp/runtime/src/z_Linux_util.cpp


Index: openmp/runtime/src/z_Linux_util.cpp
===================================================================
--- openmp/runtime/src/z_Linux_util.cpp
+++ openmp/runtime/src/z_Linux_util.cpp
@@ -1849,10 +1849,13 @@
 
   va_start(args, format);
   FILE *f = fopen(path, "rb");
-  if (f == NULL)
+  if (f == NULL) {
+    va_end(args);
     return 0;
+  }
   result = vfscanf(f, format, args);
   fclose(f);
+  va_end(args);
 
   return result;
 }
Index: openmp/runtime/src/kmp_settings.cpp
===================================================================
--- openmp/runtime/src/kmp_settings.cpp
+++ openmp/runtime/src/kmp_settings.cpp
@@ -1467,7 +1467,7 @@
 // taskloop threshold to switch from recursive to linear tasks creation
 static void __kmp_stg_parse_taskloop_min_tasks(char const *name,
                                                char const *value, void *data) {
-  int tmp;
+  int tmp = 0;
   __kmp_stg_parse_int(name, value, 0, INT_MAX, &tmp);
   __kmp_taskloop_min_tasks = tmp;
 } // __kmp_stg_parse_taskloop_min_tasks
Index: openmp/runtime/src/kmp_runtime.cpp
===================================================================
--- openmp/runtime/src/kmp_runtime.cpp
+++ openmp/runtime/src/kmp_runtime.cpp
@@ -405,6 +405,8 @@
   }
 #endif /* KMP_PRINT_DATA_PLACEMENT */
   __kmp_release_bootstrap_lock(&__kmp_stdio_lock);
+
+  va_end(ap);
 }
 
 void __kmp_warn(char const *format, ...) {
Index: openmp/runtime/src/kmp_affinity.h
===================================================================
--- openmp/runtime/src/kmp_affinity.h
+++ openmp/runtime/src/kmp_affinity.h
@@ -62,7 +62,8 @@
       }
       int error = errno;
       if (abort_on_error) {
-        __kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
+        __kmp_fatal(KMP_MSG(FunctionError, "hwloc_get_cpubind()"),
+                    KMP_ERR(error), __kmp_msg_null);
       }
       return error;
     }
@@ -76,7 +77,8 @@
       }
       int error = errno;
       if (abort_on_error) {
-        __kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
+        __kmp_fatal(KMP_MSG(FunctionError, "hwloc_set_cpubind()"),
+                    KMP_ERR(error), __kmp_msg_null);
       }
       return error;
     }
@@ -95,7 +97,8 @@
           return 0;
         error = errno;
         if (abort_on_error)
-          __kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
+          __kmp_fatal(KMP_MSG(FunctionError, "hwloc_set_cpubind()"),
+                      KMP_ERR(error), __kmp_msg_null);
       }
       return error;
     }
@@ -372,7 +375,8 @@
       }
       int error = errno;
       if (abort_on_error) {
-        __kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
+        __kmp_fatal(KMP_MSG(FunctionError, "pthread_getaffinity_np()"),
+                    KMP_ERR(error), __kmp_msg_null);
       }
       return error;
     }
@@ -392,7 +396,8 @@
       }
       int error = errno;
       if (abort_on_error) {
-        __kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
+        __kmp_fatal(KMP_MSG(FunctionError, "pthread_setaffinity_np()"),
+                    KMP_ERR(error), __kmp_msg_null);
       }
       return error;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152289.537408.patch
Type: text/x-patch
Size: 3217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230705/4ff7769d/attachment.bin>


More information about the Openmp-commits mailing list