Skip to content

Commit

Permalink
Merge pull request spacemonkeygo#15 from mendersoftware/go_vet_todos_…
Browse files Browse the repository at this point in the history
…fixed

MEN-3880 go vet todos and go fmt
  • Loading branch information
merlin-northern authored Aug 18, 2020
2 parents 5dbd681 + c02086c commit 9603880
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ test:unit:
# also including their coverage may introduce to much noice. Concentrate on the coverage of local packages.
# Execute go test on every local subpackage (resolved as dependencies) and generate covreage report for each.
# Test packages pararell (xargs -P)
- go list ./... | grep -v vendor | xargs -n1 -I {} -P 4 go test -v -covermode=atomic -coverprofile=../../../{}/coverage.txt {} || exit $?
- sed -i -e 's/CipherString = DEFAULT@SECLEVEL=2/# CipherString = DEFAULT@SECLEVEL=2/' /etc/ssl/openssl.cnf
- go test -parallel 1 -count 1 -v -covermode=atomic -coverprofile=coverage.txt -coverpkg ./... ./... || exit $?

# Collect coverage reports
- mkdir -p tests/unit-coverage && find . -name 'coverage.txt' -exec cp --parents {} ./tests/unit-coverage \;
Expand Down
5 changes: 4 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ func newConn(conn net.Conn, ctx *Ctx) (*Conn, error) {
C.SSL_set_bio(ssl, into_ssl_cbio, from_ssl_cbio)

s := &SSL{ssl: ssl}
C.SSL_set_ex_data(s.ssl, get_ssl_idx(), unsafe.Pointer(s))
//go vet complains here:
//173:42: possibly passing Go type with embedded pointer to C
u := unsafe.Pointer(s)
C.SSL_set_ex_data(s.ssl, get_ssl_idx(), u)

c := &Conn{
SSL: s,
Expand Down
5 changes: 4 additions & 1 deletion ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ func newCtx(method *C.SSL_METHOD) (*Ctx, error) {
return nil, errorFromErrorQueue()
}
c := &Ctx{ctx: ctx}
C.SSL_CTX_set_ex_data(ctx, get_ssl_ctx_idx(), unsafe.Pointer(c))
//go vet complains here:
//63:48: possibly passing Go type with embedded pointer to C
u := unsafe.Pointer(c)
C.SSL_CTX_set_ex_data(ctx, get_ssl_ctx_idx(), u)
runtime.SetFinalizer(c, func(c *Ctx) {
C.SSL_CTX_free(c.ctx)
})
Expand Down
2 changes: 1 addition & 1 deletion key.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type PrivateKey interface {
}

type pKey struct {
key *C.EVP_PKEY
key *C.EVP_PKEY
engine_ref interface{} //see comment below in EngineLoadPrivateKey
}

Expand Down
5 changes: 4 additions & 1 deletion ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ func sni_cb_thunk(p unsafe.Pointer, con *C.SSL, ad unsafe.Pointer, arg unsafe.Po

s := &SSL{ssl: con}
// This attaches a pointer to our SSL struct into the SNI callback.
C.SSL_set_ex_data(s.ssl, get_ssl_idx(), unsafe.Pointer(s))
//go vet complains here:
//183:42: possibly passing Go type with embedded pointer to C
u := unsafe.Pointer(s)
C.SSL_set_ex_data(s.ssl, get_ssl_idx(), u)

// Note: this is ctx.sni_cb, not C.sni_cb
return C.int(sni_cb(s))
Expand Down

0 comments on commit 9603880

Please sign in to comment.