[Beignet] *** SPAM LEVEL 4.053 *** [PATCH 1/2] Use access() instead of fopen() to search for PCH

Simon Richter Simon.Richter at hogyros.de
Thu Jul 25 01:31:42 PDT 2013


Since all we want to do is find out whether the file exists and can be
read, use the appropriate function.

Signed-off-by: Simon Richter <Simon.Richter at hogyros.de>
---
 backend/src/backend/program.cpp |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 20bdcec..26c22f3 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -37,6 +37,7 @@
 #include <fstream>
 #include <dlfcn.h>
 #include <sstream>
+#include <unistd.h>
 
 /* Not defined for LLVM 3.0 */
 #if !defined(LLVM_VERSION_MAJOR)
@@ -258,10 +259,8 @@ namespace gbe {
       std::istringstream idirs(dirs);
 
       while (getline(idirs, pchHeaderName, ';')) {
-        FILE *pchFile = fopen(pchHeaderName.c_str(), "r");
-        if (pchFile != NULL) {
+        if(access(pchHeaderName.c_str(), R_OK) == 0) {
           usePCH = true;
-          fclose(pchFile);
           break;
         }
       }
-- 
1.7.10.4



More information about the Beignet mailing list