From ead7281c2038a0ac252af3664659a8dcfb699ac9 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sat, 17 Dec 2016 15:24:13 +0100 Subject: [PATCH] build: Enable gometalinter "unused" check --- build.go | 2 ++ cmd/strelaysrv/main.go | 1 - lib/model/model.go | 14 -------------- lib/protocol/protocol.go | 2 -- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/build.go b/build.go index 5244ae622..fc0846eb0 100644 --- a/build.go +++ b/build.go @@ -299,6 +299,7 @@ func runCommand(cmd string, target target) { ok = gometalinter("structcheck", dirs) && ok ok = gometalinter("varcheck", dirs) && ok ok = gometalinter("ineffassign", dirs) && ok + ok = gometalinter("unused", dirs) && ok if !ok { os.Exit(1) } @@ -369,6 +370,7 @@ func setup() { "github.com/tsenart/deadcode", "golang.org/x/net/html", "golang.org/x/tools/cmd/cover", + "honnef.co/go/unused/cmd/unused", } for _, pkg := range packages { fmt.Println(pkg) diff --git a/cmd/strelaysrv/main.go b/cmd/strelaysrv/main.go index a7431e5b8..6767d65bb 100644 --- a/cmd/strelaysrv/main.go +++ b/cmd/strelaysrv/main.go @@ -54,7 +54,6 @@ func init() { var ( listen string debug bool - proto string sessionAddress []byte sessionPort uint16 diff --git a/lib/model/model.go b/lib/model/model.go index 45f53e6ab..77e5d0c81 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -1070,20 +1070,6 @@ func (m *Model) Closed(conn protocol.Connection, err error) { close(closed) } -// close will close the underlying connection for a given device -func (m *Model) close(device protocol.DeviceID) { - m.pmut.Lock() - conn, ok := m.conn[device] - m.pmut.Unlock() - - if !ok { - // There is no connection to close - return - } - - closeRawConn(conn) -} - // Request returns the specified data segment by reading it from local disk. // Implements the protocol.Model interface. func (m *Model) Request(deviceID protocol.DeviceID, folder, name string, offset int64, hash []byte, fromTemporary bool, buf []byte) error { diff --git a/lib/protocol/protocol.go b/lib/protocol/protocol.go index fd355dc8f..bb5c6d846 100644 --- a/lib/protocol/protocol.go +++ b/lib/protocol/protocol.go @@ -21,8 +21,6 @@ const ( // MaxMessageLen is the largest message size allowed on the wire. (500 MB) MaxMessageLen = 500 * 1000 * 1000 - - hdrSize = 6 ) const (