Merge "ref: Remove dead code detected by intellij."
diff --git a/cmd/mounttable/impl.go b/cmd/mounttable/impl.go
index f3b4974..25a0c80 100644
--- a/cmd/mounttable/impl.go
+++ b/cmd/mounttable/impl.go
@@ -20,7 +20,6 @@
"v.io/v23/naming"
"v.io/v23/options"
"v.io/v23/rpc"
- "v.io/v23/security"
"v.io/x/ref/lib/v23cmd"
_ "v.io/x/ref/runtime/factories/generic"
@@ -201,25 +200,3 @@
`,
Children: []*cmdline.Command{cmdGlob, cmdMount, cmdUnmount, cmdResolveStep},
}
-
-func blessingPatternsFromServer(ctx *context.T, server string) ([]security.BlessingPattern, error) {
- ctx.Infof("Contacting %q to determine the blessings presented by it", server)
- ctx, cancel := context.WithTimeout(ctx, time.Minute)
- defer cancel()
- call, err := v23.GetClient(ctx).StartCall(ctx, server, rpc.ReservedSignature, nil)
- if err != nil {
- return nil, fmt.Errorf("Unable to extract blessings presented by %q: %v", server, err)
- }
- blessings, _ := call.RemoteBlessings()
- if len(blessings) == 0 {
- return nil, fmt.Errorf("No recognizable blessings presented by %q, it cannot be securely mounted", server)
- }
- // This translation between BlessingPattern and string is silly!
- // Kill the BlessingPatterns type and make methods on that type
- // functions instead!
- patterns := make([]security.BlessingPattern, len(blessings))
- for i := range blessings {
- patterns[i] = security.BlessingPattern(blessings[i])
- }
- return patterns, nil
-}
diff --git a/lib/security/bcrypter/crypter_test.go b/lib/security/bcrypter/crypter_test.go
index c686349..37bee26 100644
--- a/lib/security/bcrypter/crypter_test.go
+++ b/lib/security/bcrypter/crypter_test.go
@@ -29,7 +29,7 @@
return []byte("AThirtyTwoBytePieceOfTextThisIs!")
}
-func TextExtract(t *testing.T) {
+func TestExtract(t *testing.T) {
ctx, shutdown := context.RootContext()
defer shutdown()
@@ -50,7 +50,7 @@
if got := key.Blessing(); got != b {
t.Fatalf("extracted key is for blessing %v, want key for blessing %v", got, b)
}
- if got, want := key.Params, googleYoutube.Params(); !reflect.DeepEqual(got, want) {
+ if got, want := key.Params(), googleYoutube.Params(); !reflect.DeepEqual(got, want) {
t.Fatalf("extract key is for params %v, want key for params %v", got, want)
}
}
diff --git a/lib/security/testutil_test.go b/lib/security/testutil_test.go
index 4118e85..fea678f 100644
--- a/lib/security/testutil_test.go
+++ b/lib/security/testutil_test.go
@@ -54,14 +54,6 @@
return p, def
}
-func bless(blesser, blessed security.Principal, with security.Blessings, extension string) security.Blessings {
- b, err := blesser.Bless(blessed.PublicKey(), with, extension, security.UnconstrainedUse())
- if err != nil {
- panic(err)
- }
- return b
-}
-
func blessSelf(p security.Principal, name string) security.Blessings {
b, err := p.BlessSelf(name)
if err != nil {
diff --git a/lib/vdl/opconst/big_complex.go b/lib/vdl/opconst/big_complex.go
index 3d204d1..da2a8e0 100644
--- a/lib/vdl/opconst/big_complex.go
+++ b/lib/vdl/opconst/big_complex.go
@@ -25,11 +25,6 @@
return &bigComplex{re: *re}
}
-// imagComplex returns a bigComplex with real part zero, and imaginary part im.
-func imagComplex(im *big.Rat) *bigComplex {
- return &bigComplex{im: *im}
-}
-
func (z *bigComplex) SetComplex128(c complex128) *bigComplex {
z.re.SetFloat64(real(c))
z.im.SetFloat64(imag(c))
diff --git a/runtime/internal/flow/conn/auth_test.go b/runtime/internal/flow/conn/auth_test.go
index 285789c..c6478b6 100644
--- a/runtime/internal/flow/conn/auth_test.go
+++ b/runtime/internal/flow/conn/auth_test.go
@@ -132,16 +132,6 @@
func (fc *fakeDischargeClient) Close() {}
func (fc *fakeDischargeClient) Closed() <-chan struct{} { return nil }
-func patterns(ctx *context.T) []security.BlessingPattern {
- p := v23.GetPrincipal(ctx)
- b := p.BlessingStore().Default()
- var patterns []security.BlessingPattern
- for _, n := range security.BlessingNames(p, b) {
- patterns = append(patterns, security.BlessingPattern(n))
- }
- return patterns
-}
-
func TestUnidirectional(t *testing.T) {
defer goroutines.NoLeaks(t, leakWaitTime)()
diff --git a/runtime/internal/flow/manager/conncache.go b/runtime/internal/flow/manager/conncache.go
index 0e4467d..63316e0 100644
--- a/runtime/internal/flow/manager/conncache.go
+++ b/runtime/internal/flow/manager/conncache.go
@@ -267,20 +267,6 @@
}
}
-// matchBlessings return true if the intersection of a and b is not empty.
-func matchBlessings(a, b []string) bool {
- m := make(map[string]bool, len(a))
- for _, i := range a {
- m[i] = true
- }
- for _, j := range b {
- if m[j] {
- return true
- }
- }
- return false
-}
-
// TODO(suharshs): If sorting the connections becomes too slow, switch to
// container/heap instead of sorting all the connections.
type connEntries []*connEntry
diff --git a/runtime/internal/naming/namespace/all_test.go b/runtime/internal/naming/namespace/all_test.go
index 20e550e..277c65c 100644
--- a/runtime/internal/naming/namespace/all_test.go
+++ b/runtime/internal/naming/namespace/all_test.go
@@ -186,18 +186,10 @@
doResolveTest(t, "ResolveToMountTable", ns.ResolveToMountTable, ctx, name, want)
}
-func testResolveToMountTableWithPattern(t *testing.T, ctx *context.T, ns namespace.T, name string, pattern naming.NamespaceOpt, want ...string) {
- doResolveTest(t, "ResolveToMountTable", ns.ResolveToMountTable, ctx, name, want, pattern)
-}
-
func testResolve(t *testing.T, ctx *context.T, ns namespace.T, name string, want ...string) {
doResolveTest(t, "Resolve", ns.Resolve, ctx, name, want)
}
-func testResolveWithPattern(t *testing.T, ctx *context.T, ns namespace.T, name string, pattern naming.NamespaceOpt, want ...string) {
- doResolveTest(t, "Resolve", ns.Resolve, ctx, name, want, pattern)
-}
-
type serverEntry struct {
mountPoint string
stop func() error
@@ -631,14 +623,6 @@
}
}
-func bless(blesser, delegate security.Principal, extension string) {
- b, err := blesser.Bless(delegate.PublicKey(), blesser.BlessingStore().Default(), extension, security.UnconstrainedUse())
- if err != nil {
- panic(err)
- }
- delegate.BlessingStore().SetDefault(b)
-}
-
func TestAuthorizationDuringResolve(t *testing.T) {
ctx, shutdown := test.V23Init()
defer shutdown()
diff --git a/runtime/internal/naming/namespace/mount.go b/runtime/internal/naming/namespace/mount.go
index f181b08..9c0390c 100644
--- a/runtime/internal/naming/namespace/mount.go
+++ b/runtime/internal/naming/namespace/mount.go
@@ -11,7 +11,6 @@
"v.io/v23/context"
"v.io/v23/naming"
"v.io/v23/options"
- "v.io/v23/security"
"v.io/x/ref/lib/apilog"
)
@@ -80,11 +79,3 @@
ctx.VI(1).Infof("Remove(%s, %v) -> %v", name, deleteSubtree, err)
return err
}
-
-func str2pattern(strs []string) (ret []security.BlessingPattern) {
- ret = make([]security.BlessingPattern, len(strs))
- for i, s := range strs {
- ret[i] = security.BlessingPattern(s)
- }
- return
-}
diff --git a/runtime/internal/naming/namespace/namespace.go b/runtime/internal/naming/namespace/namespace.go
index 38dd7e7..d02494f 100644
--- a/runtime/internal/naming/namespace/namespace.go
+++ b/runtime/internal/naming/namespace/namespace.go
@@ -182,16 +182,6 @@
return ctx
}
-// withTimeoutAndCancel returns a new context with a deadline and a cancellation function.
-func withTimeoutAndCancel(ctx *context.T) (nctx *context.T, cancel context.CancelFunc) {
- if _, ok := ctx.Deadline(); !ok {
- nctx, cancel = context.WithTimeout(ctx, callTimeout)
- } else {
- nctx, cancel = context.WithCancel(ctx)
- }
- return
-}
-
// CacheCtl implements naming.Namespace.CacheCtl
func (ns *namespace) CacheCtl(ctls ...naming.CacheCtl) []naming.CacheCtl {
defer apilog.LogCallf(nil, "ctls...=%v", ctls)(nil, "") // gologcop: DO NOT EDIT, MUST BE FIRST STATEMENT
diff --git a/runtime/internal/naming/namespace/stub.go b/runtime/internal/naming/namespace/stub.go
index 9c0ca59..5bc30d3 100644
--- a/runtime/internal/naming/namespace/stub.go
+++ b/runtime/internal/naming/namespace/stub.go
@@ -12,10 +12,3 @@
}
return
}
-
-func convertStringsToServers(servers []string) (ret []naming.MountedServer) {
- for _, s := range servers {
- ret = append(ret, naming.MountedServer{Server: s})
- }
- return
-}
diff --git a/runtime/internal/rpc/benchmark/simple/main_android.go b/runtime/internal/rpc/benchmark/simple/main_android.go
index d07fee2..9d8fe52 100644
--- a/runtime/internal/rpc/benchmark/simple/main_android.go
+++ b/runtime/internal/rpc/benchmark/simple/main_android.go
@@ -10,11 +10,12 @@
package main
import (
+ "time"
+
"golang.org/x/mobile/app"
"golang.org/x/mobile/event/lifecycle"
"golang.org/x/mobile/event/paint"
"golang.org/x/mobile/gl"
- "time"
)
func main() {
diff --git a/runtime/internal/rpc/roaming_test.go b/runtime/internal/rpc/roaming_test.go
index 9857d95..c064de0 100644
--- a/runtime/internal/rpc/roaming_test.go
+++ b/runtime/internal/rpc/roaming_test.go
@@ -6,7 +6,6 @@
import (
"net"
- "sort"
"strings"
"testing"
@@ -156,12 +155,3 @@
}
return addrs
}
-
-func endpointToStrings(eps []naming.Endpoint) []string {
- r := []string{}
- for _, ep := range eps {
- r = append(r, ep.String())
- }
- sort.Strings(r)
- return r
-}
diff --git a/runtime/internal/rpc/server_authorizer.go b/runtime/internal/rpc/server_authorizer.go
index 9dedfce..b84a10d 100644
--- a/runtime/internal/rpc/server_authorizer.go
+++ b/runtime/internal/rpc/server_authorizer.go
@@ -71,17 +71,3 @@
}
return nil
}
-
-func canCreateServerAuthorizer(ctx *context.T, opts []rpc.CallOpt) error {
- policy := false
- for _, o := range opts {
- switch o.(type) {
- case options.ServerAuthorizer:
- if policy {
- return verror.New(errMultipleAuthorizationPolicies, ctx)
- }
- policy = true
- }
- }
- return nil
-}
diff --git a/runtime/internal/rpc/test/client_test.go b/runtime/internal/rpc/test/client_test.go
index a6932ca..eefb38e 100644
--- a/runtime/internal/rpc/test/client_test.go
+++ b/runtime/internal/rpc/test/client_test.go
@@ -396,10 +396,6 @@
// logErr("timeout to server", err)
}
-func simpleResolver(ctx *context.T, network, address string) (string, string, error) {
- return network, address, nil
-}
-
type closeConn struct {
ctx *context.T
flow.Conn
diff --git a/runtime/internal/rpc/testutil_test.go b/runtime/internal/rpc/testutil_test.go
index e08d80a..6acff51 100644
--- a/runtime/internal/rpc/testutil_test.go
+++ b/runtime/internal/rpc/testutil_test.go
@@ -5,8 +5,6 @@
package rpc
import (
- "reflect"
- "testing"
"time"
"v.io/v23"
@@ -14,69 +12,12 @@
"v.io/v23/naming"
"v.io/v23/security"
"v.io/v23/vdl"
- "v.io/v23/verror"
"v.io/v23/vtrace"
"v.io/x/ref/lib/flags"
ivtrace "v.io/x/ref/runtime/internal/vtrace"
"v.io/x/ref/test"
)
-func makeResultPtrs(ins []interface{}) []interface{} {
- outs := make([]interface{}, len(ins))
- for ix, in := range ins {
- typ := reflect.TypeOf(in)
- if typ == nil {
- // Nil indicates interface{}.
- var empty interface{}
- typ = reflect.ValueOf(&empty).Elem().Type()
- }
- outs[ix] = reflect.New(typ).Interface()
- }
- return outs
-}
-
-func checkResultPtrs(t *testing.T, name string, gotptrs, want []interface{}) {
- for ix, res := range gotptrs {
- got := reflect.ValueOf(res).Elem().Interface()
- want := want[ix]
- switch g := got.(type) {
- case verror.E:
- w, ok := want.(verror.E)
- // don't use reflect deep equal on verror's since they contain
- // a list of stack PCs which will be different.
- if !ok {
- t.Errorf("%s result %d got type %T, want %T", name, ix, g, w)
- }
- if verror.ErrorID(g) != w.ID {
- t.Errorf("%s result %d got %v, want %v", name, ix, g, w)
- }
- default:
- if !reflect.DeepEqual(got, want) {
- t.Errorf("%s result %d got %v, want %v", name, ix, got, want)
- }
- }
-
- }
-}
-
-func mkCaveat(cav security.Caveat, err error) security.Caveat {
- if err != nil {
- panic(err)
- }
- return cav
-}
-
-func bless(blesser, blessed security.Principal, extension string, caveats ...security.Caveat) security.Blessings {
- if len(caveats) == 0 {
- caveats = append(caveats, security.UnconstrainedUse())
- }
- b, err := blesser.Bless(blessed.PublicKey(), blesser.BlessingStore().Default(), extension, caveats[0], caveats[1:]...)
- if err != nil {
- panic(err)
- }
- return b
-}
-
func initForTest() (*context.T, v23.Shutdown) {
ctx, shutdown := test.V23Init()
ctx, err := ivtrace.Init(ctx, flags.VtraceFlags{})
@@ -87,14 +28,6 @@
return ctx, shutdown
}
-func mkThirdPartyCaveat(discharger security.PublicKey, location string, c security.Caveat) security.Caveat {
- tpc, err := security.NewPublicKeyCaveat(discharger, location, security.ThirdPartyRequirements{}, c)
- if err != nil {
- panic(err)
- }
- return tpc
-}
-
// mockCall implements security.Call
type mockCall struct {
p security.Principal
diff --git a/services/mounttable/mounttablelib/mounttable_test.go b/services/mounttable/mounttablelib/mounttable_test.go
index 8cd9e99..024e98a 100644
--- a/services/mounttable/mounttablelib/mounttable_test.go
+++ b/services/mounttable/mounttablelib/mounttable_test.go
@@ -5,7 +5,6 @@
package mounttablelib_test
import (
- "encoding/json"
"errors"
"fmt"
"io"
@@ -119,10 +118,6 @@
return names
}
-func strslice(strs ...string) []string {
- return strs
-}
-
func resolve(ctx *context.T, name string) (*naming.MountEntry, error) {
// Resolve the name one level.
var entry naming.MountEntry
@@ -558,24 +553,6 @@
}
}
-func getUserNodeCounts(t *testing.T) (counts map[string]int32) {
- s, err := libstats.Value("mounttable/num-nodes-per-user")
- if err != nil {
- boom(t, "Can't get mounttable statistics")
- }
- // This string is a json encoded map. Decode.
- switch v := s.(type) {
- default:
- boom(t, "Wrong type for mounttable statistics")
- case string:
- err = json.Unmarshal([]byte(v), &counts)
- if err != nil {
- boom(t, "Can't unmarshal mounttable statistics")
- }
- }
- return
-}
-
func TestGlobAccessLists(t *testing.T) {
rootCtx, aliceCtx, bobCtx, shutdown := initTest()
defer shutdown()
diff --git a/services/mounttable/mounttablelib/neighborhood_test.go b/services/mounttable/mounttablelib/neighborhood_test.go
index fbf343d..645c9e7 100644
--- a/services/mounttable/mounttablelib/neighborhood_test.go
+++ b/services/mounttable/mounttablelib/neighborhood_test.go
@@ -19,14 +19,6 @@
"v.io/x/ref/test"
)
-func protocolAndAddress(e naming.Endpoint) (string, string, error) {
- addr := e.Addr()
- if addr == nil {
- return "", "", fmt.Errorf("failed to get address")
- }
- return addr.Network(), addr.String(), nil
-}
-
type stopper interface {
Stop()
}
diff --git a/services/syncbase/vsync/initiator_test.go b/services/syncbase/vsync/initiator_test.go
index 46d1a76..627289d 100644
--- a/services/syncbase/vsync/initiator_test.go
+++ b/services/syncbase/vsync/initiator_test.go
@@ -441,25 +441,3 @@
}
return svc, iSt, cleanup
}
-
-func testIfSgPfxsEqual(t *testing.T, m map[string]sgSet, a []string) {
- aMap := arrToMap(a)
-
- if len(aMap) != len(m) {
- t.Fatalf("testIfSgPfxsEqual diff lengths: got %v, want %v", aMap, m)
- }
-
- for p := range aMap {
- if _, ok := m[p]; !ok {
- t.Fatalf("testIfSgPfxsEqual: want %v", p)
- }
- }
-}
-
-func arrToMap(a []string) map[string]struct{} {
- m := make(map[string]struct{})
- for _, s := range a {
- m[s] = struct{}{}
- }
- return m
-}
diff --git a/services/wspr/wsprlib/wspr.go b/services/wspr/wsprlib/wspr.go
index 4622136..b5d57d4 100644
--- a/services/wspr/wsprlib/wspr.go
+++ b/services/wspr/wsprlib/wspr.go
@@ -8,10 +8,8 @@
package wsprlib
import (
- "bytes"
"crypto/tls"
"fmt"
- "io"
"net"
"net/http"
"sync"
@@ -44,16 +42,6 @@
pipes map[*http.Request]*pipe
}
-func readFromRequest(r *http.Request) (*bytes.Buffer, error) {
- var buf bytes.Buffer
- if readBytes, err := io.Copy(&buf, r.Body); err != nil {
- return nil, fmt.Errorf("error copying message out of request: %v", err)
- } else if wantBytes := r.ContentLength; readBytes != wantBytes {
- return nil, fmt.Errorf("read %d bytes, wanted %d", readBytes, wantBytes)
- }
- return &buf, nil
-}
-
// Starts listening for requests and returns the network endpoint address.
func (wspr *WSPR) Listen() net.Addr {
addr := fmt.Sprintf("127.0.0.1:%d", wspr.httpPort)
diff --git a/test/modules/shell.go b/test/modules/shell.go
index c34d3b1..ededae2 100644
--- a/test/modules/shell.go
+++ b/test/modules/shell.go
@@ -133,7 +133,6 @@
"os"
"path/filepath"
"sync"
- "syscall"
"time"
"v.io/x/lib/envvar"
@@ -259,18 +258,6 @@
return c.path
}
-func dup(conn *os.File) (int, error) {
- syscall.ForkLock.RLock()
- fd, err := syscall.Dup(int(conn.Fd()))
- if err != nil {
- syscall.ForkLock.RUnlock()
- return -1, err
- }
- syscall.CloseOnExec(fd)
- syscall.ForkLock.RUnlock()
- return fd, nil
-}
-
// NewCustomCredentials creates a new Principal for StartWithOpts.
// Returns nil if the shell is not managing principals.
func (sh *Shell) NewCustomCredentials() (cred *CustomCredentials, err error) {
diff --git a/test/modules/util.go b/test/modules/util.go
index 3469fbd..97436eb 100644
--- a/test/modules/util.go
+++ b/test/modules/util.go
@@ -11,10 +11,7 @@
"io/ioutil"
"os"
- "v.io/v23/security"
-
"v.io/x/ref/internal/logger"
- vsecurity "v.io/x/ref/lib/security"
)
func newLogfile(prefix, name string) (*os.File, error) {
@@ -41,21 +38,3 @@
io.Copy(out, f)
f.Close()
}
-
-func principalFromDir(dir string) (security.Principal, error) {
- p, err := vsecurity.LoadPersistentPrincipal(dir, nil)
- if err == nil {
- return p, nil
- }
- if !os.IsNotExist(err) {
- return nil, err
- }
- p, err = vsecurity.CreatePersistentPrincipal(dir, nil)
- if err != nil {
- return nil, err
- }
- if err := vsecurity.InitDefaultBlessings(p, shellBlessingExtension); err != nil {
- return nil, err
- }
- return p, nil
-}
diff --git a/test/timekeeper/manual_time_test.go b/test/timekeeper/manual_time_test.go
index abb3546..307d69d 100644
--- a/test/timekeeper/manual_time_test.go
+++ b/test/timekeeper/manual_time_test.go
@@ -96,26 +96,24 @@
<-c
}
-func testBlocking(t *testing.T) {
+func TestBlocking(t *testing.T) {
mt := NewManualTime()
sync := make(chan bool)
go func() {
// Simulate blocking on a timer.
<-mt.After(10 * time.Second)
- <-mt.After(11 * time.Second)
- <-mt.After(3 * time.Second)
+ <-mt.After(2 * time.Second)
sync <- true
<-mt.After(4 * time.Second)
sync <- true
}()
- <-mt.Requests()
- <-mt.Requests()
- mt.AdvanceTime(12 * time.Second)
- <-mt.Requests()
- mt.AdvanceTime(2 * time.Second)
+ <-mt.Requests() // 10
+ mt.AdvanceTime(11 * time.Second)
+ <-mt.Requests() // 2
+ mt.AdvanceTime(3 * time.Second)
mt.AdvanceTime(time.Second)
<-sync
- <-mt.Requests()
+ <-mt.Requests() // 4
mt.AdvanceTime(5 * time.Second)
<-sync
}