[Openmp-commits] [openmp] 50a95e3 - [OpenMP] Minor improvement in error msg and fixes few coverity reported issues

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


Author: Nawrin Sultana
Date: 2023-07-05T12:07:51-05:00
New Revision: 50a95e3e6bab6edfd99386cc2b9950dfc211dea4

URL: https://github.com/llvm/llvm-project/commit/50a95e3e6bab6edfd99386cc2b9950dfc211dea4
DIFF: https://github.com/llvm/llvm-project/commit/50a95e3e6bab6edfd99386cc2b9950dfc211dea4.diff

LOG: [OpenMP] Minor improvement in error msg and fixes few coverity reported issues

Differential Revision: https://reviews.llvm.org/D152289

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_affinity.h b/openmp/runtime/src/kmp_affinity.h
index e685e2cee7a2d7..f27dd9a5339e86 100644
--- a/openmp/runtime/src/kmp_affinity.h
+++ b/openmp/runtime/src/kmp_affinity.h
@@ -62,7 +62,8 @@ class KMPHwlocAffinity : public KMPAffinity {
       }
       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 @@ class KMPHwlocAffinity : public KMPAffinity {
       }
       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 @@ class KMPHwlocAffinity : public KMPAffinity {
           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 @@ class KMPNativeAffinity : public KMPAffinity {
       }
       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 @@ class KMPNativeAffinity : public KMPAffinity {
       }
       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;
     }

diff  --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 03956acdcb055e..0154ee064faf3a 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -405,6 +405,8 @@ void __kmp_print_storage_map_gtid(int gtid, void *p1, void *p2, size_t size,
   }
 #endif /* KMP_PRINT_DATA_PLACEMENT */
   __kmp_release_bootstrap_lock(&__kmp_stdio_lock);
+
+  va_end(ap);
 }
 
 void __kmp_warn(char const *format, ...) {

diff  --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index 181db20a5f58d1..eb92de11333b2b 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -1467,7 +1467,7 @@ static void __kmp_stg_print_max_task_priority(kmp_str_buf_t *buffer,
 // 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

diff  --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 95c9e97b37fa77..260b982af200e5 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -1849,10 +1849,13 @@ int __kmp_read_from_file(char const *path, char const *format, ...) {
 
   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;
 }


        


More information about the Openmp-commits mailing list