Skip to content

Commit 2c31edb

Browse files
committed
unconvert: remove unnescessary conversions
Signed-off-by: Kir Kolyshkin <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3a16c72 commit 2c31edb

9 files changed

Lines changed: 19 additions & 21 deletions

File tree

daemon/graphdriver/devmapper/devmapper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func initLoopbacks() error {
4040
// only create new loopback files if they don't exist
4141
if _, err := os.Stat(loopPath); err != nil {
4242
if mkerr := syscall.Mknod(loopPath,
43-
uint32(statT.Mode|syscall.S_IFBLK), int((7<<8)|(i&0xff)|((i&0xfff00)<<12))); mkerr != nil {
43+
uint32(statT.Mode|syscall.S_IFBLK), int((7<<8)|(i&0xff)|((i&0xfff00)<<12))); mkerr != nil { // nolint: unconvert
4444
return mkerr
4545
}
4646
os.Chown(loopPath, int(statT.Uid), int(statT.Gid))

daemon/info_unix_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestParseInitVersion(t *testing.T) {
3939
}
4040

4141
for _, test := range tests {
42-
version, commit, err := parseInitVersion(string(test.output))
42+
version, commit, err := parseInitVersion(test.output)
4343
if test.invalid {
4444
assert.Check(t, is.ErrorContains(err, ""))
4545
} else {
@@ -91,7 +91,7 @@ spec: 1.0.0
9191
}
9292

9393
for _, test := range tests {
94-
version, commit, err := parseRuncVersion(string(test.output))
94+
version, commit, err := parseRuncVersion(test.output)
9595
if test.invalid {
9696
assert.Check(t, is.ErrorContains(err, ""))
9797
} else {

image/fs_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ func TestFSGetInvalidData(t *testing.T) {
2929
store, cleanup := defaultFSStoreBackend(t)
3030
defer cleanup()
3131

32-
id, err := store.Set([]byte("foobar"))
32+
dgst, err := store.Set([]byte("foobar"))
3333
assert.Check(t, err)
3434

35-
dgst := digest.Digest(id)
36-
3735
err = ioutil.WriteFile(filepath.Join(store.(*fs).root, contentDirName, string(dgst.Algorithm()), dgst.Hex()), []byte("foobar2"), 0600)
3836
assert.Check(t, err)
3937

40-
_, err = store.Get(id)
38+
_, err = store.Get(dgst)
4139
assert.Check(t, is.ErrorContains(err, "failed to verify"))
4240
}
4341

@@ -172,7 +170,7 @@ func TestFSGetSet(t *testing.T) {
172170
})
173171

174172
for _, tc := range tcases {
175-
id, err := store.Set([]byte(tc.input))
173+
id, err := store.Set(tc.input)
176174
assert.Check(t, err)
177175
assert.Check(t, is.Equal(tc.expected, id))
178176
}

image/store_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"testing"
77

88
"github.com/docker/docker/layer"
9-
digest "github.com/opencontainers/go-digest"
109
"gotest.tools/assert"
1110
"gotest.tools/assert/cmp"
1211
)
@@ -60,11 +59,11 @@ func TestRestore(t *testing.T) {
6059
assert.NilError(t, err)
6160
assert.Check(t, cmp.Equal(ID(id1), sid1))
6261

63-
sid1, err = is.Search(digest.Digest(id1).Hex()[:6])
62+
sid1, err = is.Search(id1.Hex()[:6])
6463
assert.NilError(t, err)
6564
assert.Check(t, cmp.Equal(ID(id1), sid1))
6665

67-
invalidPattern := digest.Digest(id1).Hex()[1:6]
66+
invalidPattern := id1.Hex()[1:6]
6867
_, err = is.Search(invalidPattern)
6968
assert.ErrorContains(t, err, "No such image")
7069
}

pkg/archive/archive_unix_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func getNlink(path string) (uint64, error) {
166166
return 0, fmt.Errorf("expected type *syscall.Stat_t, got %t", stat.Sys())
167167
}
168168
// We need this conversion on ARM64
169+
// nolint: unconvert
169170
return uint64(statT.Nlink), nil
170171
}
171172

pkg/idtools/idtools_unix_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func TestNewIDMappings(t *testing.T) {
323323

324324
gids, err := tempUser.GroupIds()
325325
assert.Check(t, err)
326-
group, err := user.LookupGroupId(string(gids[0]))
326+
group, err := user.LookupGroupId(gids[0])
327327
assert.Check(t, err)
328328

329329
idMapping, err := NewIdentityMapping(tempUser.Username, group.Name)

pkg/ioutils/fswriters_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestAtomicWriteToFile(t *testing.T) {
4545
if err != nil {
4646
t.Fatalf("Error statting file: %v", err)
4747
}
48-
if expected := os.FileMode(testMode); st.Mode() != expected {
48+
if expected := testMode; st.Mode() != expected {
4949
t.Fatalf("Mode mismatched, expected %o, got %o", expected, st.Mode())
5050
}
5151
}
@@ -93,7 +93,7 @@ func TestAtomicWriteSetCommit(t *testing.T) {
9393
if err != nil {
9494
t.Fatalf("Error statting file: %v", err)
9595
}
96-
if expected := os.FileMode(testMode); st.Mode() != expected {
96+
if expected := testMode; st.Mode() != expected {
9797
t.Fatalf("Mode mismatched, expected %o, got %o", expected, st.Mode())
9898
}
9999

pkg/system/chtimes_unix_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestChtimesLinux(t *testing.T) {
2828
}
2929

3030
stat := f.Sys().(*syscall.Stat_t)
31-
aTime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
31+
aTime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) // nolint: unconvert
3232
if aTime != unixEpochTime {
3333
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
3434
}
@@ -42,7 +42,7 @@ func TestChtimesLinux(t *testing.T) {
4242
}
4343

4444
stat = f.Sys().(*syscall.Stat_t)
45-
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
45+
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) // nolint: unconvert
4646
if aTime != unixEpochTime {
4747
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
4848
}
@@ -56,7 +56,7 @@ func TestChtimesLinux(t *testing.T) {
5656
}
5757

5858
stat = f.Sys().(*syscall.Stat_t)
59-
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
59+
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) // nolint: unconvert
6060
if aTime != unixEpochTime {
6161
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
6262
}
@@ -70,7 +70,7 @@ func TestChtimesLinux(t *testing.T) {
7070
}
7171

7272
stat = f.Sys().(*syscall.Stat_t)
73-
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
73+
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) // nolint: unconvert
7474
if aTime != afterUnixEpochTime {
7575
t.Fatalf("Expected: %s, got: %s", afterUnixEpochTime, aTime)
7676
}
@@ -84,7 +84,7 @@ func TestChtimesLinux(t *testing.T) {
8484
}
8585

8686
stat = f.Sys().(*syscall.Stat_t)
87-
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
87+
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) // nolint: unconvert
8888
if aTime.Truncate(time.Second) != unixMaxTime.Truncate(time.Second) {
8989
t.Fatalf("Expected: %s, got: %s", unixMaxTime.Truncate(time.Second), aTime.Truncate(time.Second))
9090
}

restartmanager/restartmanager_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestRestartManagerTimeout(t *testing.T) {
1111
rm := New(container.RestartPolicy{Name: "always"}, 0).(*restartManager)
12-
var duration = time.Duration(1 * time.Second)
12+
var duration = 1 * time.Second
1313
should, _, err := rm.ShouldRestart(0, false, duration)
1414
if err != nil {
1515
t.Fatal(err)
@@ -25,7 +25,7 @@ func TestRestartManagerTimeout(t *testing.T) {
2525
func TestRestartManagerTimeoutReset(t *testing.T) {
2626
rm := New(container.RestartPolicy{Name: "always"}, 0).(*restartManager)
2727
rm.timeout = 5 * time.Second
28-
var duration = time.Duration(10 * time.Second)
28+
var duration = 10 * time.Second
2929
_, _, err := rm.ShouldRestart(0, false, duration)
3030
if err != nil {
3131
t.Fatal(err)

0 commit comments

Comments
 (0)