New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positives with syscall.Stdin #26

Open
karalabe opened this Issue Nov 10, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@karalabe

karalabe commented Nov 10, 2017

The type of syscall.Stdin differs on Linux (int) and Windows (syscall.Handle). As such, any calling code needs to always cast syscall.Stdin to an integer to use it. But this gets flagged by unconvert on Linux.

My current workaround is to do int(os.Stdin.Fd()) instead of syscall.Stdin. Would be nice to do without the hack.

@mdempsky

This comment has been minimized.

Show comment
Hide comment
@mdempsky

mdempsky Nov 10, 2017

Owner

To confirm, are you using unconvert's -all flag?

Owner

mdempsky commented Nov 10, 2017

To confirm, are you using unconvert's -all flag?

@karalabe

This comment has been minimized.

Show comment
Hide comment
@karalabe

karalabe Nov 10, 2017

I'm using unconvert via the gometalinter using --enable=unconvert. Not sure exactly how the meta linter invokes unconvert.

karalabe commented Nov 10, 2017

I'm using unconvert via the gometalinter using --enable=unconvert. Not sure exactly how the meta linter invokes unconvert.

@dmitshur

This comment has been minimized.

Show comment
Hide comment
@dmitshur

dmitshur Nov 10, 2017

Contributor

According to https://github.com/alecthomas/gometalinter/blob/0262fb20957a4c2d3bb7c834a6a125ae3884a2c6/linters.go#L373, it looks like gometalinter invokes unconvert without -all or any other flags.

Contributor

dmitshur commented Nov 10, 2017

According to https://github.com/alecthomas/gometalinter/blob/0262fb20957a4c2d3bb7c834a6a125ae3884a2c6/linters.go#L373, it looks like gometalinter invokes unconvert without -all or any other flags.

@mdempsky

This comment has been minimized.

Show comment
Hide comment
@mdempsky

mdempsky Nov 10, 2017

Owner

I see. Unconvert should support your case with the -all flag. If not, that's definitely a bug.

I'm not familiar with gometalinter though. I don't know how to have it run unconvert with -all, or if that's even possible without changing the source.

Owner

mdempsky commented Nov 10, 2017

I see. Unconvert should support your case with the -all flag. If not, that's definitely a bug.

I'm not familiar with gometalinter though. I don't know how to have it run unconvert with -all, or if that's even possible without changing the source.

@karalabe

This comment has been minimized.

Show comment
Hide comment
@karalabe

karalabe Nov 10, 2017

I did try running locally with the --all option on my repo, but it dies on some CGO packages:

$ unconvert --all ./cmd/puppeth/
/work/src/github.com/ethereum/go-ethereum/crypto/signature_cgo.go:27:2: could not import github.com/ethereum/go-ethereum/crypto/secp256k1 (invalid package name: "")
2017/11/10 18:34:47 couldn't load packages due to errors: github.com/ethereum/go-ethereum/crypto

karalabe commented Nov 10, 2017

I did try running locally with the --all option on my repo, but it dies on some CGO packages:

$ unconvert --all ./cmd/puppeth/
/work/src/github.com/ethereum/go-ethereum/crypto/signature_cgo.go:27:2: could not import github.com/ethereum/go-ethereum/crypto/secp256k1 (invalid package name: "")
2017/11/10 18:34:47 couldn't load packages due to errors: github.com/ethereum/go-ethereum/crypto
@dnephin

This comment has been minimized.

Show comment
Hide comment
@dnephin

dnephin Jan 8, 2018

You can customize the command run by gometalinter using a config file:

{
  "Linters": {
    "unconvert": {"Command": "unconvert --all"}
  }
}

I tried --all on another repo, and I hit this problems with CGO as well.

snapshots/btrfs/btrfs.go:212:12: SubvolCreate not declared by package btrfs

However:

  • this function is declared in the btrfs package
  • there are no build tags on the file
  • it doesn't fail without --all

The only thing different about this package seems to be the import "C"

dnephin commented Jan 8, 2018

You can customize the command run by gometalinter using a config file:

{
  "Linters": {
    "unconvert": {"Command": "unconvert --all"}
  }
}

I tried --all on another repo, and I hit this problems with CGO as well.

snapshots/btrfs/btrfs.go:212:12: SubvolCreate not declared by package btrfs

However:

  • this function is declared in the btrfs package
  • there are no build tags on the file
  • it doesn't fail without --all

The only thing different about this package seems to be the import "C"

X-Guardian added a commit to X-Guardian/atlantis that referenced this issue Oct 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment