Skip to content

Commit f62c8b6

Browse files
chaehnimwfarb
authored andcommitted
Cleaning code (#50)
* spelling and gofmt * go vet * go imports * ineffectual assignments * spelling * simplified * mike feedback
1 parent 6cefa48 commit f62c8b6

File tree

27 files changed

+2221
-2218
lines changed

27 files changed

+2221
-2218
lines changed

bat/bat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func main() {
172172
}
173173
}
174174
}
175-
175+
176176
if *URL == "" {
177177
usage()
178178
}

bwtester/bwtestclient/bwtestclient.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func parseBandwidth(bw string) int64 {
166166
return DefaultBW
167167
}
168168

169-
var m int64 = 1
169+
var m int64
170170
val := rawBw[0][:len(rawBw[0])-1]
171171
suffix := rawBw[0][len(rawBw[0])-1:]
172172
switch suffix {
@@ -209,7 +209,7 @@ func getDuration(duration string) int64 {
209209
}
210210
d := time.Second * time.Duration(a1)
211211
if d > MaxDuration {
212-
Check(fmt.Errorf("Duration is exceeding MaxDuration:", a1, ">", MaxDuration/time.Second))
212+
Check(fmt.Errorf("Duration is exceeding MaxDuration: %d > %d", a1, MaxDuration/time.Second))
213213
a1 = DefaultDuration
214214
}
215215
return a1

bwtester/bwtestlib/bwtestlib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func HandleDCConnSend(bwp *BwtestParameters, udpConnection snet.Conn) {
192192
Check(err)
193193
}
194194
} else if int64(n) < bwp.PacketSize {
195-
Check(fmt.Errorf("Insufficient number of bytes written:", n, "instead of:", bwp.PacketSize))
195+
Check(fmt.Errorf("Insufficient number of bytes written: %d instead of %d", n, bwp.PacketSize))
196196
}
197197
i++
198198
}

