summaryrefslogtreecommitdiff
path: root/lib/btrfs/btrfstree
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-01 19:27:49 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-01 22:42:08 -0700
commitc307e7048da3c02e1e540eab227def7fec7340cc (patch)
treea134fe5f8822e0d9faa7684b6887bc2c139ecd17 /lib/btrfs/btrfstree
parent046162cc1ff55985e3dd45eb191729ead1f9cc8d (diff)
lint: Turn on gocritic
Diffstat (limited to 'lib/btrfs/btrfstree')
-rw-r--r--lib/btrfs/btrfstree/ops.go14
-rw-r--r--lib/btrfs/btrfstree/types_node.go9
-rw-r--r--lib/btrfs/btrfstree/types_node_test.go5
3 files changed, 13 insertions, 15 deletions
diff --git a/lib/btrfs/btrfstree/ops.go b/lib/btrfs/btrfstree/ops.go
index f2eb6f0..ddab630 100644
--- a/lib/btrfs/btrfstree/ops.go
+++ b/lib/btrfs/btrfstree/ops.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -156,14 +156,12 @@ func (fs TreeOperatorImpl) treeWalk(ctx context.Context, path TreePath, errHandl
}
if err != nil {
errHandle(&TreeError{Path: path, Err: err})
- } else {
- if cbs.Node != nil {
- if err := cbs.Node(path, node); err != nil {
- if errors.Is(err, iofs.SkipDir) {
- return
- }
- errHandle(&TreeError{Path: path, Err: err})
+ } else if cbs.Node != nil {
+ if err := cbs.Node(path, node); err != nil {
+ if errors.Is(err, iofs.SkipDir) {
+ return
}
+ errHandle(&TreeError{Path: path, Err: err})
}
}
if ctx.Err() != nil {
diff --git a/lib/btrfs/btrfstree/types_node.go b/lib/btrfs/btrfstree/types_node.go
index 299c433..d2e91de 100644
--- a/lib/btrfs/btrfstree/types_node.go
+++ b/lib/btrfs/btrfstree/types_node.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -212,10 +212,11 @@ func (node Node) MarshalBinary() ([]byte, error) {
if bs, err := binstruct.Marshal(node.Head); err != nil {
return buf, err
- } else if len(bs) != binstruct.StaticSize(NodeHeader{}) {
- return nil, fmt.Errorf("header is %v bytes but expected %v",
- len(bs), binstruct.StaticSize(NodeHeader{}))
} else {
+ if len(bs) != binstruct.StaticSize(NodeHeader{}) {
+ return nil, fmt.Errorf("header is %v bytes but expected %v",
+ len(bs), binstruct.StaticSize(NodeHeader{}))
+ }
copy(buf, bs)
}
diff --git a/lib/btrfs/btrfstree/types_node_test.go b/lib/btrfs/btrfstree/types_node_test.go
index 040b90c..80855d8 100644
--- a/lib/btrfs/btrfstree/types_node_test.go
+++ b/lib/btrfs/btrfstree/types_node_test.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2022 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -23,13 +23,12 @@ func FuzzRoundTripNode(f *testing.F) {
n, err := binstruct.Unmarshal(inDat, &node)
if err != nil {
t.Logf("err=%v", err)
- //require.Equal(t, 0, n)
} else {
require.Equal(t, len(inDat), n)
outDat, err := binstruct.Marshal(node)
require.NoError(t, err)
- require.Equal(t, inDat[:], outDat)
+ require.Equal(t, inDat, outDat)
}
})
}