From 33de7f09d31063ef2a4380bb2f2692653a6de06c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 9 Mar 2023 16:43:39 -0700 Subject: containers: Add OptionalValue and OptionalNil --- cmd/btrfs-rec/inspect/rebuildmappings/process.go | 5 +---- cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go | 5 +---- cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go | 5 +---- cmd/btrfs-rec/inspect/rebuildtrees/scan.go | 2 +- cmd/btrfs-rec/inspect_lstrees.go | 2 +- 5 files changed, 5 insertions(+), 14 deletions(-) (limited to 'cmd') diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process.go b/cmd/btrfs-rec/inspect/rebuildmappings/process.go index e42acf9..7a49cc6 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process.go @@ -137,10 +137,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR PAddr: otherPAddr.Add(-offsetWithinChunk), Size: bg.Size, SizeLocked: true, - Flags: containers.Optional[btrfsvol.BlockGroupFlags]{ - OK: true, - Val: bg.Flags, - }, + Flags: containers.OptionalValue(bg.Flags), } if err := fs.LV.AddMapping(mapping); err != nil { dlog.Errorf(ctx, "error: adding flags from blockgroup: %v", err) diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go index ef9d9aa..5148e5c 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go @@ -63,10 +63,7 @@ func matchBlockGroupSumsExact(ctx context.Context, PAddr: matches[0], Size: blockgroup.Size, SizeLocked: true, - Flags: containers.Optional[btrfsvol.BlockGroupFlags]{ - OK: true, - Val: blockgroup.Flags, - }, + Flags: containers.OptionalValue(blockgroup.Flags), } if err := fs.LV.AddMapping(mapping); err != nil { dlog.Errorf(ctx, "error: %v", err) diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go index 905211c..f3557cd 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go @@ -123,10 +123,7 @@ func matchBlockGroupSumsFuzzy(ctx context.Context, PAddr: best.Dat[0].PAddr, Size: blockgroup.Size, SizeLocked: true, - Flags: containers.Optional[btrfsvol.BlockGroupFlags]{ - OK: true, - Val: blockgroup.Flags, - }, + Flags: containers.OptionalValue(blockgroup.Flags), } if err := fs.LV.AddMapping(mapping); err != nil { dlog.Errorf(ctx, "error: %v", err) diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go index 961ff8d..ada9f6f 100644 --- a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go +++ b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go @@ -72,7 +72,7 @@ func ScanDevices(ctx context.Context, fs *btrfs.FS, nodeList []btrfsvol.LogicalA return ScanDevicesResult{}, err } node, err := btrfstree.ReadNode[btrfsvol.LogicalAddr](fs, *sb, laddr, btrfstree.NodeExpectations{ - LAddr: containers.Optional[btrfsvol.LogicalAddr]{OK: true, Val: laddr}, + LAddr: containers.OptionalValue(laddr), }) if err != nil { node.Free() diff --git a/cmd/btrfs-rec/inspect_lstrees.go b/cmd/btrfs-rec/inspect_lstrees.go index 1541012..cad1a37 100644 --- a/cmd/btrfs-rec/inspect_lstrees.go +++ b/cmd/btrfs-rec/inspect_lstrees.go @@ -106,7 +106,7 @@ func init() { } visitedNodes.Insert(laddr) node, err := btrfstree.ReadNode[btrfsvol.LogicalAddr](fs, *sb, laddr, btrfstree.NodeExpectations{ - LAddr: containers.Optional[btrfsvol.LogicalAddr]{OK: true, Val: laddr}, + LAddr: containers.OptionalValue(laddr), }) if err != nil { treeErrCnt++ -- cgit v1.2.3-2-g168b