This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 154b68b1752e3a3268ca56fcd4e34208fec19ffe
Author: Szymon Janc <[email protected]>
AuthorDate: Thu Oct 15 18:02:21 2026 +0200

    newt: Don't use non-constant format strings
    
    Messages and generated file preambles were passed as format strings, so
    any '%' in target names, paths or error messages would be interpreted
    as a format verb. Use a constant format or a non-formatting function
    instead. Also drop redundant newline passed to Fprintln.
    
    With this go vet checks run by "go test" pass for all packages.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newt/builder/buildutil.go   |  2 +-
 newt/builder/cmake.go       |  2 +-
 newt/cli/target_cfg_cmds.go |  2 +-
 newt/cli/target_cmds.go     | 24 ++++++++++++------------
 newt/flashmap/flashmap.go   |  8 ++++----
 newt/logcfg/logcfg.go       |  4 ++--
 newt/mfg/build.go           |  2 +-
 newt/symbol/symbol.go       |  2 +-
 newt/syscfg/syscfg.go       |  2 +-
 newt/sysdown/sysdown.go     |  2 +-
 newt/sysinit/sysinit.go     |  2 +-
 11 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/newt/builder/buildutil.go b/newt/builder/buildutil.go
index 323e716c..b99da740 100644
--- a/newt/builder/buildutil.go
+++ b/newt/builder/buildutil.go
@@ -117,7 +117,7 @@ func logDepInfo(res *resolve.Resolution) {
        log.Debugf("API set:")
        for _, api := range apis {
                rpkg := res.ApiMap[api]
-               log.Debugf("    * " + api + " (" + rpkg.Lpkg.FullName() + ")")
+               log.Debugf("    * %s (%s)", api, rpkg.Lpkg.FullName())
        }
 
        // Log dependency graph.
diff --git a/newt/builder/cmake.go b/newt/builder/cmake.go
index a6947462..45381d57 100644
--- a/newt/builder/cmake.go
+++ b/newt/builder/cmake.go
@@ -418,7 +418,7 @@ func CmakeCompilerWrite(w io.Writer, c *toolchain.Compiler) 
{
 }
 
 func CmakeHeaderWrite(w io.Writer, c *toolchain.Compiler, projectName string) {
-       fmt.Fprintln(w, "cmake_minimum_required(VERSION 3.7)\n")
+       fmt.Fprint(w, "cmake_minimum_required(VERSION 3.7)\n\n")
        CmakeCompilerWrite(w, c)
        fmt.Fprintf(w, "project(%s VERSION 0.0.0 LANGUAGES C CXX ASM)\n\n", 
projectName)
        fmt.Fprintln(w, "SET(CMAKE_C_FLAGS_BACKUP  \"${CMAKE_C_FLAGS}\")")
diff --git a/newt/cli/target_cfg_cmds.go b/newt/cli/target_cfg_cmds.go
index d71d7062..5c3c0cb8 100644
--- a/newt/cli/target_cfg_cmds.go
+++ b/newt/cli/target_cfg_cmds.go
@@ -831,7 +831,7 @@ func targetDumpCmd(cmd *cobra.Command, args []string) {
                if err != nil {
                        NewtUsage(nil, err)
                }
-               util.StatusMessage(util.VERBOSITY_DEFAULT, s+"\n")
+               util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", s)
        }
 }
 
diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go
index 168d6933..62f26f3f 100644
--- a/newt/cli/target_cmds.go
+++ b/newt/cli/target_cmds.go
@@ -219,7 +219,7 @@ func targetShowCmd(cmd *cobra.Command, args []string) {
        for _, name := range targetNames {
                kvPairs := map[string]string{}
 
-               util.StatusMessage(util.VERBOSITY_DEFAULT, name+"\n")
+               util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", name)
 
                target := target.GetTargets()[name]
                settings := target.TargetY.AllSettingsAsStrings()
@@ -276,12 +276,12 @@ func targetEnvCmd(cmd *cobra.Command, args []string) {
                NewtUsage(nil, err)
        }
 
-       fmt.Printf("APP_ELF_PATH=" + b.AppBuilder.AppElfPath() + "\n")
-       fmt.Printf("APP_IMG_PATH=" + b.AppBuilder.AppImgPath() + "\n")
-       fmt.Printf("APP_HEX_PATH=" + b.AppBuilder.AppHexPath() + "\n")
-       fmt.Printf("APP_BIN_PATH=" + b.AppBuilder.AppBinPath() + "\n")
-       fmt.Printf("BUILD_TARGET_DIR=" + 
builder.TargetBinDir(b.GetTarget().Name()) + "\n")
-       fmt.Printf("BUILD_APP_DIR=" + b.AppBuilder.AppBinBasePath() + "\n")
+       fmt.Printf("APP_ELF_PATH=%s\n", b.AppBuilder.AppElfPath())
+       fmt.Printf("APP_IMG_PATH=%s\n", b.AppBuilder.AppImgPath())
+       fmt.Printf("APP_HEX_PATH=%s\n", b.AppBuilder.AppHexPath())
+       fmt.Printf("APP_BIN_PATH=%s\n", b.AppBuilder.AppBinPath())
+       fmt.Printf("BUILD_TARGET_DIR=%s\n", 
builder.TargetBinDir(b.GetTarget().Name()))
+       fmt.Printf("BUILD_APP_DIR=%s\n", b.AppBuilder.AppBinBasePath())
 }
 
 func printCflags(appCflags []ycfg.YCfgEntry) {
@@ -357,7 +357,7 @@ func targetListCmd(cmd *cobra.Command, args []string) {
        sort.Strings(targetNames)
 
        for _, name := range targetNames {
-               util.StatusMessage(util.VERBOSITY_DEFAULT, name+"\n")
+               util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", name)
        }
 }
 
@@ -731,8 +731,8 @@ func targetDepCmd(cmd *cobra.Command, args []string) {
        dg := targetDepCommonCmd(cmd, args)
 
        if len(dg) > 0 {
-               util.StatusMessage(util.VERBOSITY_DEFAULT,
-                       builder.DepGraphText(dg)+"\n")
+               util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n",
+                       builder.DepGraphText(dg))
        }
 }
 
@@ -789,8 +789,8 @@ func targetRevdepCmd(cmd *cobra.Command, args []string) {
        dg := targetRevdepCommonCmd(cmd, args)
 
        if len(dg) > 0 {
-               util.StatusMessage(util.VERBOSITY_DEFAULT,
-                       builder.RevdepGraphText(dg)+"\n")
+               util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n",
+                       builder.RevdepGraphText(dg))
        }
 }
 
diff --git a/newt/flashmap/flashmap.go b/newt/flashmap/flashmap.go
index d0c0446c..ab631c71 100644
--- a/newt/flashmap/flashmap.go
+++ b/newt/flashmap/flashmap.go
@@ -131,7 +131,7 @@ func parseFlashArea(
                case "size":
                        area.Size, err = parseSize(v)
                        if err != nil {
-                               return area, flashAreaErr(name, err.Error())
+                               return area, flashAreaErr(name, "%s", 
err.Error())
                        }
                        sizePresent = true
 
@@ -216,7 +216,7 @@ func Read(ymlFlashMap map[string]interface{}, pkgName 
string) (FlashMap, error)
                ymlArea := cast.ToStringMap(v)
                area, err := parseFlashArea(k, ymlArea)
                if err != nil {
-                       return flashMap, flashAreaErr(k, err.Error())
+                       return flashMap, flashAreaErr(k, "%s", err.Error())
                }
 
                flashMap.Areas[k] = area
@@ -240,7 +240,7 @@ func writeFlashAreaHeader(w io.Writer, area 
flash.FlashArea) {
 }
 
 func writeFlashMapHeader(w io.Writer, fm FlashMap) {
-       fmt.Fprintf(w, newtutil.GeneratedPreamble())
+       fmt.Fprint(w, newtutil.GeneratedPreamble())
 
        fmt.Fprintf(w, "#ifndef H_MYNEWT_SYSFLASH_\n")
        fmt.Fprintf(w, "#define H_MYNEWT_SYSFLASH_\n")
@@ -284,7 +284,7 @@ func writeFlashAreaSrc(w io.Writer, area flash.FlashArea) {
 }
 
 func writeFlashMapSrc(w io.Writer, fm FlashMap) {
-       fmt.Fprintf(w, newtutil.GeneratedPreamble())
+       fmt.Fprint(w, newtutil.GeneratedPreamble())
 
        fmt.Fprintf(w, "#include \"%s\"\n", HEADER_PATH)
        fmt.Fprintf(w, "\n")
diff --git a/newt/logcfg/logcfg.go b/newt/logcfg/logcfg.go
index fa56770f..30e2f5c7 100644
--- a/newt/logcfg/logcfg.go
+++ b/newt/logcfg/logcfg.go
@@ -316,7 +316,7 @@ func (lcfg *LCfg) writeLogModuleCases(w io.Writer) {
 
 // Writes a logcfg header file to the specified writer.
 func (lcfg *LCfg) writeHeader(w io.Writer) {
-       fmt.Fprintf(w, newtutil.GeneratedPreamble())
+       fmt.Fprint(w, newtutil.GeneratedPreamble())
 
        fmt.Fprintf(w, "#ifndef H_MYNEWT_LOGCFG_\n")
        fmt.Fprintf(w, "#define H_MYNEWT_LOGCFG_\n\n")
@@ -336,7 +336,7 @@ func (lcfg *LCfg) writeHeader(w io.Writer) {
 
 // Writes a logcfg src file to the specified writer.
 func (lcfg *LCfg) writeSource(w io.Writer) {
-       fmt.Fprintf(w, newtutil.GeneratedPreamble())
+       fmt.Fprint(w, newtutil.GeneratedPreamble())
 
        fmt.Fprintf(w, "#include <stdint.h>\n")
        fmt.Fprintf(w, "#include <stdlib.h>\n")
diff --git a/newt/mfg/build.go b/newt/mfg/build.go
index ab3ed3a2..e11efbfc 100644
--- a/newt/mfg/build.go
+++ b/newt/mfg/build.go
@@ -165,7 +165,7 @@ func calcBsp(dm DecodedMfg,
 
        bsp, err := pkg.NewBspPackage(bspLpkg, nil)
        if err != nil {
-               return nil, util.FmtNewtError(err.Error())
+               return nil, util.NewNewtError(err.Error())
        }
 
        return bsp, nil
diff --git a/newt/symbol/symbol.go b/newt/symbol/symbol.go
index 9d155caf..d40cfc79 100644
--- a/newt/symbol/symbol.go
+++ b/newt/symbol/symbol.go
@@ -167,7 +167,7 @@ func sprintfSi(si *SymbolInfo) string {
 }
 
 func dumpSi(si *SymbolInfo) {
-       fmt.Printf(sprintfSi(si))
+       fmt.Print(sprintfSi(si))
 }
 
 func (si *SymbolInfo) Dump() {
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index 87619402..3e1ed25e 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -1630,7 +1630,7 @@ func writeApis(apis []string, w io.Writer) {
 }
 
 func write(cfg Cfg, lpkgs []*pkg.LocalPackage, apis []string, w io.Writer) {
-       fmt.Fprintf(w, newtutil.GeneratedPreamble())
+       fmt.Fprint(w, newtutil.GeneratedPreamble())
 
        fmt.Fprintf(w, "#ifndef H_MYNEWT_SYSCFG_\n")
        fmt.Fprintf(w, "#define H_MYNEWT_SYSCFG_\n\n")
diff --git a/newt/sysdown/sysdown.go b/newt/sysdown/sysdown.go
index b240edf0..28bf6a13 100644
--- a/newt/sysdown/sysdown.go
+++ b/newt/sysdown/sysdown.go
@@ -142,7 +142,7 @@ func (scfg *SysdownCfg) write(lpkgs []*pkg.LocalPackage, 
isLoader bool,
                sfs = scfg.filter(lpkgs)
        }
 
-       fmt.Fprintf(w, newtutil.GeneratedPreamble())
+       fmt.Fprint(w, newtutil.GeneratedPreamble())
 
        if isLoader {
                fmt.Fprintf(w, "#if SPLIT_LOADER\n\n")
diff --git a/newt/sysinit/sysinit.go b/newt/sysinit/sysinit.go
index ee1caf3c..9c3a1457 100644
--- a/newt/sysinit/sysinit.go
+++ b/newt/sysinit/sysinit.go
@@ -316,7 +316,7 @@ func (scfg *SysinitCfg) write(lpkgs []*pkg.LocalPackage, 
isLoader bool,
                sfs = scfg.filter(lpkgs)
        }
 
-       fmt.Fprintf(w, newtutil.GeneratedPreamble())
+       fmt.Fprint(w, newtutil.GeneratedPreamble())
 
        if isLoader {
                fmt.Fprintf(w, "#if SPLIT_LOADER\n\n")

Reply via email to