[llvm-branch-commits] [openmp] 66d4cc2 - [OpenMP] Fix the wrong use of `fopen`

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Mar 9 20:47:23 PST 2023


Author: Shilei Tian
Date: 2023-03-09T20:46:51-08:00
New Revision: 66d4cc283657f4db2e52e240717b1217ac6a4303

URL: https://github.com/llvm/llvm-project/commit/66d4cc283657f4db2e52e240717b1217ac6a4303
DIFF: https://github.com/llvm/llvm-project/commit/66d4cc283657f4db2e52e240717b1217ac6a4303.diff

LOG: [OpenMP] Fix the wrong use of `fopen`

This patch fixes the wrong use of `fopen`.

Fix https://github.com/llvm/llvm-project/issues/60934

Reviewed By: jdoerfert

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

(cherry picked from commit 22cd105a664b1106e0881b821bc58099eca8cdb4)

Added: 
    

Modified: 
    openmp/runtime/src/kmp_runtime.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 7393dba90b875..88b9e58fca54c 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -24,7 +24,6 @@
 #include "kmp_wait_release.h"
 #include "kmp_wrapper_getpid.h"
 #include "kmp_dispatch.h"
-#include <cstdio>
 #if KMP_USE_HIER_SCHED
 #include "kmp_dispatch_hier.h"
 #endif
@@ -6917,12 +6916,11 @@ void __kmp_unregister_library(void) {
     // File did not open. Try the temporary file.
     use_shm = false;
     KMP_DEBUG_ASSERT(temp_reg_status_file_name);
-    FILE *tf = fopen(temp_reg_status_file_name, O_RDONLY);
-    if (!tf) {
+    fd1 = open(temp_reg_status_file_name, O_RDONLY);
+    if (fd1 == -1) {
       // give it up now.
       return;
     }
-    fd1 = fileno(tf);
   }
   char *data1 = (char *)mmap(0, SHM_SIZE, PROT_READ, MAP_SHARED, fd1, 0);
   if (data1 != MAP_FAILED) {


        


More information about the llvm-branch-commits mailing list