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 56bababf83d1f6f7b769adc28f8dcc22ce5df27a
Author: Szymon Janc <[email protected]>
AuthorDate: Mon Oct 19 17:48:47 2026 +0200

    newt/syscfg: Fix crash on cmdline override of deprecated setting
    
    Values injected with "-S" on the command line have no source package.
    If such a value overrode a deprecated or experimental setting, newt
    crashed while generating the warning because it dereferenced the nil
    source package.
    
    Use the history point name ("newt" for injected values) instead, as
    the setting history output already does.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newt/syscfg/syscfg.go                              |  4 +--
 newt/syscfg_stability_test.go                      | 19 ++++++++++++++
 .../repos/apache-mynewt-core/sys/foo/syscfg.yml    | 29 ++++++++++++++++++++++
 .../syscfg_stability/targets/deprecated/pkg.yml    | 22 ++++++++++++++++
 .../syscfg_stability/targets/deprecated/syscfg.yml | 23 +++++++++++++++++
 .../syscfg_stability/targets/deprecated/target.yml | 23 +++++++++++++++++
 6 files changed, 118 insertions(+), 2 deletions(-)

diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index a9d04fcf..49da0bb0 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -1181,7 +1181,7 @@ func (cfg *Cfg) DeprecatedWarning() []string {
                point := mostRecentPoint(entry)
                lines = append(lines,
                        fmt.Sprintf("Use of deprecated setting %s in %s: %s", k,
-                               point.Source.FullName(), entry.Description))
+                               point.Name(), entry.Description))
        }
 
        return lines
@@ -1200,7 +1200,7 @@ func (cfg *Cfg) ExperimentalWarning() []string {
                point := mostRecentPoint(entry)
                lines = append(lines,
                        fmt.Sprintf("Use of experimental setting %s in %s", k,
-                               point.Source.FullName()))
+                               point.Name()))
        }
 
        return lines
diff --git a/newt/syscfg_stability_test.go b/newt/syscfg_stability_test.go
index 8a7addee..5b03e6e7 100644
--- a/newt/syscfg_stability_test.go
+++ b/newt/syscfg_stability_test.go
@@ -50,3 +50,22 @@ func TestSyscfgStabilityNewtSettingOverride(t *testing.T) {
                t.Errorf("missing priority violation error\n%s", out)
        }
 }
+
+// Deprecated and experimental settings overridden on the command line
+// produce warnings naming newt as the source.
+func TestSyscfgStabilityCmdlineDeprecated(t *testing.T) {
+       dir := copyToTemp(t, syscfgStabilityDir)
+
+       out, _ := newtCombinedOutput(dir, nil, "build", "deprecated",
+               "-S", "FOO_DEPRECATED=2:FOO_EXPERIMENTAL=2")
+       syscfgStabilityCheckNoPanic(t, out)
+
+       for _, msg := range []string{
+               "Use of deprecated setting FOO_DEPRECATED in newt",
+               "Use of experimental setting FOO_EXPERIMENTAL in newt",
+       } {
+               if !strings.Contains(out, msg) {
+                       t.Errorf("missing warning \"%s\"\n%s", msg, out)
+               }
+       }
+}
diff --git 
a/newt/testdata/syscfg_stability/repos/apache-mynewt-core/sys/foo/syscfg.yml 
b/newt/testdata/syscfg_stability/repos/apache-mynewt-core/sys/foo/syscfg.yml
new file mode 100644
index 00000000..0efb1fe5
--- /dev/null
+++ b/newt/testdata/syscfg_stability/repos/apache-mynewt-core/sys/foo/syscfg.yml
@@ -0,0 +1,29 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+syscfg.defs:
+    FOO_DEPRECATED:
+        description: Deprecated setting.
+        value: 0
+        deprecated: 1
+    FOO_EXPERIMENTAL:
+        description: Experimental setting.
+        value: 0
+        experimental: 1
diff --git a/newt/testdata/syscfg_stability/targets/deprecated/pkg.yml 
b/newt/testdata/syscfg_stability/targets/deprecated/pkg.yml
new file mode 100644
index 00000000..cbfeb413
--- /dev/null
+++ b/newt/testdata/syscfg_stability/targets/deprecated/pkg.yml
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+pkg.name: targets/deprecated
+pkg.type: target
diff --git a/newt/testdata/syscfg_stability/targets/deprecated/syscfg.yml 
b/newt/testdata/syscfg_stability/targets/deprecated/syscfg.yml
new file mode 100644
index 00000000..d93315a2
--- /dev/null
+++ b/newt/testdata/syscfg_stability/targets/deprecated/syscfg.yml
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+syscfg.vals:
+    FOO_DEPRECATED: 1
+    FOO_EXPERIMENTAL: 1
diff --git a/newt/testdata/syscfg_stability/targets/deprecated/target.yml 
b/newt/testdata/syscfg_stability/targets/deprecated/target.yml
new file mode 100644
index 00000000..7fbe84da
--- /dev/null
+++ b/newt/testdata/syscfg_stability/targets/deprecated/target.yml
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+target.app: apps/app
+target.bsp: "@apache-mynewt-core/hw/bsp/sim"
+target.build_profile: default

Reply via email to