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 dae8b0cf0ec944396b4f40495fe893a401b4813a
Author: Szymon Janc <[email protected]>
AuthorDate: Wed Oct 21 10:30:42 2026 +0200

    newt: Remove unused assignments and unreachable code
    
    The list of directories with extra archives in Builder.link() is built
    but never used; the directories are walked directly below. In pkg
    move/copy the destination repository is only looked up to check that
    it exists, so drop the unused variable.
    
    Remove return statements that can never be reached in the symbol tree
    helpers and in the YAML mapping decoder, whose loop only exits through
    returns.
    
    No functional change.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newt/builder/build.go       |  3 ---
 newt/builder/symbol_tree.go | 21 +++++++++------------
 newt/cli/pkg_cmds.go        |  4 +---
 yaml/decode.go              |  2 --
 4 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/newt/builder/build.go b/newt/builder/build.go
index d62f0002..26d7cf75 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -460,8 +460,6 @@ func (b *Builder) link(elfName string, linkerScripts 
[]string,
                return err
        }
 
-       // Calculate the list of directories containing source .a files.
-       var dirs []string
        staticLibs := []util.StaticLib{}
        var extension string
 
@@ -487,7 +485,6 @@ func (b *Builder) link(elfName string, linkerScripts 
[]string,
                        staticLibs = append(staticLibs, s)
                }
        }
-       dirs = append(dirs, extraADirs...)
 
        // Find all .a files in the input directories.
        for _, dir := range extraADirs {
diff --git a/newt/builder/symbol_tree.go b/newt/builder/symbol_tree.go
index f2732b3b..23b01e7b 100644
--- a/newt/builder/symbol_tree.go
+++ b/newt/builder/symbol_tree.go
@@ -145,31 +145,28 @@ func (f *Folder) sumSize() uint64 {
 func (f *Folder) getFolder(name string) *Folder {
        if nextF, ok := f.Folders[name]; ok {
                return nextF
-       } else {
-               f.Folders[name] = newFolder(name)
-               return f.Folders[name]
        }
-       return &Folder{} // cannot happen
+
+       f.Folders[name] = newFolder(name)
+       return f.Folders[name]
 }
 
 func (f *Folder) getFile(name string) *File {
        if nextF, ok := f.Files[name]; ok {
                return nextF
-       } else {
-               f.Files[name] = newFile(name)
-               return f.Files[name]
        }
-       return &File{} // cannot happen
+
+       f.Files[name] = newFile(name)
+       return f.Files[name]
 }
 
 func (f *File) getSymbol(name string) *Symbol {
        if nextF, ok := f.Symbols[name]; ok {
                return nextF
-       } else {
-               f.Symbols[name] = &Symbol{name, "", 0}
-               return f.Symbols[name]
        }
-       return &Symbol{} // cannot happen
+
+       f.Symbols[name] = &Symbol{name, "", 0}
+       return f.Symbols[name]
 }
 
 func (f *Folder) addFolder(path []string) *Folder {
diff --git a/newt/cli/pkg_cmds.go b/newt/cli/pkg_cmds.go
index 97d089eb..64e541d6 100644
--- a/newt/cli/pkg_cmds.go
+++ b/newt/cli/pkg_cmds.go
@@ -124,11 +124,9 @@ func pkgCloneOrMoveCmd(cmd *cobra.Command, args []string, 
dirOpFn dirOperation,
        }
 
        dstPath := proj.Path() + "/"
-       repo := proj.LocalRepo()
        if repoName != "" {
                dstPath += "repos/" + repoName + "/"
-               repo = proj.FindRepo(repoName)
-               if repo == nil {
+               if proj.FindRepo(repoName) == nil {
                        NewtUsage(cmd, util.NewNewtError("Destination repo "+
                                repoName+" does not exist"))
                }
diff --git a/yaml/decode.go b/yaml/decode.go
index 2661b62e..cefa7064 100644
--- a/yaml/decode.go
+++ b/yaml/decode.go
@@ -222,8 +222,6 @@ func decodeMappingStart(parser *yaml_parser_t, event 
*yaml_event_t,
                }
                mappingAdd(&ctxt, key, subCtxt.value)
        }
-
-       return ctxt, nil
 }
 
 func decodeMappingEnd(parser *yaml_parser_t, event *yaml_event_t,

Reply via email to