1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

fix: wrong sha1 cmp

reported by staticcheck.
This commit is contained in:
wdvxdr 2021-09-28 15:51:35 +08:00
parent d464236573
commit 83b4206b15
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
2 changed files with 2 additions and 1 deletions

View File

@ -44,6 +44,7 @@ func TestBtree(t *testing.T) {
assert2.NoError(t, bt.Close()) assert2.NoError(t, bt.Close())
bt, err = Open(f) bt, err = Open(f)
assert2.NoError(t, err)
for i, tt := range tests { for i, tt := range tests {
assert2.Equal(t, []byte(tt), bt.Get(sha[i])) assert2.Equal(t, []byte(tt), bt.Get(sha[i]))
} }

View File

@ -32,7 +32,7 @@ func cmp(a, b *byte) int64 {
if *(*uint64)(pa) != *(*uint64)(pb) { if *(*uint64)(pa) != *(*uint64)(pb) {
return int64(*(*uint64)(pa) - *(*uint64)(pb)) return int64(*(*uint64)(pa) - *(*uint64)(pb))
} }
return int64(*(*uint32)(unsafe.Add(pa, 8)) - *(*uint32)(unsafe.Add(pa, 8))) return int64(*(*uint32)(unsafe.Add(pa, 8)) - *(*uint32)(unsafe.Add(pb, 8)))
} }
func copysha1(dst *byte, src *byte) { func copysha1(dst *byte, src *byte) {