[Openmp-commits] [PATCH] D144601: [OpenMP] Fix the wrong use of `fopen`

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Feb 22 15:56:17 PST 2023

tianshilei1992 created this revision.
tianshilei1992 added a reviewer: sthibaul.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

This patch fixes the wrong use of `fopen`.

  rG LLVM Github Monorepo



Index: openmp/runtime/src/kmp_runtime.cpp
--- openmp/runtime/src/kmp_runtime.cpp
+++ 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>
 #include "kmp_dispatch_hier.h"
@@ -6906,12 +6905,11 @@
     // File did not open. Try the temporary file.
     use_shm = false;
-    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.
-    fd1 = fileno(tf);
   char *data1 = (char *)mmap(0, SHM_SIZE, PROT_READ, MAP_SHARED, fd1, 0);
   if (data1 != MAP_FAILED) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144601.499664.patch
Type: text/x-patch
Size: 860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230222/98d2c88a/attachment.bin>

More information about the Openmp-commits mailing list