Commit 1e542169 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent eaa81cd4
...@@ -25,7 +25,7 @@ func (p *Address) NEOEncode(data []byte) { ...@@ -25,7 +25,7 @@ func (p *Address) NEOEncode(data []byte) {
} }
func (p *Address) NEODecode(data []byte) (int, error) { func (p *Address) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
...@@ -37,13 +37,13 @@ func (p *Address) NEODecode(data []byte) (int, error) { ...@@ -37,13 +37,13 @@ func (p *Address) NEODecode(data []byte) (int, error) {
} }
p.Host = string(data[:l]) p.Host = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread0 += 4 + l
} }
if len(data) < 2 { if len(data) < 2 {
goto overflow goto overflow
} }
p.Port = binary.BigEndian.Uint16(data[0:]) p.Port = binary.BigEndian.Uint16(data[0:])
return int(nread) + 2, nil return 2 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -72,7 +72,7 @@ func (p *NodeInfo) NEOEncode(data []byte) { ...@@ -72,7 +72,7 @@ func (p *NodeInfo) NEOEncode(data []byte) {
} }
func (p *NodeInfo) NEODecode(data []byte) (int, error) { func (p *NodeInfo) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -88,7 +88,7 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) { ...@@ -88,7 +88,7 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) {
} }
p.Address.Host = string(data[:l]) p.Address.Host = string(data[:l])
data = data[l:] data = data[l:]
nread += 8 + l nread0 += 8 + l
} }
if len(data) < 2 { if len(data) < 2 {
goto overflow goto overflow
...@@ -106,7 +106,7 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) { ...@@ -106,7 +106,7 @@ func (p *NodeInfo) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.IdTimestamp = float64_NEODecode(data[10:]) p.IdTimestamp = float64_NEODecode(data[10:])
return int(nread) + 18, nil return 18 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -125,7 +125,6 @@ func (p *CellInfo) NEOEncode(data []byte) { ...@@ -125,7 +125,6 @@ func (p *CellInfo) NEOEncode(data []byte) {
} }
func (p *CellInfo) NEODecode(data []byte) (int, error) { func (p *CellInfo) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -134,7 +133,7 @@ func (p *CellInfo) NEODecode(data []byte) (int, error) { ...@@ -134,7 +133,7 @@ func (p *CellInfo) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) p.CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -163,7 +162,7 @@ func (p *RowInfo) NEOEncode(data []byte) { ...@@ -163,7 +162,7 @@ func (p *RowInfo) NEOEncode(data []byte) {
} }
func (p *RowInfo) NEODecode(data []byte) (int, error) { func (p *RowInfo) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -174,7 +173,7 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) { ...@@ -174,7 +173,7 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
p.CellList = make([]CellInfo, l) p.CellList = make([]CellInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
...@@ -187,10 +186,10 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) { ...@@ -187,10 +186,10 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) {
} }
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -214,7 +213,7 @@ func (p *Notify) NEOEncode(data []byte) { ...@@ -214,7 +213,7 @@ func (p *Notify) NEOEncode(data []byte) {
} }
func (p *Notify) NEODecode(data []byte) (int, error) { func (p *Notify) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
...@@ -226,9 +225,9 @@ func (p *Notify) NEODecode(data []byte) (int, error) { ...@@ -226,9 +225,9 @@ func (p *Notify) NEODecode(data []byte) (int, error) {
} }
p.Message = string(data[:l]) p.Message = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread0 += 4 + l
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -253,7 +252,7 @@ func (p *Error) NEOEncode(data []byte) { ...@@ -253,7 +252,7 @@ func (p *Error) NEOEncode(data []byte) {
} }
func (p *Error) NEODecode(data []byte) (int, error) { func (p *Error) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -269,9 +268,9 @@ func (p *Error) NEODecode(data []byte) (int, error) { ...@@ -269,9 +268,9 @@ func (p *Error) NEODecode(data []byte) (int, error) {
} }
p.Message = string(data[:l]) p.Message = string(data[:l])
data = data[l:] data = data[l:]
nread += 8 + l nread0 += 8 + l
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -288,8 +287,7 @@ func (p *Ping) NEOEncode(data []byte) { ...@@ -288,8 +287,7 @@ func (p *Ping) NEOEncode(data []byte) {
} }
func (p *Ping) NEODecode(data []byte) (int, error) { func (p *Ping) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -306,8 +304,7 @@ func (p *CloseClient) NEOEncode(data []byte) { ...@@ -306,8 +304,7 @@ func (p *CloseClient) NEOEncode(data []byte) {
} }
func (p *CloseClient) NEODecode(data []byte) (int, error) { func (p *CloseClient) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -343,7 +340,7 @@ func (p *RequestIdentification) NEOEncode(data []byte) { ...@@ -343,7 +340,7 @@ func (p *RequestIdentification) NEOEncode(data []byte) {
} }
func (p *RequestIdentification) NEODecode(data []byte) (int, error) { func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -367,7 +364,7 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) { ...@@ -367,7 +364,7 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
} }
p.Address.Host = string(data[:l]) p.Address.Host = string(data[:l])
data = data[l:] data = data[l:]
nread += 16 + l nread0 += 16 + l
} }
if len(data) < 2 { if len(data) < 2 {
goto overflow goto overflow
...@@ -384,13 +381,13 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) { ...@@ -384,13 +381,13 @@ func (p *RequestIdentification) NEODecode(data []byte) (int, error) {
} }
p.Name = string(data[:l]) p.Name = string(data[:l])
data = data[l:] data = data[l:]
nread += 6 + l nread0 += 6 + l
} }
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.IdTimestamp = float64_NEODecode(data[0:]) p.IdTimestamp = float64_NEODecode(data[0:])
return int(nread) + 8, nil return 8 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -444,7 +441,7 @@ func (p *AcceptIdentification) NEOEncode(data []byte) { ...@@ -444,7 +441,7 @@ func (p *AcceptIdentification) NEOEncode(data []byte) {
} }
func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -476,7 +473,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -476,7 +473,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
} }
p.Primary.Host = string(data[:l]) p.Primary.Host = string(data[:l])
data = data[l:] data = data[l:]
nread += 24 + l nread0 += 24 + l
} }
if len(data) < 2 { if len(data) < 2 {
goto overflow goto overflow
...@@ -488,7 +485,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -488,7 +485,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[2:]) l := binary.BigEndian.Uint32(data[2:])
data = data[6:] data = data[6:]
nread += 6 nread0 += 6
p.KnownMasterList = make([]struct { p.KnownMasterList = make([]struct {
Address Address
UUID UUID UUID UUID
...@@ -506,7 +503,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -506,7 +503,7 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
} }
(*a).Address.Host = string(data[:l]) (*a).Address.Host = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread0 += 4 + l
} }
if len(data) < 2 { if len(data) < 2 {
goto overflow goto overflow
...@@ -517,10 +514,10 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) { ...@@ -517,10 +514,10 @@ func (p *AcceptIdentification) NEODecode(data []byte) (int, error) {
} }
(*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[2:]))) (*a).UUID = UUID(int32(binary.BigEndian.Uint32(data[2:])))
data = data[6:] data = data[6:]
nread += 6 nread0 += 6
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -537,8 +534,7 @@ func (p *PrimaryMaster) NEOEncode(data []byte) { ...@@ -537,8 +534,7 @@ func (p *PrimaryMaster) NEOEncode(data []byte) {
} }
func (p *PrimaryMaster) NEODecode(data []byte) (int, error) { func (p *PrimaryMaster) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -556,12 +552,11 @@ func (p *AnswerPrimary) NEOEncode(data []byte) { ...@@ -556,12 +552,11 @@ func (p *AnswerPrimary) NEOEncode(data []byte) {
} }
func (p *AnswerPrimary) NEODecode(data []byte) (int, error) { func (p *AnswerPrimary) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
p.PrimaryUUID = UUID(int32(binary.BigEndian.Uint32(data[0:]))) p.PrimaryUUID = UUID(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return 4, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -578,8 +573,7 @@ func (p *AnnouncePrimary) NEOEncode(data []byte) { ...@@ -578,8 +573,7 @@ func (p *AnnouncePrimary) NEOEncode(data []byte) {
} }
func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) { func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -596,8 +590,7 @@ func (p *ReelectPrimary) NEOEncode(data []byte) { ...@@ -596,8 +590,7 @@ func (p *ReelectPrimary) NEOEncode(data []byte) {
} }
func (p *ReelectPrimary) NEODecode(data []byte) (int, error) { func (p *ReelectPrimary) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -614,8 +607,7 @@ func (p *Recovery) NEOEncode(data []byte) { ...@@ -614,8 +607,7 @@ func (p *Recovery) NEOEncode(data []byte) {
} }
func (p *Recovery) NEODecode(data []byte) (int, error) { func (p *Recovery) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -635,7 +627,6 @@ func (p *AnswerRecovery) NEOEncode(data []byte) { ...@@ -635,7 +627,6 @@ func (p *AnswerRecovery) NEOEncode(data []byte) {
} }
func (p *AnswerRecovery) NEODecode(data []byte) (int, error) { func (p *AnswerRecovery) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -648,7 +639,7 @@ func (p *AnswerRecovery) NEODecode(data []byte) (int, error) { ...@@ -648,7 +639,7 @@ func (p *AnswerRecovery) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.TruncateTID = Tid(binary.BigEndian.Uint64(data[16:])) p.TruncateTID = Tid(binary.BigEndian.Uint64(data[16:]))
return int(nread) + 24, nil return 24, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -665,8 +656,7 @@ func (p *LastIDs) NEOEncode(data []byte) { ...@@ -665,8 +656,7 @@ func (p *LastIDs) NEOEncode(data []byte) {
} }
func (p *LastIDs) NEODecode(data []byte) (int, error) { func (p *LastIDs) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -685,7 +675,6 @@ func (p *AnswerLastIDs) NEOEncode(data []byte) { ...@@ -685,7 +675,6 @@ func (p *AnswerLastIDs) NEOEncode(data []byte) {
} }
func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) { func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -694,7 +683,7 @@ func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) { ...@@ -694,7 +683,7 @@ func (p *AnswerLastIDs) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.LastTID = Tid(binary.BigEndian.Uint64(data[8:])) p.LastTID = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return 16, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -711,8 +700,7 @@ func (p *PartitionTable) NEOEncode(data []byte) { ...@@ -711,8 +700,7 @@ func (p *PartitionTable) NEOEncode(data []byte) {
} }
func (p *PartitionTable) NEODecode(data []byte) (int, error) { func (p *PartitionTable) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -757,7 +745,7 @@ func (p *AnswerPartitionTable) NEOEncode(data []byte) { ...@@ -757,7 +745,7 @@ func (p *AnswerPartitionTable) NEOEncode(data []byte) {
} }
func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) { func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -768,7 +756,7 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -768,7 +756,7 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
p.RowList = make([]RowInfo, l) p.RowList = make([]RowInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
...@@ -782,7 +770,7 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -782,7 +770,7 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
(*a).CellList = make([]CellInfo, l) (*a).CellList = make([]CellInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
...@@ -795,14 +783,14 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -795,14 +783,14 @@ func (p *AnswerPartitionTable) NEODecode(data []byte) (int, error) {
} }
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
data = data[0:] data = data[0:]
nread += 0 nread0 += 0
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -847,7 +835,7 @@ func (p *NotifyPartitionTable) NEOEncode(data []byte) { ...@@ -847,7 +835,7 @@ func (p *NotifyPartitionTable) NEOEncode(data []byte) {
} }
func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) { func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -858,7 +846,7 @@ func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -858,7 +846,7 @@ func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
p.RowList = make([]RowInfo, l) p.RowList = make([]RowInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
...@@ -872,7 +860,7 @@ func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -872,7 +860,7 @@ func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
(*a).CellList = make([]CellInfo, l) (*a).CellList = make([]CellInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
...@@ -885,14 +873,14 @@ func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -885,14 +873,14 @@ func (p *NotifyPartitionTable) NEODecode(data []byte) (int, error) {
} }
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
data = data[0:] data = data[0:]
nread += 0 nread0 += 0
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -922,7 +910,7 @@ func (p *PartitionChanges) NEOEncode(data []byte) { ...@@ -922,7 +910,7 @@ func (p *PartitionChanges) NEOEncode(data []byte) {
} }
func (p *PartitionChanges) NEODecode(data []byte) (int, error) { func (p *PartitionChanges) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -933,7 +921,7 @@ func (p *PartitionChanges) NEODecode(data []byte) (int, error) { ...@@ -933,7 +921,7 @@ func (p *PartitionChanges) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
p.CellList = make([]struct { p.CellList = make([]struct {
Offset uint32 Offset uint32
UUID UUID UUID UUID
...@@ -954,10 +942,10 @@ func (p *PartitionChanges) NEODecode(data []byte) (int, error) { ...@@ -954,10 +942,10 @@ func (p *PartitionChanges) NEODecode(data []byte) (int, error) {
} }
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[8:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[8:])))
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -975,12 +963,11 @@ func (p *StartOperation) NEOEncode(data []byte) { ...@@ -975,12 +963,11 @@ func (p *StartOperation) NEOEncode(data []byte) {
} }
func (p *StartOperation) NEODecode(data []byte) (int, error) { func (p *StartOperation) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 1 { if len(data) < 1 {
goto overflow goto overflow
} }
p.Backup = byte2bool((data[0:])[0]) p.Backup = byte2bool((data[0:])[0])
return int(nread) + 1, nil return 1, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -997,8 +984,7 @@ func (p *StopOperation) NEOEncode(data []byte) { ...@@ -997,8 +984,7 @@ func (p *StopOperation) NEOEncode(data []byte) {
} }
func (p *StopOperation) NEODecode(data []byte) (int, error) { func (p *StopOperation) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1015,8 +1001,7 @@ func (p *UnfinishedTransactions) NEOEncode(data []byte) { ...@@ -1015,8 +1001,7 @@ func (p *UnfinishedTransactions) NEOEncode(data []byte) {
} }
func (p *UnfinishedTransactions) NEODecode(data []byte) (int, error) { func (p *UnfinishedTransactions) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1044,7 +1029,7 @@ func (p *AnswerUnfinishedTransactions) NEOEncode(data []byte) { ...@@ -1044,7 +1029,7 @@ func (p *AnswerUnfinishedTransactions) NEOEncode(data []byte) {
} }
func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) { func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1055,7 +1040,7 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) { ...@@ -1055,7 +1040,7 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
p.TidList = make([]struct{ UnfinishedTID Tid }, l) p.TidList = make([]struct{ UnfinishedTID Tid }, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TidList[i] a := &p.TidList[i]
...@@ -1064,10 +1049,10 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) { ...@@ -1064,10 +1049,10 @@ func (p *AnswerUnfinishedTransactions) NEODecode(data []byte) (int, error) {
} }
(*a).UnfinishedTID = Tid(binary.BigEndian.Uint64(data[0:])) (*a).UnfinishedTID = Tid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1084,8 +1069,7 @@ func (p *LockedTransactions) NEOEncode(data []byte) { ...@@ -1084,8 +1069,7 @@ func (p *LockedTransactions) NEOEncode(data []byte) {
} }
func (p *LockedTransactions) NEODecode(data []byte) (int, error) { func (p *LockedTransactions) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1117,14 +1101,14 @@ func (p *AnswerLockedTransactions) NEOEncode(data []byte) { ...@@ -1117,14 +1101,14 @@ func (p *AnswerLockedTransactions) NEOEncode(data []byte) {
} }
func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) { func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.TidDict = make(map[Tid]Tid, l) p.TidDict = make(map[Tid]Tid, l)
m := p.TidDict m := p.TidDict
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
...@@ -1137,10 +1121,10 @@ func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) { ...@@ -1137,10 +1121,10 @@ func (p *AnswerLockedTransactions) NEODecode(data []byte) (int, error) {
} }
m[key] = Tid(binary.BigEndian.Uint64(data[8:])) m[key] = Tid(binary.BigEndian.Uint64(data[8:]))
data = data[16:] data = data[16:]
nread += 16 nread0 += 16
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1158,12 +1142,11 @@ func (p *FinalTID) NEOEncode(data []byte) { ...@@ -1158,12 +1142,11 @@ func (p *FinalTID) NEOEncode(data []byte) {
} }
func (p *FinalTID) NEODecode(data []byte) (int, error) { func (p *FinalTID) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1181,12 +1164,11 @@ func (p *AnswerFinalTID) NEOEncode(data []byte) { ...@@ -1181,12 +1164,11 @@ func (p *AnswerFinalTID) NEOEncode(data []byte) {
} }
func (p *AnswerFinalTID) NEODecode(data []byte) (int, error) { func (p *AnswerFinalTID) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1205,7 +1187,6 @@ func (p *ValidateTransaction) NEOEncode(data []byte) { ...@@ -1205,7 +1187,6 @@ func (p *ValidateTransaction) NEOEncode(data []byte) {
} }
func (p *ValidateTransaction) NEODecode(data []byte) (int, error) { func (p *ValidateTransaction) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1214,7 +1195,7 @@ func (p *ValidateTransaction) NEODecode(data []byte) (int, error) { ...@@ -1214,7 +1195,7 @@ func (p *ValidateTransaction) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[8:])) p.Tid = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return 16, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1232,12 +1213,11 @@ func (p *BeginTransaction) NEOEncode(data []byte) { ...@@ -1232,12 +1213,11 @@ func (p *BeginTransaction) NEOEncode(data []byte) {
} }
func (p *BeginTransaction) NEODecode(data []byte) (int, error) { func (p *BeginTransaction) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1255,12 +1235,11 @@ func (p *AnswerBeginTransaction) NEOEncode(data []byte) { ...@@ -1255,12 +1235,11 @@ func (p *AnswerBeginTransaction) NEOEncode(data []byte) {
} }
func (p *AnswerBeginTransaction) NEODecode(data []byte) (int, error) { func (p *AnswerBeginTransaction) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1298,7 +1277,7 @@ func (p *FinishTransaction) NEOEncode(data []byte) { ...@@ -1298,7 +1277,7 @@ func (p *FinishTransaction) NEOEncode(data []byte) {
} }
func (p *FinishTransaction) NEODecode(data []byte) (int, error) { func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1309,7 +1288,7 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) { ...@@ -1309,7 +1288,7 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
p.OIDList = make([]Oid, l) p.OIDList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OIDList[i] a := &p.OIDList[i]
...@@ -1318,7 +1297,7 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) { ...@@ -1318,7 +1297,7 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
} }
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
{ {
...@@ -1327,7 +1306,7 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) { ...@@ -1327,7 +1306,7 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.CheckedList = make([]Oid, l) p.CheckedList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CheckedList[i] a := &p.CheckedList[i]
...@@ -1336,10 +1315,10 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) { ...@@ -1336,10 +1315,10 @@ func (p *FinishTransaction) NEODecode(data []byte) (int, error) {
} }
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1358,7 +1337,6 @@ func (p *AnswerFinishTransaction) NEOEncode(data []byte) { ...@@ -1358,7 +1337,6 @@ func (p *AnswerFinishTransaction) NEOEncode(data []byte) {
} }
func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) { func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1367,7 +1345,7 @@ func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) { ...@@ -1367,7 +1345,7 @@ func (p *AnswerFinishTransaction) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[8:])) p.Tid = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return 16, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1386,7 +1364,6 @@ func (p *NotifyTransactionFinished) NEOEncode(data []byte) { ...@@ -1386,7 +1364,6 @@ func (p *NotifyTransactionFinished) NEOEncode(data []byte) {
} }
func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) { func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1395,7 +1372,7 @@ func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) { ...@@ -1395,7 +1372,7 @@ func (p *NotifyTransactionFinished) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return 16, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1414,7 +1391,6 @@ func (p *LockInformation) NEOEncode(data []byte) { ...@@ -1414,7 +1391,6 @@ func (p *LockInformation) NEOEncode(data []byte) {
} }
func (p *LockInformation) NEODecode(data []byte) (int, error) { func (p *LockInformation) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1423,7 +1399,7 @@ func (p *LockInformation) NEODecode(data []byte) (int, error) { ...@@ -1423,7 +1399,7 @@ func (p *LockInformation) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[8:])) p.Tid = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return 16, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1441,12 +1417,11 @@ func (p *AnswerLockInformation) NEOEncode(data []byte) { ...@@ -1441,12 +1417,11 @@ func (p *AnswerLockInformation) NEOEncode(data []byte) {
} }
func (p *AnswerLockInformation) NEODecode(data []byte) (int, error) { func (p *AnswerLockInformation) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Ttid = Tid(binary.BigEndian.Uint64(data[0:])) p.Ttid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1474,7 +1449,7 @@ func (p *InvalidateObjects) NEOEncode(data []byte) { ...@@ -1474,7 +1449,7 @@ func (p *InvalidateObjects) NEOEncode(data []byte) {
} }
func (p *InvalidateObjects) NEODecode(data []byte) (int, error) { func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1485,7 +1460,7 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) { ...@@ -1485,7 +1460,7 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
...@@ -1494,10 +1469,10 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) { ...@@ -1494,10 +1469,10 @@ func (p *InvalidateObjects) NEODecode(data []byte) (int, error) {
} }
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1515,12 +1490,11 @@ func (p *UnlockInformation) NEOEncode(data []byte) { ...@@ -1515,12 +1490,11 @@ func (p *UnlockInformation) NEOEncode(data []byte) {
} }
func (p *UnlockInformation) NEODecode(data []byte) (int, error) { func (p *UnlockInformation) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.TTID = Tid(binary.BigEndian.Uint64(data[0:])) p.TTID = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1538,12 +1512,11 @@ func (p *GenerateOIDs) NEOEncode(data []byte) { ...@@ -1538,12 +1512,11 @@ func (p *GenerateOIDs) NEOEncode(data []byte) {
} }
func (p *GenerateOIDs) NEODecode(data []byte) (int, error) { func (p *GenerateOIDs) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
p.NumOIDs = binary.BigEndian.Uint32(data[0:]) p.NumOIDs = binary.BigEndian.Uint32(data[0:])
return int(nread) + 4, nil return 4, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1570,14 +1543,14 @@ func (p *AnswerGenerateOIDs) NEOEncode(data []byte) { ...@@ -1570,14 +1543,14 @@ func (p *AnswerGenerateOIDs) NEOEncode(data []byte) {
} }
func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) { func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
...@@ -1586,10 +1559,10 @@ func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) { ...@@ -1586,10 +1559,10 @@ func (p *AnswerGenerateOIDs) NEODecode(data []byte) (int, error) {
} }
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1642,7 +1615,7 @@ func (p *StoreObject) NEOEncode(data []byte) { ...@@ -1642,7 +1615,7 @@ func (p *StoreObject) NEOEncode(data []byte) {
} }
func (p *StoreObject) NEODecode(data []byte) (int, error) { func (p *StoreObject) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1741,7 +1714,7 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) { ...@@ -1741,7 +1714,7 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[37:]) l := binary.BigEndian.Uint32(data[37:])
data = data[41:] data = data[41:]
nread += 41 nread0 += 41
p.Data = make([]byte, l) p.Data = make([]byte, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.Data[i] a := &p.Data[i]
...@@ -1750,7 +1723,7 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) { ...@@ -1750,7 +1723,7 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) {
} }
(*a) = (data[0:])[0] (*a) = (data[0:])[0]
data = data[1:] data = data[1:]
nread += 1 nread0 += 1
} }
} }
if len(data) < 8 { if len(data) < 8 {
...@@ -1765,7 +1738,7 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) { ...@@ -1765,7 +1738,7 @@ func (p *StoreObject) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Unlock = byte2bool((data[16:])[0]) p.Unlock = byte2bool((data[16:])[0])
return int(nread) + 17, nil return 17 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1785,7 +1758,6 @@ func (p *AnswerStoreObject) NEOEncode(data []byte) { ...@@ -1785,7 +1758,6 @@ func (p *AnswerStoreObject) NEOEncode(data []byte) {
} }
func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) { func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 1 { if len(data) < 1 {
goto overflow goto overflow
} }
...@@ -1798,7 +1770,7 @@ func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) { ...@@ -1798,7 +1770,7 @@ func (p *AnswerStoreObject) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Serial = Tid(binary.BigEndian.Uint64(data[9:])) p.Serial = Tid(binary.BigEndian.Uint64(data[9:]))
return int(nread) + 17, nil return 17, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1816,12 +1788,11 @@ func (p *AbortTransaction) NEOEncode(data []byte) { ...@@ -1816,12 +1788,11 @@ func (p *AbortTransaction) NEOEncode(data []byte) {
} }
func (p *AbortTransaction) NEODecode(data []byte) (int, error) { func (p *AbortTransaction) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1870,7 +1841,7 @@ func (p *StoreTransaction) NEOEncode(data []byte) { ...@@ -1870,7 +1841,7 @@ func (p *StoreTransaction) NEOEncode(data []byte) {
} }
func (p *StoreTransaction) NEODecode(data []byte) (int, error) { func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1886,7 +1857,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -1886,7 +1857,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
} }
p.User = string(data[:l]) p.User = string(data[:l])
data = data[l:] data = data[l:]
nread += 12 + l nread0 += 12 + l
} }
{ {
if len(data) < 4 { if len(data) < 4 {
...@@ -1899,7 +1870,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -1899,7 +1870,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
} }
p.Description = string(data[:l]) p.Description = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread0 += 4 + l
} }
{ {
if len(data) < 4 { if len(data) < 4 {
...@@ -1912,7 +1883,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -1912,7 +1883,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
} }
p.Extension = string(data[:l]) p.Extension = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread0 += 4 + l
} }
{ {
if len(data) < 4 { if len(data) < 4 {
...@@ -1920,7 +1891,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -1920,7 +1891,7 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
...@@ -1929,10 +1900,10 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) { ...@@ -1929,10 +1900,10 @@ func (p *StoreTransaction) NEODecode(data []byte) (int, error) {
} }
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1950,12 +1921,11 @@ func (p *VoteTransaction) NEOEncode(data []byte) { ...@@ -1950,12 +1921,11 @@ func (p *VoteTransaction) NEOEncode(data []byte) {
} }
func (p *VoteTransaction) NEODecode(data []byte) (int, error) { func (p *VoteTransaction) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -1975,7 +1945,6 @@ func (p *GetObject) NEOEncode(data []byte) { ...@@ -1975,7 +1945,6 @@ func (p *GetObject) NEOEncode(data []byte) {
} }
func (p *GetObject) NEODecode(data []byte) (int, error) { func (p *GetObject) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -1988,7 +1957,7 @@ func (p *GetObject) NEODecode(data []byte) (int, error) { ...@@ -1988,7 +1957,7 @@ func (p *GetObject) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[16:])) p.Tid = Tid(binary.BigEndian.Uint64(data[16:]))
return int(nread) + 24, nil return 24, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2040,7 +2009,7 @@ func (p *AnswerGetObject) NEOEncode(data []byte) { ...@@ -2040,7 +2009,7 @@ func (p *AnswerGetObject) NEOEncode(data []byte) {
} }
func (p *AnswerGetObject) NEODecode(data []byte) (int, error) { func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -2143,7 +2112,7 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) { ...@@ -2143,7 +2112,7 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[45:]) l := binary.BigEndian.Uint32(data[45:])
data = data[49:] data = data[49:]
nread += 49 nread0 += 49
p.Data = make([]byte, l) p.Data = make([]byte, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.Data[i] a := &p.Data[i]
...@@ -2152,14 +2121,14 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) { ...@@ -2152,14 +2121,14 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
} }
(*a) = (data[0:])[0] (*a) = (data[0:])[0]
data = data[1:] data = data[1:]
nread += 1 nread0 += 1
} }
} }
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.DataSerial = Tid(binary.BigEndian.Uint64(data[0:])) p.DataSerial = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2179,7 +2148,6 @@ func (p *TIDList) NEOEncode(data []byte) { ...@@ -2179,7 +2148,6 @@ func (p *TIDList) NEOEncode(data []byte) {
} }
func (p *TIDList) NEODecode(data []byte) (int, error) { func (p *TIDList) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -2192,7 +2160,7 @@ func (p *TIDList) NEODecode(data []byte) (int, error) { ...@@ -2192,7 +2160,7 @@ func (p *TIDList) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Partition = binary.BigEndian.Uint32(data[16:]) p.Partition = binary.BigEndian.Uint32(data[16:])
return int(nread) + 20, nil return 20, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2219,14 +2187,14 @@ func (p *AnswerTIDList) NEOEncode(data []byte) { ...@@ -2219,14 +2187,14 @@ func (p *AnswerTIDList) NEOEncode(data []byte) {
} }
func (p *AnswerTIDList) NEODecode(data []byte) (int, error) { func (p *AnswerTIDList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.TIDList = make([]Tid, l) p.TIDList = make([]Tid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TIDList[i] a := &p.TIDList[i]
...@@ -2235,10 +2203,10 @@ func (p *AnswerTIDList) NEODecode(data []byte) (int, error) { ...@@ -2235,10 +2203,10 @@ func (p *AnswerTIDList) NEODecode(data []byte) (int, error) {
} }
(*a) = Tid(binary.BigEndian.Uint64(data[0:])) (*a) = Tid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2259,7 +2227,6 @@ func (p *TIDListFrom) NEOEncode(data []byte) { ...@@ -2259,7 +2227,6 @@ func (p *TIDListFrom) NEOEncode(data []byte) {
} }
func (p *TIDListFrom) NEODecode(data []byte) (int, error) { func (p *TIDListFrom) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -2276,7 +2243,7 @@ func (p *TIDListFrom) NEODecode(data []byte) (int, error) { ...@@ -2276,7 +2243,7 @@ func (p *TIDListFrom) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Partition = binary.BigEndian.Uint32(data[20:]) p.Partition = binary.BigEndian.Uint32(data[20:])
return int(nread) + 24, nil return 24, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2303,14 +2270,14 @@ func (p *AnswerTIDListFrom) NEOEncode(data []byte) { ...@@ -2303,14 +2270,14 @@ func (p *AnswerTIDListFrom) NEOEncode(data []byte) {
} }
func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) { func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.TidList = make([]Tid, l) p.TidList = make([]Tid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.TidList[i] a := &p.TidList[i]
...@@ -2319,10 +2286,10 @@ func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) { ...@@ -2319,10 +2286,10 @@ func (p *AnswerTIDListFrom) NEODecode(data []byte) (int, error) {
} }
(*a) = Tid(binary.BigEndian.Uint64(data[0:])) (*a) = Tid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2340,12 +2307,11 @@ func (p *TransactionInformation) NEOEncode(data []byte) { ...@@ -2340,12 +2307,11 @@ func (p *TransactionInformation) NEOEncode(data []byte) {
} }
func (p *TransactionInformation) NEODecode(data []byte) (int, error) { func (p *TransactionInformation) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2395,7 +2361,7 @@ func (p *AnswerTransactionInformation) NEOEncode(data []byte) { ...@@ -2395,7 +2361,7 @@ func (p *AnswerTransactionInformation) NEOEncode(data []byte) {
} }
func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -2411,7 +2377,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -2411,7 +2377,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
} }
p.User = string(data[:l]) p.User = string(data[:l])
data = data[l:] data = data[l:]
nread += 12 + l nread0 += 12 + l
} }
{ {
if len(data) < 4 { if len(data) < 4 {
...@@ -2424,7 +2390,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -2424,7 +2390,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
} }
p.Description = string(data[:l]) p.Description = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread0 += 4 + l
} }
{ {
if len(data) < 4 { if len(data) < 4 {
...@@ -2437,7 +2403,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -2437,7 +2403,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
} }
p.Extension = string(data[:l]) p.Extension = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread0 += 4 + l
} }
if len(data) < 1 { if len(data) < 1 {
goto overflow goto overflow
...@@ -2449,7 +2415,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -2449,7 +2415,7 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[1:]) l := binary.BigEndian.Uint32(data[1:])
data = data[5:] data = data[5:]
nread += 5 nread0 += 5
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
...@@ -2458,10 +2424,10 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) { ...@@ -2458,10 +2424,10 @@ func (p *AnswerTransactionInformation) NEODecode(data []byte) (int, error) {
} }
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2481,7 +2447,6 @@ func (p *ObjectHistory) NEOEncode(data []byte) { ...@@ -2481,7 +2447,6 @@ func (p *ObjectHistory) NEOEncode(data []byte) {
} }
func (p *ObjectHistory) NEODecode(data []byte) (int, error) { func (p *ObjectHistory) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -2494,7 +2459,7 @@ func (p *ObjectHistory) NEODecode(data []byte) (int, error) { ...@@ -2494,7 +2459,7 @@ func (p *ObjectHistory) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Last = binary.BigEndian.Uint64(data[16:]) p.Last = binary.BigEndian.Uint64(data[16:])
return int(nread) + 24, nil return 24, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2523,7 +2488,7 @@ func (p *AnswerObjectHistory) NEOEncode(data []byte) { ...@@ -2523,7 +2488,7 @@ func (p *AnswerObjectHistory) NEOEncode(data []byte) {
} }
func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) { func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -2534,7 +2499,7 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) { ...@@ -2534,7 +2499,7 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
p.HistoryList = make([]struct { p.HistoryList = make([]struct {
Serial Tid Serial Tid
Size uint32 Size uint32
...@@ -2550,10 +2515,10 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) { ...@@ -2550,10 +2515,10 @@ func (p *AnswerObjectHistory) NEODecode(data []byte) (int, error) {
} }
(*a).Size = binary.BigEndian.Uint32(data[8:]) (*a).Size = binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2573,7 +2538,6 @@ func (p *PartitionList) NEOEncode(data []byte) { ...@@ -2573,7 +2538,6 @@ func (p *PartitionList) NEOEncode(data []byte) {
} }
func (p *PartitionList) NEODecode(data []byte) (int, error) { func (p *PartitionList) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -2586,7 +2550,7 @@ func (p *PartitionList) NEODecode(data []byte) (int, error) { ...@@ -2586,7 +2550,7 @@ func (p *PartitionList) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.UUID = UUID(int32(binary.BigEndian.Uint32(data[8:]))) p.UUID = UUID(int32(binary.BigEndian.Uint32(data[8:])))
return int(nread) + 12, nil return 12, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2631,7 +2595,7 @@ func (p *AnswerPartitionList) NEOEncode(data []byte) { ...@@ -2631,7 +2595,7 @@ func (p *AnswerPartitionList) NEOEncode(data []byte) {
} }
func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) { func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -2642,7 +2606,7 @@ func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) { ...@@ -2642,7 +2606,7 @@ func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[8:]) l := binary.BigEndian.Uint32(data[8:])
data = data[12:] data = data[12:]
nread += 12 nread0 += 12
p.RowList = make([]RowInfo, l) p.RowList = make([]RowInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.RowList[i] a := &p.RowList[i]
...@@ -2656,7 +2620,7 @@ func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) { ...@@ -2656,7 +2620,7 @@ func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
(*a).CellList = make([]CellInfo, l) (*a).CellList = make([]CellInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &(*a).CellList[i] a := &(*a).CellList[i]
...@@ -2669,14 +2633,14 @@ func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) { ...@@ -2669,14 +2633,14 @@ func (p *AnswerPartitionList) NEODecode(data []byte) (int, error) {
} }
(*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:]))) (*a).CellState = CellState(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
data = data[0:] data = data[0:]
nread += 0 nread0 += 0
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2694,12 +2658,11 @@ func (p *X_NodeList) NEOEncode(data []byte) { ...@@ -2694,12 +2658,11 @@ func (p *X_NodeList) NEOEncode(data []byte) {
} }
func (p *X_NodeList) NEODecode(data []byte) (int, error) { func (p *X_NodeList) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:]))) p.NodeType = NodeType(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return 4, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2743,14 +2706,14 @@ func (p *AnswerNodeList) NEOEncode(data []byte) { ...@@ -2743,14 +2706,14 @@ func (p *AnswerNodeList) NEOEncode(data []byte) {
} }
func (p *AnswerNodeList) NEODecode(data []byte) (int, error) { func (p *AnswerNodeList) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.NodeList = make([]NodeInfo, l) p.NodeList = make([]NodeInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
...@@ -2769,7 +2732,7 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) { ...@@ -2769,7 +2732,7 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) {
} }
(*a).Address.Host = string(data[:l]) (*a).Address.Host = string(data[:l])
data = data[l:] data = data[l:]
nread += 8 + l nread0 += 8 + l
} }
if len(data) < 2 { if len(data) < 2 {
goto overflow goto overflow
...@@ -2788,10 +2751,10 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) { ...@@ -2788,10 +2751,10 @@ func (p *AnswerNodeList) NEODecode(data []byte) (int, error) {
} }
(*a).IdTimestamp = float64_NEODecode(data[10:]) (*a).IdTimestamp = float64_NEODecode(data[10:])
data = data[18:] data = data[18:]
nread += 18 nread0 += 18
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2810,7 +2773,6 @@ func (p *SetNodeState) NEOEncode(data []byte) { ...@@ -2810,7 +2773,6 @@ func (p *SetNodeState) NEOEncode(data []byte) {
} }
func (p *SetNodeState) NEODecode(data []byte) (int, error) { func (p *SetNodeState) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -2819,7 +2781,7 @@ func (p *SetNodeState) NEODecode(data []byte) (int, error) { ...@@ -2819,7 +2781,7 @@ func (p *SetNodeState) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.NodeState = NodeState(int32(binary.BigEndian.Uint32(data[4:]))) p.NodeState = NodeState(int32(binary.BigEndian.Uint32(data[4:])))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2846,14 +2808,14 @@ func (p *AddPendingNodes) NEOEncode(data []byte) { ...@@ -2846,14 +2808,14 @@ func (p *AddPendingNodes) NEOEncode(data []byte) {
} }
func (p *AddPendingNodes) NEODecode(data []byte) (int, error) { func (p *AddPendingNodes) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.UUIDList = make([]UUID, l) p.UUIDList = make([]UUID, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.UUIDList[i] a := &p.UUIDList[i]
...@@ -2862,10 +2824,10 @@ func (p *AddPendingNodes) NEODecode(data []byte) (int, error) { ...@@ -2862,10 +2824,10 @@ func (p *AddPendingNodes) NEODecode(data []byte) (int, error) {
} }
(*a) = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a) = UUID(int32(binary.BigEndian.Uint32(data[0:])))
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2892,14 +2854,14 @@ func (p *TweakPartitionTable) NEOEncode(data []byte) { ...@@ -2892,14 +2854,14 @@ func (p *TweakPartitionTable) NEOEncode(data []byte) {
} }
func (p *TweakPartitionTable) NEODecode(data []byte) (int, error) { func (p *TweakPartitionTable) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.UUIDList = make([]UUID, l) p.UUIDList = make([]UUID, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.UUIDList[i] a := &p.UUIDList[i]
...@@ -2908,10 +2870,10 @@ func (p *TweakPartitionTable) NEODecode(data []byte) (int, error) { ...@@ -2908,10 +2870,10 @@ func (p *TweakPartitionTable) NEODecode(data []byte) (int, error) {
} }
(*a) = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a) = UUID(int32(binary.BigEndian.Uint32(data[0:])))
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -2955,14 +2917,14 @@ func (p *NotifyNodeInformation) NEOEncode(data []byte) { ...@@ -2955,14 +2917,14 @@ func (p *NotifyNodeInformation) NEOEncode(data []byte) {
} }
func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) { func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.NodeList = make([]NodeInfo, l) p.NodeList = make([]NodeInfo, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.NodeList[i] a := &p.NodeList[i]
...@@ -2981,7 +2943,7 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) { ...@@ -2981,7 +2943,7 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) {
} }
(*a).Address.Host = string(data[:l]) (*a).Address.Host = string(data[:l])
data = data[l:] data = data[l:]
nread += 8 + l nread0 += 8 + l
} }
if len(data) < 2 { if len(data) < 2 {
goto overflow goto overflow
...@@ -3000,10 +2962,10 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) { ...@@ -3000,10 +2962,10 @@ func (p *NotifyNodeInformation) NEODecode(data []byte) (int, error) {
} }
(*a).IdTimestamp = float64_NEODecode(data[10:]) (*a).IdTimestamp = float64_NEODecode(data[10:])
data = data[18:] data = data[18:]
nread += 18 nread0 += 18
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3020,8 +2982,7 @@ func (p *NodeInformation) NEOEncode(data []byte) { ...@@ -3020,8 +2982,7 @@ func (p *NodeInformation) NEOEncode(data []byte) {
} }
func (p *NodeInformation) NEODecode(data []byte) (int, error) { func (p *NodeInformation) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3039,12 +3000,11 @@ func (p *SetClusterState) NEOEncode(data []byte) { ...@@ -3039,12 +3000,11 @@ func (p *SetClusterState) NEOEncode(data []byte) {
} }
func (p *SetClusterState) NEODecode(data []byte) (int, error) { func (p *SetClusterState) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:]))) p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return 4, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3062,12 +3022,11 @@ func (p *ClusterInformation) NEOEncode(data []byte) { ...@@ -3062,12 +3022,11 @@ func (p *ClusterInformation) NEOEncode(data []byte) {
} }
func (p *ClusterInformation) NEODecode(data []byte) (int, error) { func (p *ClusterInformation) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:]))) p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return 4, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3085,12 +3044,11 @@ func (p *X_ClusterState) NEOEncode(data []byte) { ...@@ -3085,12 +3044,11 @@ func (p *X_ClusterState) NEOEncode(data []byte) {
} }
func (p *X_ClusterState) NEODecode(data []byte) (int, error) { func (p *X_ClusterState) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:]))) p.State = ClusterState(int32(binary.BigEndian.Uint32(data[0:])))
return int(nread) + 4, nil return 4, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3120,7 +3078,7 @@ func (p *ObjectUndoSerial) NEOEncode(data []byte) { ...@@ -3120,7 +3078,7 @@ func (p *ObjectUndoSerial) NEOEncode(data []byte) {
} }
func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) { func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -3139,7 +3097,7 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) { ...@@ -3139,7 +3097,7 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[24:]) l := binary.BigEndian.Uint32(data[24:])
data = data[28:] data = data[28:]
nread += 28 nread0 += 28
p.OidList = make([]Oid, l) p.OidList = make([]Oid, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.OidList[i] a := &p.OidList[i]
...@@ -3148,10 +3106,10 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) { ...@@ -3148,10 +3106,10 @@ func (p *ObjectUndoSerial) NEODecode(data []byte) (int, error) {
} }
(*a) = Oid(binary.BigEndian.Uint64(data[0:])) (*a) = Oid(binary.BigEndian.Uint64(data[0:]))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3185,14 +3143,14 @@ func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) { ...@@ -3185,14 +3143,14 @@ func (p *AnswerObjectUndoSerial) NEOEncode(data []byte) {
} }
func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) { func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.ObjectTIDDict = make(map[Oid]struct { p.ObjectTIDDict = make(map[Oid]struct {
CurrentSerial Tid CurrentSerial Tid
UndoSerial Tid UndoSerial Tid
...@@ -3223,10 +3181,10 @@ func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) { ...@@ -3223,10 +3181,10 @@ func (p *AnswerObjectUndoSerial) NEODecode(data []byte) (int, error) {
v.IsCurrent = byte2bool((data[24:])[0]) v.IsCurrent = byte2bool((data[24:])[0])
m[key] = v m[key] = v
data = data[25:] data = data[25:]
nread += 25 nread0 += 25
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3245,7 +3203,6 @@ func (p *HasLock) NEOEncode(data []byte) { ...@@ -3245,7 +3203,6 @@ func (p *HasLock) NEOEncode(data []byte) {
} }
func (p *HasLock) NEODecode(data []byte) (int, error) { func (p *HasLock) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -3254,7 +3211,7 @@ func (p *HasLock) NEODecode(data []byte) (int, error) { ...@@ -3254,7 +3211,7 @@ func (p *HasLock) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Oid = Oid(binary.BigEndian.Uint64(data[8:])) p.Oid = Oid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return 16, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3273,7 +3230,6 @@ func (p *AnswerHasLock) NEOEncode(data []byte) { ...@@ -3273,7 +3230,6 @@ func (p *AnswerHasLock) NEOEncode(data []byte) {
} }
func (p *AnswerHasLock) NEODecode(data []byte) (int, error) { func (p *AnswerHasLock) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -3282,7 +3238,7 @@ func (p *AnswerHasLock) NEODecode(data []byte) (int, error) { ...@@ -3282,7 +3238,7 @@ func (p *AnswerHasLock) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.LockState = LockState(int32(binary.BigEndian.Uint32(data[8:]))) p.LockState = LockState(int32(binary.BigEndian.Uint32(data[8:])))
return int(nread) + 12, nil return 12, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3302,7 +3258,6 @@ func (p *CheckCurrentSerial) NEOEncode(data []byte) { ...@@ -3302,7 +3258,6 @@ func (p *CheckCurrentSerial) NEOEncode(data []byte) {
} }
func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) { func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
...@@ -3315,7 +3270,7 @@ func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) { ...@@ -3315,7 +3270,7 @@ func (p *CheckCurrentSerial) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Oid = Oid(binary.BigEndian.Uint64(data[16:])) p.Oid = Oid(binary.BigEndian.Uint64(data[16:]))
return int(nread) + 24, nil return 24, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3335,7 +3290,6 @@ func (p *AnswerCheckCurrentSerial) NEOEncode(data []byte) { ...@@ -3335,7 +3290,6 @@ func (p *AnswerCheckCurrentSerial) NEOEncode(data []byte) {
} }
func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) { func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 1 { if len(data) < 1 {
goto overflow goto overflow
} }
...@@ -3348,7 +3302,7 @@ func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) { ...@@ -3348,7 +3302,7 @@ func (p *AnswerCheckCurrentSerial) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.Serial = Tid(binary.BigEndian.Uint64(data[9:])) p.Serial = Tid(binary.BigEndian.Uint64(data[9:]))
return int(nread) + 17, nil return 17, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3366,12 +3320,11 @@ func (p *Pack) NEOEncode(data []byte) { ...@@ -3366,12 +3320,11 @@ func (p *Pack) NEOEncode(data []byte) {
} }
func (p *Pack) NEODecode(data []byte) (int, error) { func (p *Pack) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3389,12 +3342,11 @@ func (p *AnswerPack) NEOEncode(data []byte) { ...@@ -3389,12 +3342,11 @@ func (p *AnswerPack) NEOEncode(data []byte) {
} }
func (p *AnswerPack) NEODecode(data []byte) (int, error) { func (p *AnswerPack) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 1 { if len(data) < 1 {
goto overflow goto overflow
} }
p.Status = byte2bool((data[0:])[0]) p.Status = byte2bool((data[0:])[0])
return int(nread) + 1, nil return 1, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3428,14 +3380,14 @@ func (p *CheckReplicas) NEOEncode(data []byte) { ...@@ -3428,14 +3380,14 @@ func (p *CheckReplicas) NEOEncode(data []byte) {
} }
func (p *CheckReplicas) NEODecode(data []byte) (int, error) { func (p *CheckReplicas) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
{ {
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
l := binary.BigEndian.Uint32(data[0:]) l := binary.BigEndian.Uint32(data[0:])
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
p.PartitionDict = make(map[uint32]UUID, l) p.PartitionDict = make(map[uint32]UUID, l)
m := p.PartitionDict m := p.PartitionDict
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
...@@ -3448,7 +3400,7 @@ func (p *CheckReplicas) NEODecode(data []byte) (int, error) { ...@@ -3448,7 +3400,7 @@ func (p *CheckReplicas) NEODecode(data []byte) (int, error) {
} }
m[key] = UUID(int32(binary.BigEndian.Uint32(data[4:]))) m[key] = UUID(int32(binary.BigEndian.Uint32(data[4:])))
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
} }
} }
if len(data) < 8 { if len(data) < 8 {
...@@ -3459,7 +3411,7 @@ func (p *CheckReplicas) NEODecode(data []byte) (int, error) { ...@@ -3459,7 +3411,7 @@ func (p *CheckReplicas) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[8:]))
return int(nread) + 16, nil return 16 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3494,7 +3446,7 @@ func (p *CheckPartition) NEOEncode(data []byte) { ...@@ -3494,7 +3446,7 @@ func (p *CheckPartition) NEOEncode(data []byte) {
} }
func (p *CheckPartition) NEODecode(data []byte) (int, error) { func (p *CheckPartition) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -3510,7 +3462,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) { ...@@ -3510,7 +3462,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
} }
p.Source.UpstreamName = string(data[:l]) p.Source.UpstreamName = string(data[:l])
data = data[l:] data = data[l:]
nread += 8 + l nread0 += 8 + l
} }
{ {
if len(data) < 4 { if len(data) < 4 {
...@@ -3523,7 +3475,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) { ...@@ -3523,7 +3475,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
} }
p.Source.Address.Host = string(data[:l]) p.Source.Address.Host = string(data[:l])
data = data[l:] data = data[l:]
nread += 4 + l nread0 += 4 + l
} }
if len(data) < 2 { if len(data) < 2 {
goto overflow goto overflow
...@@ -3537,7 +3489,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) { ...@@ -3537,7 +3489,7 @@ func (p *CheckPartition) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.MaxTID = Tid(binary.BigEndian.Uint64(data[10:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[10:]))
return int(nread) + 18, nil return 18 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3558,7 +3510,6 @@ func (p *CheckTIDRange) NEOEncode(data []byte) { ...@@ -3558,7 +3510,6 @@ func (p *CheckTIDRange) NEOEncode(data []byte) {
} }
func (p *CheckTIDRange) NEODecode(data []byte) (int, error) { func (p *CheckTIDRange) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -3575,7 +3526,7 @@ func (p *CheckTIDRange) NEODecode(data []byte) (int, error) { ...@@ -3575,7 +3526,7 @@ func (p *CheckTIDRange) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.MaxTID = Tid(binary.BigEndian.Uint64(data[16:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[16:]))
return int(nread) + 24, nil return 24, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3614,7 +3565,6 @@ func (p *AnswerCheckTIDRange) NEOEncode(data []byte) { ...@@ -3614,7 +3565,6 @@ func (p *AnswerCheckTIDRange) NEOEncode(data []byte) {
} }
func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) { func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -3703,7 +3653,7 @@ func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) { ...@@ -3703,7 +3653,7 @@ func (p *AnswerCheckTIDRange) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.MaxTID = Tid(binary.BigEndian.Uint64(data[24:])) p.MaxTID = Tid(binary.BigEndian.Uint64(data[24:]))
return int(nread) + 32, nil return 32, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3725,7 +3675,6 @@ func (p *CheckSerialRange) NEOEncode(data []byte) { ...@@ -3725,7 +3675,6 @@ func (p *CheckSerialRange) NEOEncode(data []byte) {
} }
func (p *CheckSerialRange) NEODecode(data []byte) (int, error) { func (p *CheckSerialRange) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -3746,7 +3695,7 @@ func (p *CheckSerialRange) NEODecode(data []byte) (int, error) { ...@@ -3746,7 +3695,7 @@ func (p *CheckSerialRange) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.MinOID = Oid(binary.BigEndian.Uint64(data[24:])) p.MinOID = Oid(binary.BigEndian.Uint64(data[24:]))
return int(nread) + 32, nil return 32, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -3806,7 +3755,6 @@ func (p *AnswerCheckSerialRange) NEOEncode(data []byte) { ...@@ -3806,7 +3755,6 @@ func (p *AnswerCheckSerialRange) NEOEncode(data []byte) {
} }
func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) { func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -3979,7 +3927,7 @@ func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) { ...@@ -3979,7 +3927,7 @@ func (p *AnswerCheckSerialRange) NEODecode(data []byte) (int, error) {
goto overflow goto overflow
} }
p.MaxOID = Oid(binary.BigEndian.Uint64(data[52:])) p.MaxOID = Oid(binary.BigEndian.Uint64(data[52:]))
return int(nread) + 60, nil return 60, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -4007,7 +3955,7 @@ func (p *PartitionCorrupted) NEOEncode(data []byte) { ...@@ -4007,7 +3955,7 @@ func (p *PartitionCorrupted) NEOEncode(data []byte) {
} }
func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) { func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) {
var nread uint32 var nread0 uint32
if len(data) < 4 { if len(data) < 4 {
goto overflow goto overflow
} }
...@@ -4018,7 +3966,7 @@ func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) { ...@@ -4018,7 +3966,7 @@ func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) {
} }
l := binary.BigEndian.Uint32(data[4:]) l := binary.BigEndian.Uint32(data[4:])
data = data[8:] data = data[8:]
nread += 8 nread0 += 8
p.CellList = make([]UUID, l) p.CellList = make([]UUID, l)
for i := 0; uint32(i) < l; i++ { for i := 0; uint32(i) < l; i++ {
a := &p.CellList[i] a := &p.CellList[i]
...@@ -4027,10 +3975,10 @@ func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) { ...@@ -4027,10 +3975,10 @@ func (p *PartitionCorrupted) NEODecode(data []byte) (int, error) {
} }
(*a) = UUID(int32(binary.BigEndian.Uint32(data[0:]))) (*a) = UUID(int32(binary.BigEndian.Uint32(data[0:])))
data = data[4:] data = data[4:]
nread += 4 nread0 += 4
} }
} }
return int(nread) + 0, nil return 0 + int(nread0), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -4047,8 +3995,7 @@ func (p *LastTransaction) NEOEncode(data []byte) { ...@@ -4047,8 +3995,7 @@ func (p *LastTransaction) NEOEncode(data []byte) {
} }
func (p *LastTransaction) NEODecode(data []byte) (int, error) { func (p *LastTransaction) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -4066,12 +4013,11 @@ func (p *AnswerLastTransaction) NEOEncode(data []byte) { ...@@ -4066,12 +4013,11 @@ func (p *AnswerLastTransaction) NEOEncode(data []byte) {
} }
func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) { func (p *AnswerLastTransaction) NEODecode(data []byte) (int, error) {
var nread uint32
if len(data) < 8 { if len(data) < 8 {
goto overflow goto overflow
} }
p.Tid = Tid(binary.BigEndian.Uint64(data[0:])) p.Tid = Tid(binary.BigEndian.Uint64(data[0:]))
return int(nread) + 8, nil return 8, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
...@@ -4088,8 +4034,7 @@ func (p *NotifyReady) NEOEncode(data []byte) { ...@@ -4088,8 +4034,7 @@ func (p *NotifyReady) NEOEncode(data []byte) {
} }
func (p *NotifyReady) NEODecode(data []byte) (int, error) { func (p *NotifyReady) NEODecode(data []byte) (int, error) {
var nread uint32 return 0, nil
return int(nread) + 0, nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
......
...@@ -234,59 +234,59 @@ type CodecCodeGen interface { ...@@ -234,59 +234,59 @@ type CodecCodeGen interface {
} }
// sizer/encode/decode codegen // sizer/encode/decode codegen
type coderForFunc struct { type commonCoder struct {
recvName string // receiver/type for top-level func recvName string // receiver/type for top-level func
typeName string // or empty typeName string // or empty
varN int // suffix to add to variables (size0, size1, ...) - for nested computations
varUsed map[string]bool // whether a variable was used
} }
func (c *coderForFunc) setFunc(recvName, typeName string) { func (c *commonCoder) setFunc(recvName, typeName string) {
c.recvName = recvName c.recvName = recvName
c.typeName = typeName c.typeName = typeName
} }
// get variable name for varname
func (c *commonCoder) var__(varname string) string {
return fmt.Sprintf("%s%d", varname, c.varN)
}
func (c *commonCoder) var_(varname string) string {
varnameX := c.var__(varname)
if c.varUsed == nil {
c.varUsed = make(map[string]bool)
}
c.varUsed[varname] = true
return varnameX
}
type sizer struct { type sizer struct {
Buffer // buffer for code Buffer // buffer for code
n int // fixed part of size n int // fixed part of size
symLenv []string // symbolic part of size symLenv []string // symbolic part of size
varN int // suffix to add to variables (size0, size1, ...) - for nested computations commonCoder
varUsed map[string]bool // whether a variable was used
coderForFunc
}
// get variable name for varname
func (s *sizer) var__(varname string) string {
return fmt.Sprintf("%s%d", varname, s.varN)
}
func (s *sizer) var_(varname string) string {
varnameX := s.var__(varname)
if s.varUsed == nil {
s.varUsed = make(map[string]bool)
}
s.varUsed[varname] = true
return varnameX
} }
// create new sizer for subsize calculation (e.g. for loop) // create new sizer for subsize calculation (e.g. for loop)
func (s *sizer) subSizer() *sizer { func (s *sizer) subSizer() *sizer {
return &sizer{varN: s.varN + 1} return &sizer{commonCoder: commonCoder{varN: s.varN + 1}}
} }
type encoder struct { type encoder struct {
Buffer // XXX Buffer // XXX
n int n int
coderForFunc commonCoder
} }
type decoder struct { type decoder struct {
Buffer // buffer for generated code Buffer // buffer for generated code
n int // current decode position in data n int // current decode position in data
coderForFunc commonCoder
} }
var _ CodecCodeGen = (*sizer)(nil) var _ CodecCodeGen = (*sizer)(nil)
...@@ -354,12 +354,19 @@ func (d *decoder) generatedCode() string { ...@@ -354,12 +354,19 @@ func (d *decoder) generatedCode() string {
if d.recvName != "" { if d.recvName != "" {
code.emit("func (%s *%s) NEODecode(data []byte) (int, error) {", d.recvName, d.typeName) code.emit("func (%s *%s) NEODecode(data []byte) (int, error) {", d.recvName, d.typeName)
} }
code.emit("var nread uint32") if d.varUsed["nread"] {
code.emit("var %v uint32", d.var__("nread"))
}
code.Write(d.Bytes()) // XXX -> d.buf.Bytes() ? code.Write(d.Bytes()) // XXX -> d.buf.Bytes() ?
// epilogue // epilogue
code.emit("return int(nread) + %v, nil", d.n) retexpr := fmt.Sprintf("%v", d.n)
if d.varUsed["nread"] {
retexpr += fmt.Sprintf(" + int(%v)", d.var__("nread"))
}
code.emit("return %v, nil", retexpr)
code.emit("\noverflow:") code.emit("\noverflow:")
code.emit("return 0, ErrDecodeOverflow") code.emit("return 0, ErrDecodeOverflow")
code.emit("goto overflow") // TODO check if overflow used at all and remove code.emit("goto overflow") // TODO check if overflow used at all and remove
...@@ -431,7 +438,7 @@ func (d *decoder) genStrBytes(assignto string) { ...@@ -431,7 +438,7 @@ func (d *decoder) genStrBytes(assignto string) {
d.emit("if uint32(len(data)) < l { goto overflow }") d.emit("if uint32(len(data)) < l { goto overflow }")
d.emit("%v= string(data[:l])", assignto) d.emit("%v= string(data[:l])", assignto)
d.emit("data = data[l:]") d.emit("data = data[l:]")
d.emit("nread += %v + l", d.n) d.emit("%v += %v + l", d.var_("nread"), d.n)
d.emit("}") d.emit("}")
d.n = 0 d.n = 0
} }
...@@ -481,7 +488,7 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object) ...@@ -481,7 +488,7 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
d.emit("{") d.emit("{")
d.genBasic("l:", types.Typ[types.Uint32], nil) d.genBasic("l:", types.Typ[types.Uint32], nil)
d.emit("data = data[%v:]", d.n) d.emit("data = data[%v:]", d.n)
d.emit("nread += %v", d.n) d.emit("%v += %v", d.var_("nread"), d.n)
d.n = 0 d.n = 0
d.emit("%v= make(%v, l)", assignto, typeName(typ)) d.emit("%v= make(%v, l)", assignto, typeName(typ))
// TODO size check // TODO size check
...@@ -492,7 +499,7 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object) ...@@ -492,7 +499,7 @@ func (d *decoder) genSlice(assignto string, typ *types.Slice, obj types.Object)
// XXX try to avoid (*) in a // XXX try to avoid (*) in a
codegenType("(*a)", typ.Elem(), obj, d) codegenType("(*a)", typ.Elem(), obj, d)
d.emit("data = data[%v:]", d.n) // FIXME wrt slice of slice ? d.emit("data = data[%v:]", d.n) // FIXME wrt slice of slice ?
d.emit("nread += %v", d.n) d.emit("%v += %v", d.var_("nread"), d.n)
d.emit("}") d.emit("}")
//d.emit("%v= string(data[:l])", assignto) //d.emit("%v= string(data[:l])", assignto)
d.emit("}") d.emit("}")
...@@ -548,7 +555,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) { ...@@ -548,7 +555,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
d.emit("{") d.emit("{")
d.genBasic("l:", types.Typ[types.Uint32], nil) d.genBasic("l:", types.Typ[types.Uint32], nil)
d.emit("data = data[%v:]", d.n) d.emit("data = data[%v:]", d.n)
d.emit("nread += %v", d.n) d.emit("%v += %v", d.var_("nread"), d.n)
d.n = 0 d.n = 0
d.emit("%v= make(%v, l)", assignto, typeName(typ)) d.emit("%v= make(%v, l)", assignto, typeName(typ))
// TODO size check // TODO size check
...@@ -572,7 +579,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) { ...@@ -572,7 +579,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
} }
d.emit("data = data[%v:]", d.n) // FIXME wrt map of map ? d.emit("data = data[%v:]", d.n) // FIXME wrt map of map ?
d.emit("nread += %v", d.n) d.emit("%v += %v", d.var_("nread"), d.n)
d.emit("}") d.emit("}")
//d.emit("%v= string(data[:l])", assignto) //d.emit("%v= string(data[:l])", assignto)
d.emit("}") d.emit("}")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment