Skip to content

Commit 7b49758

Browse files
committed
all: fix two minor printf bugs spotted by staticcheck
In cmd/cue/cmd we were using a detailed error string as a format string, which could cause trouble if the detailed error string were to contain any special characters. NewAttr had a similar issue; the only current call site leaves str empty anyway, so there shouldn't be any change in behavior whatsoever. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I588311a0a3cdacf5df8cc88779aaf6cd4887cb8b Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1168433 Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 382449b commit 7b49758

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

cmd/cue/cmd/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Run "cue help commands" for more details on tasks and commands.
165165
cmdline += " cmd"
166166
}
167167
cwd, _ := os.Getwd()
168-
fmt.Fprintf(w, errors.Details(err, &errors.Config{Cwd: cwd}))
168+
fmt.Fprint(w, errors.Details(err, &errors.Config{Cwd: cwd}))
169169
fmt.Fprintln(w, `Ensure custom commands are defined in a "_tool.cue" file.`)
170170
fmt.Fprintln(w, "Run 'cue help cmd' to list available custom commands.")
171171
if isRootCmd {

internal/internal.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,8 @@ func NewAttr(name, str string) *ast.Attribute {
264264
buf.WriteByte('@')
265265
buf.WriteString(name)
266266
buf.WriteByte('(')
267-
fmt.Fprintf(buf, str)
267+
buf.WriteString(str)
268268
buf.WriteByte(')')
269-
270269
return &ast.Attribute{Text: buf.String()}
271270
}
272271

0 commit comments

Comments
 (0)