bwtester/bwtestserver/bwtestserver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func handleClients(CCConn snet.Conn, serverISDASIP string, receivePacketBuffer [
259259
// An error happened, ask the client to try again in 1 second (perhaps no path to client was found)
260260
sendPacketBuffer[0] = 'N'
261261
sendPacketBuffer[1] = byte(1)
262-
n, err = CCConn.WriteTo(sendPacketBuffer[:2], clientCCAddr)
262+
CCConn.WriteTo(sendPacketBuffer[:2], clientCCAddr)
263263
// Ignore error
264264
continue
265265
}
@@ -285,7 +285,7 @@ func handleClients(CCConn snet.Conn, serverISDASIP string, receivePacketBuffer [
285285
// Send back success
286286
sendPacketBuffer[0] = 'N'
287287
sendPacketBuffer[1] = byte(0)
288-
n, _ = CCConn.WriteTo(sendPacketBuffer[:2], clientCCAddr)
288+
CCConn.WriteTo(sendPacketBuffer[:2], clientCCAddr)
289289
// Ignore error
290290
// Everything succeeded, now set variable that bwtest is ongoing
291291
currentBwtest = clientCCAddrStr

camerapp/imagefetcher/imagefetcher.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ func fetchFileInfo(udpConnection snet.Conn) (string, uint32, time.Duration, erro
4747
numRetries++
4848
// Send LIST command ("L") to server
4949
t0 := time.Now()
50-
n, err := udpConnection.Write([]byte("L"))
50+
_, err := udpConnection.Write([]byte("L"))
5151
check(err)
5252

5353
// Read response
5454
err = udpConnection.SetReadDeadline(time.Now().Add(maxWaitDelay))
5555
check(err)
56-
n, _, err = udpConnection.ReadFrom(packetBuffer)
56+
n, _, err := udpConnection.ReadFrom(packetBuffer)
5757
if err != nil {
5858
// Read error, most likely Timeout
5959
continue
@@ -68,7 +68,7 @@ func fetchFileInfo(udpConnection snet.Conn) (string, uint32, time.Duration, erro
6868
// }
6969
// }
7070
// If it's not an snet Timeout or SCMP error, then it's something more serious and fail
71-
check(err)
71+
// check(err)
7272
}
7373
t1 := time.Now()
7474
rttApprox := t1.Sub(t0)
@@ -128,7 +128,7 @@ func blockReceiver(receivedBlockChan chan uint32, udpConnection snet.Conn, fileB
128128
// }
129129
// }
130130
// If it's not an snet SCMP error, then it's something more serious and fail
131-
check(err)
131+
// check(err)
132132
}
133133
if n < 10 {
134134
continue

camerapp/imageserver/imageserver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"sync"
1616
"time"
1717

18-
"github.com/scionproto/scion/go/lib/snet"
1918
"github.com/scionproto/scion/go/lib/sciond"
19+
"github.com/scionproto/scion/go/lib/snet"
2020
)
2121

2222
const (
@@ -164,7 +164,7 @@ func main() {
164164
// }
165165
// }
166166
// If it's not an snet SCMP error, then it's something more serious and fail
167-
check(err)
167+
// check(err)
168168
}
169169
if n > 0 {
170170
if receivePacketBuffer[0] == 'L' {
@@ -183,7 +183,7 @@ func main() {
183183
binary.LittleEndian.PutUint32(sendPacketBuffer[sendLen:], currentFiles[mostRecentFile].size)
184184
currentFilesLock.Unlock()
185185
sendLen = sendLen + 4
186-
n, err = udpConnection.WriteTo(sendPacketBuffer[:sendLen], remoteUDPaddress)
186+
_, err = udpConnection.WriteTo(sendPacketBuffer[:sendLen], remoteUDPaddress)
187187
check(err)
188188
} else if receivePacketBuffer[0] == 'G' && n > 1 {
189189
filenameLen := int(receivePacketBuffer[1])
@@ -206,7 +206,7 @@ func main() {
206206
// Copy image contents
207207
copy(sendPacketBuffer[9:], v.content[startByte:endByte])
208208
sendLen := 9 + endByte - startByte
209-
n, err = udpConnection.WriteTo(sendPacketBuffer[:sendLen], remoteUDPaddress)
209+
_, err = udpConnection.WriteTo(sendPacketBuffer[:sendLen], remoteUDPaddress)
210210
check(err)
211211
}
212212
}

lib/scionutil/hosts_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ func TestReadHosts(t *testing.T) {
8989
}
9090
addr = &snet.Addr{IA: ia, Host: &libaddr.AppAddr{L3: l3, L4: libaddr.NewL4UDPInfo(0)}}
9191

92-
expected, err = snet.AddrFromString("20-ffaa:c0ff:ee12,[::ff1:ce00:dead:10cc:baad:f00d]:0")
92+
expected, _ = snet.AddrFromString("20-ffaa:c0ff:ee12,[::ff1:ce00:dead:10cc:baad:f00d]:0")
9393
if !addr.EqAddr(expected) {
9494
t.Errorf("host resolved to wrong address, expected: %q, received: %q", "20-ffaa:c0ff:ee12,[::ff1:ce00:dead:10cc:baad:f00d]:0", addr)
9595
}
9696

9797
// does not parse commented hosts
98-
ia, l3, err = GetHostByName("commented")
98+
_, _, err = GetHostByName("commented")
9999
if err == nil {
100100
t.Error("read commented host")
101101
}

lib/scionutil/path_selection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func ChoosePathByMetric(pathAlgo int, local, remote *snet.Addr) *sciond.PathRepl
105105
func pathSelection(pathSet spathmeta.AppPathSet, pathAlgo int) *spathmeta.AppPath {
106106
var selectedPath *spathmeta.AppPath
107107
var metric float64
108-
// A path selection algorithm consists of a simple comparision function selecting the best path according
108+
// A path selection algorithm consists of a simple comparison function selecting the best path according
109109
// to some path property and a metric function normalizing that property to a value in [0,1], where larger is better
110110
// Available path selection algorithms, the metric returned must be normalized between [0,1]:
111111
pathAlgos := map[int](func(spathmeta.AppPathSet) (*spathmeta.AppPath, float64)){

lib/shttp/examples/image_server/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ func main() {
8181
}
8282

8383
out, err := os.Create("received.jpg")
84+
if err != nil {
85+
log.Fatal(err)
86+
}
8487
err = jpeg.Encode(out, img, nil)
8588
if err != nil {
8689
log.Fatal(err)

0 commit comments

Comments
 (0)