diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-29 17:56:46 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-29 18:03:21 +0000 |
commit | 987a4a0be9978e568d736801f281791e54928ca3 (patch) | |
tree | 128c09cce15d896558eea120394379751657634b /src/libutil | |
parent | 8d51d38e4ccf2ca0fa0b0471b32531fe287e38a4 (diff) | |
parent | 58bc3b65789a6c1216abb0dfb4f553b2a6b7f479 (diff) |
Merge remote-tracking branch 'upstream/master' into hash-always-has-type
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/hash.cc | 16 | ||||
-rw-r--r-- | src/libutil/hash.hh | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 70a18f9a0..e060700d9 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -104,6 +104,7 @@ static string printHash32(const Hash & hash) string printHash16or32(const Hash & hash) { + assert(hash.type); return hash.to_string(hash.type == htMD5 ? Base16 : Base32, false); } @@ -365,14 +366,15 @@ HashType parseHashType(std::string_view s) string printHashType(HashType ht) { switch (ht) { - case htMD5: return "md5"; break; - case htSHA1: return "sha1"; break; - case htSHA256: return "sha256"; break; - case htSHA512: return "sha512"; break; + case htMD5: return "md5"; + case htSHA1: return "sha1"; + case htSHA256: return "sha256"; + case htSHA512: return "sha512"; + default: + // illegal hash type enum value internally, as opposed to external input + // which should be validated with nice error message. + abort(); } - // illegal hash type enum value internally, as opposed to external input - // which should be validated with nice error message. - abort(); } } diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index b51850ccf..a55295912 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -10,7 +10,7 @@ namespace nix { MakeError(BadHash, Error); -enum HashType : char { htMD5, htSHA1, htSHA256, htSHA512 }; +enum HashType : char { htMD5 = 42, htSHA1, htSHA256, htSHA512 }; const int md5HashSize = 16; |