refactor(3p/nix): Apply clang-tidy's readability-* fixes

This applies the readability fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html
This commit is contained in:
Vincent Ambo 2020-05-20 22:27:37 +01:00
parent d331d3a0b5
commit 689ef502f5
78 changed files with 863 additions and 792 deletions

View file

@ -193,7 +193,7 @@ Hash::Hash(const std::string& s, HashType type) : type(type) {
if (i < hashSize - 1) {
hash[i + 1] |= digit >> (8 - j);
} else {
if (digit >> (8 - j)) {
if ((digit >> (8 - j)) != 0) {
throw BadHash("invalid base-32 hash '%s'", s);
}
}
@ -280,7 +280,7 @@ Hash hashFile(HashType ht, const Path& path) {
std::vector<unsigned char> buf(8192);
ssize_t n;
while ((n = read(fd.get(), buf.data(), buf.size()))) {
while ((n = read(fd.get(), buf.data(), buf.size())) != 0) {
checkInterrupt();
if (n == -1) {
throw SysError(format("reading file '%1%'") % path);
@ -341,7 +341,8 @@ Hash compressHash(const Hash& hash, unsigned int newSize) {
HashType parseHashType(const string& s) {
if (s == "md5") {
return htMD5;
} else if (s == "sha1") {
}
if (s == "sha1") {
return htSHA1;
} else if (s == "sha256") {
return htSHA256;
@ -355,7 +356,8 @@ HashType parseHashType(const string& s) {
string printHashType(HashType ht) {
if (ht == htMD5) {
return "md5";
} else if (ht == htSHA1) {
}
if (ht == htSHA1) {
return "sha1";
} else if (ht == htSHA256) {
return "sha256";