[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [obfs4/master] Reduce some if err != nil logic lines



commit ced244c09f46d60715d17b8e09c609e08cac87ae
Author: Daniel Martí <mvdan@xxxxxxxx>
Date:   Wed Mar 18 13:43:48 2015 +0100

    Reduce some if err != nil logic lines
---
 obfs4proxy/obfs4proxy.go                       |    6 ++----
 transports/obfs4/framing/framing.go            |    6 ++----
 transports/scramblesuit/handshake_uniformdh.go |    3 +--
 3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index da8f011..e489b57 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -230,8 +230,7 @@ func clientHandler(f base.ClientFactory, conn *pt.SocksConn, proxyURI *url.URL)
 		return
 	}
 
-	err = copyLoop(conn, remote)
-	if err != nil {
+	if err = copyLoop(conn, remote); err != nil {
 		warnf("%s(%s) - closed connection: %s", name, addrStr, elideError(err))
 	} else {
 		infof("%s(%s) - closed connection", name, addrStr)
@@ -323,8 +322,7 @@ func serverHandler(f base.ServerFactory, conn net.Conn, info *pt.ServerInfo) {
 	}
 	defer orConn.Close()
 
-	err = copyLoop(orConn, remote)
-	if err != nil {
+	if err = copyLoop(orConn, remote); err != nil {
 		warnf("%s(%s) - closed connection: %s", name, addrStr, elideError(err))
 	} else {
 		infof("%s(%s) - closed connection", name, addrStr)
diff --git a/transports/obfs4/framing/framing.go b/transports/obfs4/framing/framing.go
index 879765d..815a990 100644
--- a/transports/obfs4/framing/framing.go
+++ b/transports/obfs4/framing/framing.go
@@ -187,8 +187,7 @@ func (encoder *Encoder) Encode(frame, payload []byte) (n int, err error) {
 
 	// Generate a new nonce.
 	var nonce [nonceLength]byte
-	err = encoder.nonce.bytes(&nonce)
-	if err != nil {
+	if err = encoder.nonce.bytes(&nonce); err != nil {
 		return 0, err
 	}
 	encoder.nonce.counter++
@@ -256,8 +255,7 @@ func (decoder *Decoder) Decode(data []byte, frames *bytes.Buffer) (int, error) {
 		}
 
 		// Derive the nonce the peer used.
-		err = decoder.nonce.bytes(&decoder.nextNonce)
-		if err != nil {
+		if err = decoder.nonce.bytes(&decoder.nextNonce); err != nil {
 			return 0, err
 		}
 
diff --git a/transports/scramblesuit/handshake_uniformdh.go b/transports/scramblesuit/handshake_uniformdh.go
index 4345d65..4b77e5a 100644
--- a/transports/scramblesuit/handshake_uniformdh.go
+++ b/transports/scramblesuit/handshake_uniformdh.go
@@ -109,8 +109,7 @@ func (hs *ssDHClientHandshake) parseServerHandshake(resp []byte) (int, []byte, e
 
 		// Pull out the public key, and derive the server mark.
 		hs.serverPublicKey = &uniformdh.PublicKey{}
-		err := hs.serverPublicKey.SetBytes(y)
-		if err != nil {
+		if err := hs.serverPublicKey.SetBytes(y); err != nil {
 			return 0, nil, err
 		}
 		hs.mac.Reset()



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits