{ipc/wsprd}: adonovan@ ran his static analysis tool on our code base
and it tripped over a couple of things. This CL adds a TODOs to
address these.
Change-Id: I4518d6f76ec44bb1dfeb49abd26b9560abb60d4a
diff --git a/runtimes/google/ipc/client.go b/runtimes/google/ipc/client.go
index a33a242..7dc06da 100644
--- a/runtimes/google/ipc/client.go
+++ b/runtimes/google/ipc/client.go
@@ -61,9 +61,6 @@
if vcOpt, ok := opt.(stream.VCOpt); ok {
c.vcOpts = append(c.vcOpts, vcOpt)
}
- // Now handle individual opts.
- switch topt := opt.(type) {
- }
}
return c, nil
}
diff --git a/runtimes/google/lib/sync/semaphore_test.go b/runtimes/google/lib/sync/semaphore_test.go
index af813c1..10366e8 100644
--- a/runtimes/google/lib/sync/semaphore_test.go
+++ b/runtimes/google/lib/sync/semaphore_test.go
@@ -107,16 +107,14 @@
s := NewSemaphore()
var pending sync.WaitGroup
pending.Add(1)
- var err error
go func() {
- err = s.Dec(nil)
+ if err := s.Dec(nil); err == nil {
+ t.Errorf("error should not be nil")
+ }
pending.Done()
}()
s.Close()
pending.Wait()
- if err == nil {
- t.Errorf("error should not be nil")
- }
}
func TestCloseWhileInDec(t *testing.T) {
@@ -145,9 +143,10 @@
cancel := make(chan struct{})
var pending sync.WaitGroup
pending.Add(1)
- var err error
go func() {
- err = s.Dec(cancel)
+ if err := s.Dec(cancel); err == nil {
+ t.Errorf("error should not be nil")
+ }
pending.Done()
}()
close(cancel)
diff --git a/services/wsprd/app/app.go b/services/wsprd/app/app.go
index c3ee5b5..f905118 100644
--- a/services/wsprd/app/app.go
+++ b/services/wsprd/app/app.go
@@ -214,15 +214,18 @@
return c.rt
}
-// Cleanup Cleans up any outstanding rpcs.
+// Cleanup cleans up any outstanding rpcs.
func (c *Controller) Cleanup() {
c.logger.VI(0).Info("Cleaning up websocket")
c.Lock()
defer c.Unlock()
for _, stream := range c.outstandingStreams {
- if call, ok := stream.stream.(ipc.Call); ok {
- call.Cancel()
- }
+ _ = stream
+ // TODO(bjornick): this is impossible type assertion and
+ // will panic at run time.
+ // if call, ok := stream.stream.(ipc.Call); ok {
+ // call.Cancel()
+ // }
}
for _, server := range c.servers {
diff --git a/services/wsprd/ipc/stream/stream.go b/services/wsprd/ipc/stream/stream.go
index 57ef1b3..5f90e90 100644
--- a/services/wsprd/ipc/stream/stream.go
+++ b/services/wsprd/ipc/stream/stream.go
@@ -8,7 +8,7 @@
// An interface for an asynchronous sender.
type Sender interface {
- // Similar to ipc.Stream.Send, expect that instead of
+ // Similar to ipc.Stream.Send, except that instead of
// returning an error, w.sendError will be called.
Send(item interface{}, w lib.ClientWriter)
}