Correct int32 types to uint32

develop
Michael Yang 2014-01-15 21:03:03 -05:00
rodzic bd8bfe8f50
commit df4dab050b
4 zmienionych plików z 12 dodań i 12 usunięć

Wyświetl plik

@ -36,7 +36,7 @@ func init() {
}
}
func ByteInt(buf []byte, base uint) (i int32, err error) {
func ByteInt(buf []byte, base uint) (i uint32, err error) {
if len(buf) > BytesPerInt {
err = errors.New("byte integer: invalid []byte length")
return
@ -48,24 +48,24 @@ func ByteInt(buf []byte, base uint) (i int32, err error) {
return
}
i = (i << base) | int32(b)
i = (i << base) | uint32(b)
}
return
}
func SynchInt(buf []byte) (i int32, err error) {
func SynchInt(buf []byte) (i uint32, err error) {
i, err = ByteInt(buf, SynchByteLength)
return
}
func NormInt(buf []byte) (i int32, err error) {
func NormInt(buf []byte) (i uint32, err error) {
i, err = ByteInt(buf, NormByteLength)
return
}
func IntBytes(n int32, base uint) []byte {
mask := int32(1<<base - 1)
func IntBytes(n uint32, base uint) []byte {
mask := uint32(1<<base - 1)
bytes := make([]byte, BytesPerInt)
for i, _ := range bytes {
@ -76,11 +76,11 @@ func IntBytes(n int32, base uint) []byte {
return bytes
}
func SynchBytes(n int32) []byte {
func SynchBytes(n uint32) []byte {
return IntBytes(n, SynchByteLength)
}
func NormBytes(n int32) []byte {
func NormBytes(n uint32) []byte {
return IntBytes(n, NormByteLength)
}

Wyświetl plik

@ -99,7 +99,7 @@ func (t Tag) RealSize() int {
func (t *Tag) changeSize(diff int) {
if d := int(t.padding) - diff; d < 0 {
t.padding = 0
t.size += int32(-d)
t.size += uint32(-d)
} else {
t.padding = uint(d)
}
@ -312,7 +312,7 @@ type Header struct {
compression bool
experimental bool
extendedHeader bool
size int32
size uint32
}
func (h Header) Version() string {

Wyświetl plik

@ -125,7 +125,7 @@ func V22Bytes(f Framer) []byte {
headBytes := make([]byte, V22FrameHeaderSize)
copy(headBytes[:3], []byte(f.Id()))
copy(headBytes[3:6], encodedbytes.NormBytes(int32(f.Size()))[1:])
copy(headBytes[3:6], encodedbytes.NormBytes(uint32(f.Size()))[1:])
return append(headBytes, f.Bytes()...)
}

Wyświetl plik

@ -153,7 +153,7 @@ func V23Bytes(f Framer) []byte {
headBytes := make([]byte, FrameHeaderSize)
copy(headBytes[:4], []byte(f.Id()))
copy(headBytes[4:8], encodedbytes.NormBytes(int32(f.Size())))
copy(headBytes[4:8], encodedbytes.NormBytes(uint32(f.Size())))
headBytes[8] = f.StatusFlags()
headBytes[9] = f.FormatFlags()