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

Zhigang Gong zhigang.gong at linux.intel.com
Thu Jul 25 02:10:13 PDT 2013


Right, it's better. Pushed both patches, thanks.

On Thu, Jul 25, 2013 at 10:31:42AM +0200, Simon Richter wrote:
> 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
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list