Skip to content

Commit ebf3cbf

Browse files
dswarbrickdiscordianfish
authored andcommitted
zfs: drop superfluous typecasting of test values
Drop superfluous and overly pedantic typecasting for values that fit within 32 bits or where type comparison is already hinted. Signed-off-by: Daniel Swarbrick <[email protected]>
1 parent 6c96239 commit ebf3cbf

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

collector/zfs_linux_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ func TestArcstatsParsing(t *testing.T) {
3838
err = c.parseProcfsFile(arcstatsFile, "arcstats", func(s zfsSysctl, v interface{}) {
3939

4040
if s == zfsSysctl("kstat.zfs.misc.arcstats.hits") {
41-
if v.(uint64) != uint64(8772612) {
41+
if v.(uint64) != 8772612 {
4242
t.Fatalf("Incorrect value parsed from procfs data")
4343
}
4444
} else if s == zfsSysctl("kstat.zfs.misc.arcstats.memory_available_bytes") {
45-
if v.(int64) != int64(-922337203685477580) {
45+
if v.(int64) != -922337203685477580 {
4646
t.Fatalf("Incorrect value parsed from procfs data")
4747
}
4848
} else {
@@ -80,7 +80,7 @@ func TestZfetchstatsParsing(t *testing.T) {
8080

8181
handlerCalled = true
8282

83-
if v.(uint64) != uint64(7067992) {
83+
if v.(uint64) != 7067992 {
8484
t.Fatalf("Incorrect value parsed from procfs data")
8585
}
8686

@@ -116,7 +116,7 @@ func TestZilParsing(t *testing.T) {
116116

117117
handlerCalled = true
118118

119-
if v.(uint64) != uint64(10) {
119+
if v.(uint64) != 10 {
120120
t.Fatalf("Incorrect value parsed from procfs data")
121121
}
122122

@@ -152,7 +152,7 @@ func TestVdevCacheStatsParsing(t *testing.T) {
152152

153153
handlerCalled = true
154154

155-
if v.(uint64) != uint64(40) {
155+
if v.(uint64) != 40 {
156156
t.Fatalf("Incorrect value parsed from procfs data")
157157
}
158158

@@ -188,7 +188,7 @@ func TestXuioStatsParsing(t *testing.T) {
188188

189189
handlerCalled = true
190190

191-
if v.(uint64) != uint64(32) {
191+
if v.(uint64) != 32 {
192192
t.Fatalf("Incorrect value parsed from procfs data")
193193
}
194194

@@ -224,7 +224,7 @@ func TestFmParsing(t *testing.T) {
224224

225225
handlerCalled = true
226226

227-
if v.(uint64) != uint64(18) {
227+
if v.(uint64) != 18 {
228228
t.Fatalf("Incorrect value parsed from procfs data")
229229
}
230230

@@ -260,7 +260,7 @@ func TestDmuTxParsing(t *testing.T) {
260260

261261
handlerCalled = true
262262

263-
if v.(uint64) != uint64(3532844) {
263+
if v.(uint64) != 3532844 {
264264
t.Fatalf("Incorrect value parsed from procfs data")
265265
}
266266

@@ -300,7 +300,7 @@ func TestZpoolParsing(t *testing.T) {
300300

301301
handlerCalled = true
302302

303-
if v != uint64(1884160) && v != uint64(2826240) {
303+
if v != 1884160 && v != 2826240 {
304304
t.Fatalf("Incorrect value parsed from procfs data %v", v)
305305
}
306306

@@ -340,7 +340,7 @@ func TestZpoolObjsetParsing(t *testing.T) {
340340

341341
handlerCalled = true
342342

343-
if v != uint64(0) && v != uint64(4) && v != uint64(10) {
343+
if v != 0 && v != 4 && v != 10 {
344344
t.Fatalf("Incorrect value parsed from procfs data %v", v)
345345
}
346346

@@ -376,7 +376,7 @@ func TestAbdstatsParsing(t *testing.T) {
376376

377377
handlerCalled = true
378378

379-
if v.(uint64) != uint64(223232) {
379+
if v.(uint64) != 223232 {
380380
t.Fatalf("Incorrect value parsed from procfs abdstats data")
381381
}
382382

@@ -412,7 +412,7 @@ func TestDbufstatsParsing(t *testing.T) {
412412

413413
handlerCalled = true
414414

415-
if v.(uint64) != uint64(108807) {
415+
if v.(uint64) != 108807 {
416416
t.Fatalf("Incorrect value parsed from procfs dbufstats data")
417417
}
418418

@@ -448,7 +448,7 @@ func TestDnodestatsParsing(t *testing.T) {
448448

449449
handlerCalled = true
450450

451-
if v.(uint64) != uint64(37617) {
451+
if v.(uint64) != 37617 {
452452
t.Fatalf("Incorrect value parsed from procfs dnodestats data")
453453
}
454454

@@ -484,7 +484,7 @@ func TestVdevMirrorstatsParsing(t *testing.T) {
484484

485485
handlerCalled = true
486486

487-
if v.(uint64) != uint64(94) {
487+
if v.(uint64) != 94 {
488488
t.Fatalf("Incorrect value parsed from procfs vdev_mirror_stats data")
489489
}
490490

@@ -521,26 +521,26 @@ func TestPoolStateParsing(t *testing.T) {
521521
handlerCalled = true
522522

523523
if poolName == "pool1" {
524-
if isActive != uint64(1) && stateName == "online" {
524+
if isActive != 1 && stateName == "online" {
525525
t.Fatalf("Incorrect parsed value for online state")
526526
}
527-
if isActive != uint64(0) && stateName != "online" {
527+
if isActive != 0 && stateName != "online" {
528528
t.Fatalf("Incorrect parsed value for online state")
529529
}
530530
}
531531
if poolName == "poolz1" {
532-
if isActive != uint64(1) && stateName == "degraded" {
532+
if isActive != 1 && stateName == "degraded" {
533533
t.Fatalf("Incorrect parsed value for degraded state")
534534
}
535-
if isActive != uint64(0) && stateName != "degraded" {
535+
if isActive != 0 && stateName != "degraded" {
536536
t.Fatalf("Incorrect parsed value for degraded state")
537537
}
538538
}
539539
if poolName == "pool2" {
540-
if isActive != uint64(1) && stateName == "suspended" {
540+
if isActive != 1 && stateName == "suspended" {
541541
t.Fatalf("Incorrect parsed value for suspended state")
542542
}
543-
if isActive != uint64(0) && stateName != "suspended" {
543+
if isActive != 0 && stateName != "suspended" {
544544
t.Fatalf("Incorrect parsed value for suspended state")
545545
}
546546
}

0 commit comments

Comments
 (0)