> I was interested in the vet tool, and added a feature that checks for
> tautological comparisons for the integer types. Running it across HEAD
> produces the following six warnings:
>
> runtime/sigqueue.go:52: comparison of identifier s < 0 is always false
> runtime/proc1.go:1519: comparison of identifier nmspinning < 0 is always
> false
> cmd/asm/internal/asm/parse.go:817: comparison of identifier shift < 0 is
> always false
> cmd/compile/internal/big/natconv.go:304: comparison of identifier nbits >= 0
> is always true
> runtime/signal1_unix.go:192: comparison of identifier b >= 0 is always true
> runtime/signal1_unix.go:196: comparison of identifier b >= 0 is always true
Good finds. I'd say that each of these deserves a careful look and a
fix (although perhaps not for Go 1.5). Would you mind filing an issue
with these? Thanks.
I wonder why the check didn't also flag math/big/natconv.go, since the
code there is the same as command/compile/internal/big/natconv.go.
> It didn't find any major issues, just unreachable code. If it's something
> of interest, I can put it up in a CL. I'm new to go, so it may require some
> modifications to be more idiomatic.
Please do mail it as a CL. I can't promise it'll go in (the bar for
vet is quite high), but I do promise to review it carefully. And I'll
run it over a larger corpus than the standard library, to see what it
turns up. I'd also be happy to help you shape it into idiomatic code
as needed, if it looks like it is appropriate for inclusion in vet (or
even if you'd just like the feedback).
-josh