diff --git a/acl/convert.go b/acl/convert.go index c5768ad..f5de743 100644 --- a/acl/convert.go +++ b/acl/convert.go @@ -187,28 +187,26 @@ func (f *HeaderFilter) FromGRPCMessage(m grpc.Message) error { return nil } -func HeaderFiltersToGRPC(fs []HeaderFilter) (res []*acl.EACLRecord_Filter) { +func HeaderFiltersToGRPC(fs []HeaderFilter) (res []acl.EACLRecord_Filter) { if fs != nil { - res = make([]*acl.EACLRecord_Filter, 0, len(fs)) + res = make([]acl.EACLRecord_Filter, 0, len(fs)) for i := range fs { - res = append(res, fs[i].ToGRPCMessage().(*acl.EACLRecord_Filter)) + res = append(res, *fs[i].ToGRPCMessage().(*acl.EACLRecord_Filter)) } } return } -func HeaderFiltersFromGRPC(fs []*acl.EACLRecord_Filter) (res []HeaderFilter, err error) { +func HeaderFiltersFromGRPC(fs []acl.EACLRecord_Filter) (res []HeaderFilter, err error) { if fs != nil { res = make([]HeaderFilter, len(fs)) for i := range fs { - if fs[i] != nil { - err = res[i].FromGRPCMessage(fs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&fs[i]) + if err != nil { + return } } } @@ -241,28 +239,26 @@ func (t *Target) FromGRPCMessage(m grpc.Message) error { return nil } -func TargetsToGRPC(ts []Target) (res []*acl.EACLRecord_Target) { +func TargetsToGRPC(ts []Target) (res []acl.EACLRecord_Target) { if ts != nil { - res = make([]*acl.EACLRecord_Target, 0, len(ts)) + res = make([]acl.EACLRecord_Target, 0, len(ts)) for i := range ts { - res = append(res, ts[i].ToGRPCMessage().(*acl.EACLRecord_Target)) + res = append(res, *ts[i].ToGRPCMessage().(*acl.EACLRecord_Target)) } } return } -func TargetsFromGRPC(fs []*acl.EACLRecord_Target) (res []Target, err error) { +func TargetsFromGRPC(fs []acl.EACLRecord_Target) (res []Target, err error) { if fs != nil { res = make([]Target, len(fs)) for i := range fs { - if fs[i] != nil { - err = res[i].FromGRPCMessage(fs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&fs[i]) + if err != nil { + return } } } @@ -309,28 +305,26 @@ func (r *Record) FromGRPCMessage(m grpc.Message) error { return nil } -func RecordsToGRPC(ts []Record) (res []*acl.EACLRecord) { +func RecordsToGRPC(ts []Record) (res []acl.EACLRecord) { if ts != nil { - res = make([]*acl.EACLRecord, 0, len(ts)) + res = make([]acl.EACLRecord, 0, len(ts)) for i := range ts { - res = append(res, ts[i].ToGRPCMessage().(*acl.EACLRecord)) + res = append(res, *ts[i].ToGRPCMessage().(*acl.EACLRecord)) } } return } -func RecordsFromGRPC(fs []*acl.EACLRecord) (res []Record, err error) { +func RecordsFromGRPC(fs []acl.EACLRecord) (res []Record, err error) { if fs != nil { res = make([]Record, len(fs)) for i := range fs { - if fs[i] != nil { - err = res[i].FromGRPCMessage(fs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&fs[i]) + if err != nil { + return } } } @@ -429,9 +423,9 @@ func (c *APEOverride) ToGRPCMessage() grpc.Message { m.SetTarget(c.target.ToGRPCMessage().(*apeGRPC.ChainTarget)) if len(c.chains) > 0 { - apeChains := make([]*apeGRPC.Chain, len(c.chains)) + apeChains := make([]apeGRPC.Chain, len(c.chains)) for i := range c.chains { - apeChains[i] = c.chains[i].ToGRPCMessage().(*apeGRPC.Chain) + apeChains[i] = *c.chains[i].ToGRPCMessage().(*apeGRPC.Chain) } m.SetChains(apeChains) } @@ -459,7 +453,7 @@ func (c *APEOverride) FromGRPCMessage(m grpc.Message) error { c.chains = make([]*ape.Chain, len(apeChains)) for i := range apeChains { c.chains[i] = new(ape.Chain) - if err := c.chains[i].FromGRPCMessage(apeChains[i]); err != nil { + if err := c.chains[i].FromGRPCMessage(&apeChains[i]); err != nil { return err } } diff --git a/acl/grpc/types_frostfs.pb.go b/acl/grpc/types_frostfs.pb.go index 931f3b3..2b116bd 100644 Binary files a/acl/grpc/types_frostfs.pb.go and b/acl/grpc/types_frostfs.pb.go differ diff --git a/apemanager/convert.go b/apemanager/convert.go index fdc5132..5677b25 100644 --- a/apemanager/convert.go +++ b/apemanager/convert.go @@ -296,9 +296,9 @@ func (respBody *ListChainsResponseBody) ToGRPCMessage() grpc.Message { if respBody != nil { respBodygrpc = new(apemanager.ListChainsResponse_Body) - chainsgrpc := make([]*apeGRPC.Chain, 0, len(respBody.GetChains())) + chainsgrpc := make([]apeGRPC.Chain, 0, len(respBody.GetChains())) for _, chain := range respBody.GetChains() { - chainsgrpc = append(chainsgrpc, chain.ToGRPCMessage().(*apeGRPC.Chain)) + chainsgrpc = append(chainsgrpc, *chain.ToGRPCMessage().(*apeGRPC.Chain)) } respBodygrpc.SetChains(chainsgrpc) @@ -317,7 +317,7 @@ func (respBody *ListChainsResponseBody) FromGRPCMessage(m grpc.Message) error { for _, chaingrpc := range respBodygrpc.GetChains() { chain := new(ape.Chain) - if err := chain.FromGRPCMessage(chaingrpc); err != nil { + if err := chain.FromGRPCMessage(&chaingrpc); err != nil { return err } chains = append(chains, chain) diff --git a/apemanager/grpc/service_frostfs.pb.go b/apemanager/grpc/service_frostfs.pb.go index c1d28ed..99abeb2 100644 Binary files a/apemanager/grpc/service_frostfs.pb.go and b/apemanager/grpc/service_frostfs.pb.go differ diff --git a/container/convert.go b/container/convert.go index c5f9cd7..b487f40 100644 --- a/container/convert.go +++ b/container/convert.go @@ -39,28 +39,26 @@ func (a *Attribute) FromGRPCMessage(m grpc.Message) error { return nil } -func AttributesToGRPC(xs []Attribute) (res []*container.Container_Attribute) { +func AttributesToGRPC(xs []Attribute) (res []container.Container_Attribute) { if xs != nil { - res = make([]*container.Container_Attribute, 0, len(xs)) + res = make([]container.Container_Attribute, 0, len(xs)) for i := range xs { - res = append(res, xs[i].ToGRPCMessage().(*container.Container_Attribute)) + res = append(res, *xs[i].ToGRPCMessage().(*container.Container_Attribute)) } } return } -func AttributesFromGRPC(xs []*container.Container_Attribute) (res []Attribute, err error) { +func AttributesFromGRPC(xs []container.Container_Attribute) (res []Attribute, err error) { if xs != nil { res = make([]Attribute, len(xs)) for i := range xs { - if xs[i] != nil { - err = res[i].FromGRPCMessage(xs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&xs[i]) + if err != nil { + return } } } diff --git a/container/grpc/service_frostfs.pb.go b/container/grpc/service_frostfs.pb.go index 514f03b..f38b0de 100644 Binary files a/container/grpc/service_frostfs.pb.go and b/container/grpc/service_frostfs.pb.go differ diff --git a/container/grpc/types_frostfs.pb.go b/container/grpc/types_frostfs.pb.go index dcb9cf4..3010eb0 100644 Binary files a/container/grpc/types_frostfs.pb.go and b/container/grpc/types_frostfs.pb.go differ diff --git a/lock/grpc/types_frostfs.pb.go b/lock/grpc/types_frostfs.pb.go index 52a1a2d..58be895 100644 Binary files a/lock/grpc/types_frostfs.pb.go and b/lock/grpc/types_frostfs.pb.go differ diff --git a/netmap/convert.go b/netmap/convert.go index fad7380..659b798 100644 --- a/netmap/convert.go +++ b/netmap/convert.go @@ -45,28 +45,26 @@ func (f *Filter) FromGRPCMessage(m grpc.Message) error { return nil } -func FiltersToGRPC(fs []Filter) (res []*netmap.Filter) { +func FiltersToGRPC(fs []Filter) (res []netmap.Filter) { if fs != nil { - res = make([]*netmap.Filter, 0, len(fs)) + res = make([]netmap.Filter, 0, len(fs)) for i := range fs { - res = append(res, fs[i].ToGRPCMessage().(*netmap.Filter)) + res = append(res, *fs[i].ToGRPCMessage().(*netmap.Filter)) } } return } -func FiltersFromGRPC(fs []*netmap.Filter) (res []Filter, err error) { +func FiltersFromGRPC(fs []netmap.Filter) (res []Filter, err error) { if fs != nil { res = make([]Filter, len(fs)) for i := range fs { - if fs[i] != nil { - err = res[i].FromGRPCMessage(fs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&fs[i]) + if err != nil { + return } } } @@ -105,28 +103,26 @@ func (s *Selector) FromGRPCMessage(m grpc.Message) error { return nil } -func SelectorsToGRPC(ss []Selector) (res []*netmap.Selector) { +func SelectorsToGRPC(ss []Selector) (res []netmap.Selector) { if ss != nil { - res = make([]*netmap.Selector, 0, len(ss)) + res = make([]netmap.Selector, 0, len(ss)) for i := range ss { - res = append(res, ss[i].ToGRPCMessage().(*netmap.Selector)) + res = append(res, *ss[i].ToGRPCMessage().(*netmap.Selector)) } } return } -func SelectorsFromGRPC(ss []*netmap.Selector) (res []Selector, err error) { +func SelectorsFromGRPC(ss []netmap.Selector) (res []Selector, err error) { if ss != nil { res = make([]Selector, len(ss)) for i := range ss { - if ss[i] != nil { - err = res[i].FromGRPCMessage(ss[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&ss[i]) + if err != nil { + return } } } @@ -163,28 +159,26 @@ func (r *Replica) FromGRPCMessage(m grpc.Message) error { return nil } -func ReplicasToGRPC(rs []Replica) (res []*netmap.Replica) { +func ReplicasToGRPC(rs []Replica) (res []netmap.Replica) { if rs != nil { - res = make([]*netmap.Replica, 0, len(rs)) + res = make([]netmap.Replica, 0, len(rs)) for i := range rs { - res = append(res, rs[i].ToGRPCMessage().(*netmap.Replica)) + res = append(res, *rs[i].ToGRPCMessage().(*netmap.Replica)) } } return } -func ReplicasFromGRPC(rs []*netmap.Replica) (res []Replica, err error) { +func ReplicasFromGRPC(rs []netmap.Replica) (res []Replica, err error) { if rs != nil { res = make([]Replica, len(rs)) for i := range rs { - if rs[i] != nil { - err = res[i].FromGRPCMessage(rs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&rs[i]) + if err != nil { + return } } } @@ -289,28 +283,26 @@ func (a *Attribute) FromGRPCMessage(m grpc.Message) error { return nil } -func AttributesToGRPC(as []Attribute) (res []*netmap.NodeInfo_Attribute) { +func AttributesToGRPC(as []Attribute) (res []netmap.NodeInfo_Attribute) { if as != nil { - res = make([]*netmap.NodeInfo_Attribute, 0, len(as)) + res = make([]netmap.NodeInfo_Attribute, 0, len(as)) for i := range as { - res = append(res, as[i].ToGRPCMessage().(*netmap.NodeInfo_Attribute)) + res = append(res, *as[i].ToGRPCMessage().(*netmap.NodeInfo_Attribute)) } } return } -func AttributesFromGRPC(as []*netmap.NodeInfo_Attribute) (res []Attribute, err error) { +func AttributesFromGRPC(as []netmap.NodeInfo_Attribute) (res []Attribute, err error) { if as != nil { res = make([]Attribute, len(as)) for i := range as { - if as[i] != nil { - err = res[i].FromGRPCMessage(as[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&as[i]) + if err != nil { + return } } } @@ -528,13 +520,13 @@ func (x *NetworkConfig) ToGRPCMessage() grpc.Message { if x != nil { m = new(netmap.NetworkConfig) - var ps []*netmap.NetworkConfig_Parameter + var ps []netmap.NetworkConfig_Parameter if ln := len(x.ps); ln > 0 { - ps = make([]*netmap.NetworkConfig_Parameter, 0, ln) + ps = make([]netmap.NetworkConfig_Parameter, 0, ln) for i := 0; i < ln; i++ { - ps = append(ps, x.ps[i].ToGRPCMessage().(*netmap.NetworkConfig_Parameter)) + ps = append(ps, *x.ps[i].ToGRPCMessage().(*netmap.NetworkConfig_Parameter)) } } @@ -561,10 +553,8 @@ func (x *NetworkConfig) FromGRPCMessage(m grpc.Message) error { ps = make([]NetworkParameter, ln) for i := 0; i < ln; i++ { - if psV2[i] != nil { - if err := ps[i].FromGRPCMessage(psV2[i]); err != nil { - return err - } + if err := ps[i].FromGRPCMessage(&psV2[i]); err != nil { + return err } } } @@ -756,10 +746,10 @@ func (x *NetMap) ToGRPCMessage() grpc.Message { m.SetEpoch(x.epoch) if x.nodes != nil { - nodes := make([]*netmap.NodeInfo, len(x.nodes)) + nodes := make([]netmap.NodeInfo, len(x.nodes)) for i := range x.nodes { - nodes[i] = x.nodes[i].ToGRPCMessage().(*netmap.NodeInfo) + nodes[i] = *x.nodes[i].ToGRPCMessage().(*netmap.NodeInfo) } m.SetNodes(nodes) @@ -784,7 +774,7 @@ func (x *NetMap) FromGRPCMessage(m grpc.Message) error { x.nodes = make([]NodeInfo, len(nodes)) for i := range nodes { - err = x.nodes[i].FromGRPCMessage(nodes[i]) + err = x.nodes[i].FromGRPCMessage(&nodes[i]) if err != nil { return err } diff --git a/netmap/grpc/types_frostfs.pb.go b/netmap/grpc/types_frostfs.pb.go index 6ecf0fa..e7597ea 100644 Binary files a/netmap/grpc/types_frostfs.pb.go and b/netmap/grpc/types_frostfs.pb.go differ diff --git a/object/convert.go b/object/convert.go index e237883..88e6ab7 100644 --- a/object/convert.go +++ b/object/convert.go @@ -142,28 +142,26 @@ func (a *Attribute) FromGRPCMessage(m grpc.Message) error { return nil } -func AttributesToGRPC(xs []Attribute) (res []*object.Header_Attribute) { +func AttributesToGRPC(xs []Attribute) (res []object.Header_Attribute) { if xs != nil { - res = make([]*object.Header_Attribute, 0, len(xs)) + res = make([]object.Header_Attribute, 0, len(xs)) for i := range xs { - res = append(res, xs[i].ToGRPCMessage().(*object.Header_Attribute)) + res = append(res, *xs[i].ToGRPCMessage().(*object.Header_Attribute)) } } return } -func AttributesFromGRPC(xs []*object.Header_Attribute) (res []Attribute, err error) { +func AttributesFromGRPC(xs []object.Header_Attribute) (res []Attribute, err error) { if xs != nil { res = make([]Attribute, len(xs)) for i := range xs { - if xs[i] != nil { - err = res[i].FromGRPCMessage(xs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&xs[i]) + if err != nil { + return } } } @@ -683,9 +681,9 @@ func (s *ECInfo) ToGRPCMessage() grpc.Message { m = new(object.ECInfo) if s.Chunks != nil { - chunks := make([]*object.ECInfo_Chunk, len(s.Chunks)) + chunks := make([]object.ECInfo_Chunk, len(s.Chunks)) for i := range chunks { - chunks[i] = s.Chunks[i].ToGRPCMessage().(*object.ECInfo_Chunk) + chunks[i] = *s.Chunks[i].ToGRPCMessage().(*object.ECInfo_Chunk) } m.Chunks = chunks } @@ -706,7 +704,7 @@ func (s *ECInfo) FromGRPCMessage(m grpc.Message) error { } else { s.Chunks = make([]ECChunk, len(chunks)) for i := range chunks { - if err := s.Chunks[i].FromGRPCMessage(chunks[i]); err != nil { + if err := s.Chunks[i].FromGRPCMessage(&chunks[i]); err != nil { return err } } @@ -1626,28 +1624,26 @@ func (f *SearchFilter) FromGRPCMessage(m grpc.Message) error { return nil } -func SearchFiltersToGRPC(fs []SearchFilter) (res []*object.SearchRequest_Body_Filter) { +func SearchFiltersToGRPC(fs []SearchFilter) (res []object.SearchRequest_Body_Filter) { if fs != nil { - res = make([]*object.SearchRequest_Body_Filter, 0, len(fs)) + res = make([]object.SearchRequest_Body_Filter, 0, len(fs)) for i := range fs { - res = append(res, fs[i].ToGRPCMessage().(*object.SearchRequest_Body_Filter)) + res = append(res, *fs[i].ToGRPCMessage().(*object.SearchRequest_Body_Filter)) } } return } -func SearchFiltersFromGRPC(fs []*object.SearchRequest_Body_Filter) (res []SearchFilter, err error) { +func SearchFiltersFromGRPC(fs []object.SearchRequest_Body_Filter) (res []SearchFilter, err error) { if fs != nil { res = make([]SearchFilter, len(fs)) for i := range fs { - if fs[i] != nil { - err = res[i].FromGRPCMessage(fs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&fs[i]) + if err != nil { + return } } } @@ -1827,28 +1823,26 @@ func (r *Range) FromGRPCMessage(m grpc.Message) error { return nil } -func RangesToGRPC(rs []Range) (res []*object.Range) { +func RangesToGRPC(rs []Range) (res []object.Range) { if rs != nil { - res = make([]*object.Range, 0, len(rs)) + res = make([]object.Range, 0, len(rs)) for i := range rs { - res = append(res, rs[i].ToGRPCMessage().(*object.Range)) + res = append(res, *rs[i].ToGRPCMessage().(*object.Range)) } } return } -func RangesFromGRPC(rs []*object.Range) (res []Range, err error) { +func RangesFromGRPC(rs []object.Range) (res []Range, err error) { if rs != nil { res = make([]Range, len(rs)) for i := range rs { - if rs[i] != nil { - err = res[i].FromGRPCMessage(rs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&rs[i]) + if err != nil { + return } } } diff --git a/object/grpc/service_frostfs.pb.go b/object/grpc/service_frostfs.pb.go index 0bd0111..dea1b5b 100644 Binary files a/object/grpc/service_frostfs.pb.go and b/object/grpc/service_frostfs.pb.go differ diff --git a/object/grpc/types_frostfs.pb.go b/object/grpc/types_frostfs.pb.go index 04a3e29..4233417 100644 Binary files a/object/grpc/types_frostfs.pb.go and b/object/grpc/types_frostfs.pb.go differ diff --git a/object/lock.go b/object/lock.go index 62ba4a9..585fd09 100644 --- a/object/lock.go +++ b/object/lock.go @@ -89,13 +89,13 @@ func (x *Lock) ToGRPCMessage() grpc.Message { if x != nil { m = new(lock.Lock) - var members []*refsGRPC.ObjectID + var members []refsGRPC.ObjectID if x.members != nil { - members = make([]*refsGRPC.ObjectID, len(x.members)) + members = make([]refsGRPC.ObjectID, len(x.members)) for i := range x.members { - members[i] = x.members[i].ToGRPCMessage().(*refsGRPC.ObjectID) + members[i] = *x.members[i].ToGRPCMessage().(*refsGRPC.ObjectID) } } @@ -119,7 +119,7 @@ func (x *Lock) FromGRPCMessage(m grpc.Message) error { var err error for i := range x.members { - err = x.members[i].FromGRPCMessage(members[i]) + err = x.members[i].FromGRPCMessage(&members[i]) if err != nil { return err } diff --git a/refs/convert.go b/refs/convert.go index 6f06783..da31cdb 100644 --- a/refs/convert.go +++ b/refs/convert.go @@ -52,28 +52,26 @@ func (c *ContainerID) FromGRPCMessage(m grpc.Message) error { return nil } -func ContainerIDsToGRPCMessage(ids []ContainerID) (res []*refs.ContainerID) { +func ContainerIDsToGRPCMessage(ids []ContainerID) (res []refs.ContainerID) { if ids != nil { - res = make([]*refs.ContainerID, 0, len(ids)) + res = make([]refs.ContainerID, 0, len(ids)) for i := range ids { - res = append(res, ids[i].ToGRPCMessage().(*refs.ContainerID)) + res = append(res, *ids[i].ToGRPCMessage().(*refs.ContainerID)) } } return } -func ContainerIDsFromGRPCMessage(idsV2 []*refs.ContainerID) (res []ContainerID, err error) { +func ContainerIDsFromGRPCMessage(idsV2 []refs.ContainerID) (res []ContainerID, err error) { if idsV2 != nil { res = make([]ContainerID, len(idsV2)) for i := range idsV2 { - if idsV2[i] != nil { - err = res[i].FromGRPCMessage(idsV2[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&idsV2[i]) + if err != nil { + return } } } @@ -104,28 +102,26 @@ func (o *ObjectID) FromGRPCMessage(m grpc.Message) error { return nil } -func ObjectIDListToGRPCMessage(ids []ObjectID) (res []*refs.ObjectID) { +func ObjectIDListToGRPCMessage(ids []ObjectID) (res []refs.ObjectID) { if ids != nil { - res = make([]*refs.ObjectID, 0, len(ids)) + res = make([]refs.ObjectID, 0, len(ids)) for i := range ids { - res = append(res, ids[i].ToGRPCMessage().(*refs.ObjectID)) + res = append(res, *ids[i].ToGRPCMessage().(*refs.ObjectID)) } } return } -func ObjectIDListFromGRPCMessage(idsV2 []*refs.ObjectID) (res []ObjectID, err error) { +func ObjectIDListFromGRPCMessage(idsV2 []refs.ObjectID) (res []ObjectID, err error) { if idsV2 != nil { res = make([]ObjectID, len(idsV2)) for i := range idsV2 { - if idsV2[i] != nil { - err = res[i].FromGRPCMessage(idsV2[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&idsV2[i]) + if err != nil { + return } } } diff --git a/session/convert.go b/session/convert.go index b7f334e..d0e83fa 100644 --- a/session/convert.go +++ b/session/convert.go @@ -207,28 +207,26 @@ func (x *XHeader) FromGRPCMessage(m grpc.Message) error { return nil } -func XHeadersToGRPC(xs []XHeader) (res []*session.XHeader) { +func XHeadersToGRPC(xs []XHeader) (res []session.XHeader) { if xs != nil { - res = make([]*session.XHeader, 0, len(xs)) + res = make([]session.XHeader, 0, len(xs)) for i := range xs { - res = append(res, xs[i].ToGRPCMessage().(*session.XHeader)) + res = append(res, *xs[i].ToGRPCMessage().(*session.XHeader)) } } return } -func XHeadersFromGRPC(xs []*session.XHeader) (res []XHeader, err error) { +func XHeadersFromGRPC(xs []session.XHeader) (res []XHeader, err error) { if xs != nil { res = make([]XHeader, len(xs)) for i := range xs { - if xs[i] != nil { - err = res[i].FromGRPCMessage(xs[i]) - if err != nil { - return - } + err = res[i].FromGRPCMessage(&xs[i]) + if err != nil { + return } } } diff --git a/session/grpc/types_frostfs.pb.go b/session/grpc/types_frostfs.pb.go index 4f8bf81..41ff5d9 100644 Binary files a/session/grpc/types_frostfs.pb.go and b/session/grpc/types_frostfs.pb.go differ diff --git a/status/convert.go b/status/convert.go index 0743952..3c5b5bf 100644 --- a/status/convert.go +++ b/status/convert.go @@ -48,13 +48,13 @@ func (x *Status) ToGRPCMessage() grpc.Message { m.SetCode(CodeToGRPC(x.code)) m.SetMessage(x.msg) - var ds []*status.Status_Detail + var ds []status.Status_Detail if ln := len(x.details); ln > 0 { - ds = make([]*status.Status_Detail, 0, ln) + ds = make([]status.Status_Detail, 0, ln) for i := 0; i < ln; i++ { - ds = append(ds, x.details[i].ToGRPCMessage().(*status.Status_Detail)) + ds = append(ds, *x.details[i].ToGRPCMessage().(*status.Status_Detail)) } } @@ -81,10 +81,8 @@ func (x *Status) FromGRPCMessage(m grpc.Message) error { ds = make([]Detail, ln) for i := 0; i < ln; i++ { - if dsV2[i] != nil { - if err := ds[i].FromGRPCMessage(dsV2[i]); err != nil { - return err - } + if err := ds[i].FromGRPCMessage(&dsV2[i]); err != nil { + return err } } } diff --git a/status/grpc/types_frostfs.pb.go b/status/grpc/types_frostfs.pb.go index 5012491..29dfebe 100644 Binary files a/status/grpc/types_frostfs.pb.go and b/status/grpc/types_frostfs.pb.go differ diff --git a/tombstone/grpc/types_frostfs.pb.go b/tombstone/grpc/types_frostfs.pb.go index 8c2e83c..f7bc48c 100644 Binary files a/tombstone/grpc/types_frostfs.pb.go and b/tombstone/grpc/types_frostfs.pb.go differ diff --git a/util/proto/marshal_test.go b/util/proto/marshal_test.go index 5d887ce..1cd7005 100644 --- a/util/proto/marshal_test.go +++ b/util/proto/marshal_test.go @@ -113,6 +113,10 @@ func repPrimitivesEqual(t *testing.T, a *generated.RepPrimitives, b *test.RepPri require.Equal(t, a.FieldE, b.FieldE) require.Equal(t, a.FieldF, b.FieldF) require.Equal(t, a.FieldFu, b.FieldFu) + require.Equal(t, len(a.GetFieldAux()), len(b.GetFieldAux())) + for i := range a.FieldAux { + require.Equal(t, a.GetFieldAux()[i].GetInnerField(), b.GetFieldAux()[i].GetInnerField()) + } } func randIntSlice[T protoInt](n int, includeZero bool) []T { @@ -129,6 +133,14 @@ func randIntSlice[T protoInt](n int, includeZero bool) []T { return r } +func uint32SliceToAux(s []uint32) []generated.RepPrimitives_Aux { + r := make([]generated.RepPrimitives_Aux, len(s)) + for i := range s { + r[i] = generated.RepPrimitives_Aux{InnerField: s[i]} + } + return r +} + func TestStableMarshalRep(t *testing.T) { t.Run("empty", func(t *testing.T) { marshalCases := []struct { @@ -176,6 +188,9 @@ func TestStableMarshalRep(t *testing.T) { {name: "uint64", input: &generated.RepPrimitives{FieldFu: randIntSlice[uint64](1, true)}}, {name: "uint64", input: &generated.RepPrimitives{FieldFu: randIntSlice[uint64](2, true)}}, {name: "uint64", input: &generated.RepPrimitives{FieldFu: randIntSlice[uint64](2, false)}}, + {name: "message", input: &generated.RepPrimitives{FieldAux: uint32SliceToAux(randIntSlice[uint32](1, true))}}, + {name: "message", input: &generated.RepPrimitives{FieldAux: uint32SliceToAux(randIntSlice[uint32](2, true))}}, + {name: "message", input: &generated.RepPrimitives{FieldAux: uint32SliceToAux(randIntSlice[uint32](2, false))}}, } for _, tc := range marshalCases { t.Run(tc.name, func(t *testing.T) { diff --git a/util/proto/test/custom/test_frostfs.pb.go b/util/proto/test/custom/test_frostfs.pb.go index a39bba7..97efa51 100644 Binary files a/util/proto/test/custom/test_frostfs.pb.go and b/util/proto/test/custom/test_frostfs.pb.go differ diff --git a/util/proto/test/test.pb.go b/util/proto/test/test.pb.go index de8ec65..e7d5699 100644 Binary files a/util/proto/test/test.pb.go and b/util/proto/test/test.pb.go differ diff --git a/util/proto/test/test.proto b/util/proto/test/test.proto index f33be49..58cee2f 100644 --- a/util/proto/test/test.proto +++ b/util/proto/test/test.proto @@ -40,4 +40,7 @@ message RepPrimitives { repeated int64 field_e = 5; repeated uint64 field_f = 6; repeated uint64 field_fu = 7 [ packed = false ]; + + message Aux { uint32 inner_field = 1; } + repeated Aux field_aux = 8; } diff --git a/util/protogen/internalgengo/json.go b/util/protogen/internalgengo/json.go index 4ae24e7..f7cd284 100644 --- a/util/protogen/internalgengo/json.go +++ b/util/protogen/internalgengo/json.go @@ -117,7 +117,7 @@ func emitJSONFieldRead(g *protogen.GeneratedFile, f *protogen.Field, name string template = "%s = in.Bytes()" case protoreflect.MessageKind: if f.Desc.IsList() { - g.P("f = new(", fieldType(g, f)[3:], ")") + g.P("f = ", fieldType(g, f)[2:], "{}") } else { g.P("f = new(", fieldType(g, f)[1:], ")") } diff --git a/util/protogen/internalgengo/proto.go b/util/protogen/internalgengo/proto.go index 8894cde..1467541 100644 --- a/util/protogen/internalgengo/proto.go +++ b/util/protogen/internalgengo/proto.go @@ -39,8 +39,8 @@ func emitFieldUnmarshal(g *protogen.GeneratedFile, f *protogen.Field) { g.P("data, ok := fc.MessageData()") g.P(`if !ok { return fmt.Errorf("cannot unmarshal field %s", "`, f.GoName, `") }`) if f.Desc.IsList() { - g.P(name, " = append(", name, ", new(", fieldType(g, f)[3:], "))") - g.P("ff := ", name, "[len(", name, ")-1]") + g.P(name, " = append(", name, ", ", fieldType(g, f)[2:], "{})") + g.P("ff := &", name, "[len(", name, ")-1]") name = "ff" } else if f.Oneof != nil { const tmp = "oneofField" @@ -172,11 +172,12 @@ func emitMarshalRaw(g *protogen.GeneratedFile, f *protogen.Field, name string) { defer g.P("}") name += "[i]" + } else { + g.P("if ", notNil(name), " {") + defer g.P("}") } - g.P("if ", notNil(name), " {") g.P(name, ".EmitProtobuf(mm.AppendMessage(", f.Desc.Number(), "))") - g.P("}") return } diff --git a/util/protogen/internalgengo/proto_field_type.go b/util/protogen/internalgengo/proto_field_type.go index 09f6884..0096751 100644 --- a/util/protogen/internalgengo/proto_field_type.go +++ b/util/protogen/internalgengo/proto_field_type.go @@ -43,7 +43,10 @@ func fieldType(g *protogen.GeneratedFile, field *protogen.Field) structField { case protoreflect.BytesKind: typ = "[]byte" case protoreflect.MessageKind: - typ = structField(g.QualifiedGoIdent(field.Message.GoIdent)).PointerTo() + typ = structField(g.QualifiedGoIdent(field.Message.GoIdent)) + if !field.Desc.IsList() { + typ = typ.PointerTo() + } case protoreflect.GroupKind: panic("unimplemented") } diff --git a/util/protogen/internalgengo/proto_stable_compat.go b/util/protogen/internalgengo/proto_stable_compat.go index c27b9d8..3c4670c 100644 --- a/util/protogen/internalgengo/proto_stable_compat.go +++ b/util/protogen/internalgengo/proto_stable_compat.go @@ -72,7 +72,7 @@ func emitFieldSize(g *protogen.GeneratedFile, f *protogen.Field) { case f.Desc.IsList() && (f.Desc.Kind() == protoreflect.MessageKind || f.Desc.Kind() == protoreflect.Uint64Kind && !f.Desc.IsPacked()): g.P("for i := range ", name, "{") if f.Desc.Kind() == protoreflect.MessageKind { - g.P("size += ", protoPackage.Ident("NestedStructureSize"), "(", f.Desc.Number(), ", ", name, "[i])") + g.P("size += ", protoPackage.Ident("NestedStructureSizeUnchecked"), "(", f.Desc.Number(), ", &", name, "[i])") } else { if f.Desc.Kind() != protoreflect.Uint64Kind { panic("only uint64 unpacked primitive is supported")