From fd100fd8425b82c09eba2e291d1dcbfcb1242774 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 5 Jun 2022 10:36:03 -0600 Subject: more, fixup array init --- pkg/btrfs/btrfsitem/item_uuid.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'pkg/btrfs/btrfsitem/item_uuid.go') diff --git a/pkg/btrfs/btrfsitem/item_uuid.go b/pkg/btrfs/btrfsitem/item_uuid.go index 894ccff..d66e102 100644 --- a/pkg/btrfs/btrfsitem/item_uuid.go +++ b/pkg/btrfs/btrfsitem/item_uuid.go @@ -7,12 +7,10 @@ import ( // The Key for this item is a UUID, and the item is a list of // subvolume IDs (ObjectIDs) that that UUID maps to. -type UUIDMap struct { // UUID_SUBVOL=251 UUID_RECEIVED_SUBVOL=252 - SubvolIDs []internal.ObjID -} +type UUIDMap []internal.ObjID // UUID_SUBVOL=251 UUID_RECEIVED_SUBVOL=252 func (o *UUIDMap) UnmarshalBinary(dat []byte) (int, error) { - o.SubvolIDs = nil + *o = nil var n int for len(dat) > n { var subvolID internal.ObjID @@ -21,14 +19,14 @@ func (o *UUIDMap) UnmarshalBinary(dat []byte) (int, error) { if err != nil { return n, err } - o.SubvolIDs = append(o.SubvolIDs, subvolID) + *o = append(*o, subvolID) } return n, nil } func (o UUIDMap) MarshalBinary() ([]byte, error) { var ret []byte - for _, subvolID := range o.SubvolIDs { + for _, subvolID := range o { bs, err := binstruct.Marshal(subvolID) ret = append(ret, bs...) if err != nil { -- cgit v1.2.3-2-g168b