]> Cypherpunks repositories - gostls13.git/commit
cmd/vet: Use function signature to find format string index.
authorSpencer Nelson <s@spenczar.com>
Wed, 2 Mar 2016 20:29:30 +0000 (15:29 -0500)
committerRob Pike <r@golang.org>
Fri, 4 Mar 2016 00:00:20 +0000 (00:00 +0000)
commit867910ea170cad67ef929ae472f1e19052da7d7c
treeb53f68810e777679c5a59f895abcafa2e2e10c6d
parentbf3909824ccf0c03e372d1a341792a8f783f03f7
cmd/vet: Use function signature to find format string index.

cmd/vet's printf checker currently uses a hardcoded map of function
names to expected positions of format strings. We can be a bit more
precise than this by looking up the signature of the function, which
helps when libraries implement functions like Errorf or Logf with
extra arguments like log levels or error codes.

Specifically, the format string param is assumed to be the last string
parameter of the called function.

Fixes #12294.

Change-Id: Icf10ebb819bba91fa1c4109301417042901e34c7
Reviewed-on: https://go-review.googlesource.com/20163
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/vet/print.go
src/cmd/vet/testdata/print.go