aboutsummaryrefslogtreecommitdiff
path: root/find.cc
diff options
context:
space:
mode:
Diffstat (limited to 'find.cc')
-rw-r--r--find.cc32
1 files changed, 22 insertions, 10 deletions
diff --git a/find.cc b/find.cc
index 6712923..2af242b 100644
--- a/find.cc
+++ b/find.cc
@@ -35,6 +35,14 @@
#include "strutil.h"
#include "timeutil.h"
+#define FIND_WARN_LOC(...) do { \
+ if (g_flags.werror_find_emulator) { \
+ ERROR_LOC(__VA_ARGS__); \
+ } else { \
+ WARN_LOC(__VA_ARGS__); \
+ } \
+ } while (0)
+
class FindCond {
public:
virtual ~FindCond() = default;
@@ -261,9 +269,9 @@ class DirentDirNode : public DirentNode {
vector<string>& out) const override {
ScopedReadDirTracker srdt(this, *path, cur_read_dirs);
if (!srdt.ok()) {
- WARN_LOC(loc, "FindEmulator: find: File system loop detected; `%s' "
- "is part of the same file system loop as `%s'.",
- path->c_str(), srdt.conflicted().c_str());
+ FIND_WARN_LOC(loc, "FindEmulator: find: File system loop detected; `%s' "
+ "is part of the same file system loop as `%s'.",
+ path->c_str(), srdt.conflicted().c_str());
return true;
}
@@ -368,8 +376,8 @@ class DirentSymlinkNode : public DirentNode {
if (fc.follows_symlinks && errno_ != ENOENT) {
if (errno_) {
if (fc.type != FindCommandType::FINDLEAVES) {
- WARN_LOC(loc, "FindEmulator: find: `%s': %s",
- path->c_str(), strerror(errno_));
+ FIND_WARN_LOC(loc, "FindEmulator: find: `%s': %s",
+ path->c_str(), strerror(errno_));
}
return true;
}
@@ -687,7 +695,11 @@ class FindCommandParser {
StringPiece dir= tok.substr(strlen("--dir="));
fc_->finddirs.push_back(dir.as_string());
} else if (HasPrefix(tok, "--")) {
- WARN("Unknown flag in findleaves.py: %.*s", SPF(tok));
+ if (g_flags.werror_find_emulator) {
+ ERROR("Unknown flag in findleaves.py: %.*s", SPF(tok));
+ } else {
+ WARN("Unknown flag in findleaves.py: %.*s", SPF(tok));
+ }
return false;
} else {
findfiles.push_back(tok.as_string());
@@ -826,8 +838,8 @@ class FindEmulatorImpl : public FindEmulator {
if (should_fallback)
return false;
if (!fc.redirect_to_devnull) {
- WARN_LOC(loc, "FindEmulator: cd: %.*s: No such file or directory",
- SPF(fc.chdir));
+ FIND_WARN_LOC(loc, "FindEmulator: cd: %.*s: No such file or directory",
+ SPF(fc.chdir));
}
return true;
}
@@ -850,8 +862,8 @@ class FindEmulatorImpl : public FindEmulator {
return false;
}
if (!fc.redirect_to_devnull) {
- WARN_LOC(loc, "FindEmulator: find: `%s': No such file or directory",
- ConcatDir(fc.chdir, finddir).c_str());
+ FIND_WARN_LOC(loc, "FindEmulator: find: `%s': No such file or directory",
+ ConcatDir(fc.chdir, finddir).c_str());
}
continue;
}