From 689ef502f5b0655c9923ed77da2ae3504630f473 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 20 May 2020 22:27:37 +0100 Subject: 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 --- third_party/nix/src/libutil/hash.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'third_party/nix/src/libutil/hash.cc') diff --git a/third_party/nix/src/libutil/hash.cc b/third_party/nix/src/libutil/hash.cc index e33c76cc9093..81d8628e972b 100644 --- a/third_party/nix/src/libutil/hash.cc +++ b/third_party/nix/src/libutil/hash.cc @@ -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 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"; -- cgit 1.4.1