[PATCH] D45322: [libFuzzer] Print a correct error message when a director can't be opened

Alex Gaynor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 5 06:53:59 PDT 2018


alex created this revision.
alex added a reviewer: kcc.
Herald added subscribers: Sanitizers, llvm-commits, delcypher.

Currently if the directory cannot be opened for a reason other than non-existence (e.g. too many open file descriptors) the error message printed is incredibly confusing.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D45322

Files:
  lib/fuzzer/FuzzerIOPosix.cpp
  test/fuzzer/fuzzer-dirs.test


Index: test/fuzzer/fuzzer-dirs.test
===================================================================
--- test/fuzzer/fuzzer-dirs.test
+++ test/fuzzer/fuzzer-dirs.test
@@ -17,5 +17,5 @@
 RUN: rm -rf %t/SUB1
 
 RUN: not %t-SimpleTest NONEXISTENT_DIR 2>&1 | FileCheck %s --check-prefix=NONEXISTENT_DIR
-NONEXISTENT_DIR: No such directory: NONEXISTENT_DIR; exiting
+NONEXISTENT_DIR: No such file or directory: NONEXISTENT_DIR; exiting
 
Index: lib/fuzzer/FuzzerIOPosix.cpp
===================================================================
--- lib/fuzzer/FuzzerIOPosix.cpp
+++ lib/fuzzer/FuzzerIOPosix.cpp
@@ -54,7 +54,7 @@
 
   DIR *D = opendir(Dir.c_str());
   if (!D) {
-    Printf("No such directory: %s; exiting\n", Dir.c_str());
+    Printf("%s: %s; exiting\n", strerror(errno), Dir.c_str());
     exit(1);
   }
   while (auto E = readdir(D)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45322.141150.patch
Type: text/x-patch
Size: 851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180405/f38af5c5/attachment.bin>


More information about the llvm-commits mailing list