all: update repo to use the new error handling syntax (#8950)

This commit is contained in:
spaceface 2021-02-28 21:20:21 +01:00 committed by GitHub
parent b9a381f101
commit d63b7bc35a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
135 changed files with 487 additions and 468 deletions

View file

@ -147,14 +147,14 @@ fn (mut d Digest) checksum() []byte {
mut tmp := []byte{len: (64)}
tmp[0] = 0x80
if int(len) % 64 < 56 {
d.write(tmp[..56 - int(len) % 64]) or { panic(err) }
d.write(tmp[..56 - int(len) % 64]) or { panic(err.msg) }
} else {
d.write(tmp[..64 + 56 - int(len) % 64]) or { panic(err) }
d.write(tmp[..64 + 56 - int(len) % 64]) or { panic(err.msg) }
}
// Length in bits.
len <<= u64(3)
binary.big_endian_put_u64(mut tmp, len)
d.write(tmp[..8]) or { panic(err) }
d.write(tmp[..8]) or { panic(err.msg) }
if d.nx != 0 {
panic('d.nx != 0')
}
@ -181,14 +181,14 @@ pub fn sum(data []byte) []byte {
// sum256 returns the SHA256 checksum of the data.
pub fn sum256(data []byte) []byte {
mut d := new()
d.write(data) or { panic(err) }
d.write(data) or { panic(err.msg) }
return d.checksum()
}
// sum224 returns the SHA224 checksum of the data.
pub fn sum224(data []byte) []byte {
mut d := new224()
d.write(data) or { panic(err) }
d.write(data) or { panic(err.msg) }
sum := d.checksum()
sum224 := []byte{len: (size224)}
copy(sum224, sum[..size224])