1
0
mirror of https://github.com/veggiedefender/torrent-client.git synced 2025-11-06 09:29:16 +02:00

Merge pull request #7 from uxlsl/master

fix shift count type int, must be unsigned integer
This commit is contained in:
Jesse Li
2021-02-22 22:51:44 -05:00
committed by GitHub

View File

@@ -10,7 +10,7 @@ func (bf Bitfield) HasPiece(index int) bool {
if byteIndex < 0 || byteIndex >= len(bf) { if byteIndex < 0 || byteIndex >= len(bf) {
return false return false
} }
return bf[byteIndex]>>(7-offset)&1 != 0 return bf[byteIndex]>>uint(7-offset)&1 != 0
} }
// SetPiece sets a bit in the bitfield // SetPiece sets a bit in the bitfield
@@ -22,5 +22,5 @@ func (bf Bitfield) SetPiece(index int) {
if byteIndex < 0 || byteIndex >= len(bf) { if byteIndex < 0 || byteIndex >= len(bf) {
return return
} }
bf[byteIndex] |= 1 << (7 - offset) bf[byteIndex] |= 1 << uint(7 - offset)
} }