style(tvix): Add missing braces in expressions

The previous clang-tidy invocation missed some header files, which has
now been rectified.

Change-Id: I31547754fbf52f439dc7aeefb08ab90bd50c4156
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1831
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2020-08-21 03:29:53 +01:00 committed by tazjin
parent 7edbe59c6c
commit 1443298657
16 changed files with 132 additions and 72 deletions

View file

@ -181,9 +181,10 @@ class Args {
.arity(1)
.handler([=](std::vector<std::string> ss) {
I n;
if (!absl::SimpleAtoi(ss[0], &n))
if (!absl::SimpleAtoi(ss[0], &n)) {
throw UsageError("flag '--%s' requires a integer argument",
longName);
}
fun(n);
});
}

View file

@ -111,9 +111,15 @@ static std::string printHash16(const Hash& hash) {
bool Hash::IsValidBase16(absl::string_view s) {
for (char c : s) {
if ('0' <= c && c <= '9') continue;
if ('a' <= c && c <= 'f') continue;
if ('A' <= c && c <= 'F') continue;
if ('0' <= c && c <= '9') {
continue;
}
if ('a' <= c && c <= 'f') {
continue;
}
if ('A' <= c && c <= 'F') {
continue;
}
return false;
}
return true;

View file

@ -125,8 +125,9 @@ class Pool {
/* If we're over the maximum number of instance, we need
to wait until a slot becomes available. */
while (state_->idle.empty() && state_->inUse >= state_->max)
while (state_->idle.empty() && state_->inUse >= state_->max) {
state_.wait(wakeup);
}
while (!state_->idle.empty()) {
auto p = state_->idle.back();
@ -163,10 +164,11 @@ class Pool {
void flushBad() {
auto state_(state.lock());
std::vector<ref<R>> left;
for (auto& p : state_->idle)
for (auto& p : state_->idle) {
if (validator(p)) {
left.push_back(p);
}
}
std::swap(state_->idle, left);
}
};

View file

@ -248,9 +248,10 @@ T readNum(Source& source) {
((unsigned long long)buf[4] << 32) | ((unsigned long long)buf[5] << 40) |
((unsigned long long)buf[6] << 48) | ((unsigned long long)buf[7] << 56);
if (n > std::numeric_limits<T>::max())
if (n > std::numeric_limits<T>::max()) {
throw SerialisationError("serialised integer %d is too large for type '%s'",
n, typeid(T).name());
}
return (T)n;
}

View file

@ -90,11 +90,12 @@ void processGraph(ThreadPool& pool, const std::set<T>& nodes,
{
auto graph(graph_.lock());
for (auto& ref : refs)
for (auto& ref : refs) {
if (graph->left.count(ref)) {
graph->refs[node].insert(ref);
graph->rrefs[ref].insert(node);
}
}
if (graph->refs[node].empty()) {
goto doWork;
}
@ -131,8 +132,9 @@ void processGraph(ThreadPool& pool, const std::set<T>& nodes,
pool.process();
if (!graph_.lock()->left.empty())
if (!graph_.lock()->left.empty()) {
throw Error("graph processing incomplete (cyclic reference?)");
}
}
} // namespace nix

View file

@ -434,13 +434,17 @@ static void _deletePath(int parentfd, const Path& path,
static void _deletePath(const Path& path, unsigned long long& bytesFreed) {
Path dir = dirOf(path);
if (dir == "") dir = "/";
if (dir == "") {
dir = "/";
}
AutoCloseFD dirfd(open(dir.c_str(), O_RDONLY));
if (!dirfd) {
// This really shouldn't fail silently, but it's left this way
// for backwards compatibility.
if (errno == ENOENT) return;
if (errno == ENOENT) {
return;
}
throw SysError(format("opening directory '%1%'") % path);
}

View file

@ -301,7 +301,9 @@ void setInterruptThrown();
void _interrupted();
void inline checkInterrupt() {
if (_isInterrupted || (interruptCheck && interruptCheck())) _interrupted();
if (_isInterrupted || (interruptCheck && interruptCheck())) {
_interrupted();
}
}
MakeError(Interrupted, BaseError);