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/hash.cc | |
parent | 8d51d38e4ccf2ca0fa0b0471b32531fe287e38a4 (diff) | |
parent | 58bc3b65789a6c1216abb0dfb4f553b2a6b7f479 (diff) |
Merge remote-tracking branch 'upstream/master' into hash-always-has-type
Diffstat (limited to 'src/libutil/hash.cc')
-rw-r--r-- | src/libutil/hash.cc | 16 |
1 files changed, 9 insertions, 7 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(); } } |