mirror of
https://github.com/golang/sys.git
synced 2026-02-08 11:46:04 +03:00
unix: fix several staticcheck issues
Resolves a number of issues, except for the clen function being unused on Linux, as that would require a larger refactor which probably isn't strictly necessary. $ staticcheck . affinity_linux.go:94:8: const m3 is unused (U1000) affinity_linux.go:95:8: const m4 is unused (U1000) sendfile_test.go:41:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002) sendfile_test.go:47:6: this value of err is never used (SA4006) syscall_linux_test.go:519:21: should use time.Since instead of time.Now().Sub (S1012) syscall_linux_test.go:530:21: should use time.Since instead of time.Now().Sub (S1012) syscall_test.go:66:2: this value of ts is never used (SA4006) syscall_test.go:67:2: this value of ts is never used (SA4006) syscall_unix.go:88:6: func clen is unused (U1000) Change-Id: I2611b4559339cea758b5da27ea1f36fb8cc2df3f Reviewed-on: https://go-review.googlesource.com/c/sys/+/188037 Run-TryBot: Matt Layher <mdlayher@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
@@ -91,9 +91,13 @@ func onesCount64(x uint64) int {
|
||||
const m0 = 0x5555555555555555 // 01010101 ...
|
||||
const m1 = 0x3333333333333333 // 00110011 ...
|
||||
const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ...
|
||||
const m3 = 0x00ff00ff00ff00ff // etc.
|
||||
const m4 = 0x0000ffff0000ffff
|
||||
|
||||
// Unused in this function, but definitions preserved for
|
||||
// documentation purposes:
|
||||
//
|
||||
// const m3 = 0x00ff00ff00ff00ff // etc.
|
||||
// const m4 = 0x0000ffff0000ffff
|
||||
//
|
||||
// Implementation: Parallel summing of adjacent bits.
|
||||
// See "Hacker's Delight", Chap. 5: Counting Bits.
|
||||
// The following pattern shows the general approach:
|
||||
|
||||
@@ -41,10 +41,15 @@ func TestSendfile(t *testing.T) {
|
||||
go func() {
|
||||
conn, err := ln.Accept()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Errorf("failed to accept: %v", err)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
b, err := ioutil.ReadAll(conn)
|
||||
if err != nil {
|
||||
t.Errorf("failed to read: %v", err)
|
||||
return
|
||||
}
|
||||
if string(b) != contents {
|
||||
t.Errorf("contents not transmitted: got %s (len=%d), want %s", string(b), len(b), contents)
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ func TestClockNanosleep(t *testing.T) {
|
||||
t.Skip("clock_nanosleep syscall is not available, skipping test")
|
||||
} else if err != nil {
|
||||
t.Errorf("ClockNanosleep(CLOCK_MONOTONIC, 0, %#v, nil) = %v", &rel, err)
|
||||
} else if slept := time.Now().Sub(start); slept < delay {
|
||||
} else if slept := time.Since(start); slept < delay {
|
||||
t.Errorf("ClockNanosleep(CLOCK_MONOTONIC, 0, %#v, nil) slept only %v", &rel, slept)
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ func TestClockNanosleep(t *testing.T) {
|
||||
err = unix.ClockNanosleep(unix.CLOCK_REALTIME, unix.TIMER_ABSTIME, &abs, nil)
|
||||
if err != nil {
|
||||
t.Errorf("ClockNanosleep(CLOCK_REALTIME, TIMER_ABSTIME, %#v (=%v), nil) = %v", &abs, until, err)
|
||||
} else if slept := time.Now().Sub(start); slept < delay {
|
||||
} else if slept := time.Since(start); slept < delay {
|
||||
t.Errorf("ClockNanosleep(CLOCK_REALTIME, TIMER_ABSTIME, %#v (=%v), nil) slept only %v", &abs, until, slept)
|
||||
}
|
||||
|
||||
|
||||
@@ -62,13 +62,10 @@ func TestUname(t *testing.T) {
|
||||
// Test that this compiles. (Issue #31735)
|
||||
func TestStatFieldNames(t *testing.T) {
|
||||
var st unix.Stat_t
|
||||
var ts *unix.Timespec
|
||||
ts = &st.Atim
|
||||
ts = &st.Mtim
|
||||
ts = &st.Ctim
|
||||
_ = ts
|
||||
secs := int64(st.Mtim.Sec)
|
||||
nsecs := int64(st.Mtim.Nsec)
|
||||
_ = secs
|
||||
_ = nsecs
|
||||
var _ *unix.Timespec
|
||||
_ = &st.Atim
|
||||
_ = &st.Mtim
|
||||
_ = &st.Ctim
|
||||
_ = int64(st.Mtim.Sec)
|
||||
_ = int64(st.Mtim.Nsec)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user