From 6b4f24a21d5f59ff925f300d7a0fc23d7ea85071 Mon Sep 17 00:00:00 2001 From: Ted Pudlik Date: Mon, 12 Feb 2024 19:51:50 +0000 Subject: [PATCH] pw_grpc: Fix some minor bugs These were uncovered by static checkers on internal copybara import. 1. Two instances of Printf with a single argument (https://staticcheck.dev/docs/checks#SA1006). 1. One instance of ineffective break statement (https://staticcheck.dev/docs/checks#SA4011). 1. One Sprintf with missing argument. Change-Id: If6795fad5f54e783e785f5a6ef897584dfc67946 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/191831 Pigweed-Auto-Submit: Ted Pudlik Presubmit-Verified: CQ Bot Account Commit-Queue: Auto-Submit Reviewed-by: Austin Foxley --- pw_grpc/gen/hpack_gen.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pw_grpc/gen/hpack_gen.go b/pw_grpc/gen/hpack_gen.go index a33c676476..ec5a662fd6 100644 --- a/pw_grpc/gen/hpack_gen.go +++ b/pw_grpc/gen/hpack_gen.go @@ -123,13 +123,12 @@ func updateTree(out int, code string) { // End of the code: create a leaf node. // Each code should lead to a unique leaf node. if curr.child[bit] != nil { - panic(fmt.Sprintf("code for byte %v reached a duplicate leaf node")) + panic(fmt.Sprintf("code for byte %v reached a duplicate leaf node", out)) } switch { case out == EOS: curr.child[bit] = &Node{t: EOSNode} - break case out < 32 || 127 < out: // Unprintable characters are allowed by the Huffman code but not in gRPC. // See: https://github.com/grpc/grpc/blob/v1.60.x/doc/PROTOCOL-HTTP2.md#requests. @@ -287,7 +286,7 @@ func printStaticResponses() { respHeaderFields := buildResponseHeaderFields() fmt.Printf(responseHeaderFieldsPrefix, len(respHeaderFields)) fmt.Printf(" %s", fmtBytes(respHeaderFields)) - fmt.Printf(responseHeaderFieldsSuffix) + fmt.Printf("%s", responseHeaderFieldsSuffix) maxLen := len(buildResponseTrailerFields(maxStatusCode)) fmt.Printf(responseTrailerFieldsPrefix, maxLen, maxStatusCode+1) @@ -295,7 +294,7 @@ func printStaticResponses() { payload := buildResponseTrailerFields(code) fmt.Printf(" {.size=%d, .bytes={%s}},\n", len(payload), fmtBytes(payload)) } - fmt.Printf(responseTrailerFieldsSuffix) + fmt.Printf("%s", responseTrailerFieldsSuffix) } func fmtBytes(bytes []byte) string {