[PATCH 3/6] siemens: Quote A/B flags in env tests

Simon Glass sjg at chromium.org
Sun May 3 22:49:21 CEST 2026


The Siemens am33x-common, env-common and draco-etamin headers gate
boot-partition selection logic on:

    if test -n ${A}; then ...
    if test -n ${B}; then ...

A and B are flags that the upgrade machinery sets to mark "the other
partition just became active".  The default state is unset, in which
case the expression expands to 'test -n' with no operand and relies
on a U-Boot 'test' quirk that treats a missing operand as false to
skip the branch.

Quote each variable so an unset A or B expands to 'test -n ""' and
the emptiness check is explicit.

Fixes: 8b0619579b22 ("cmd: test: fix handling of single-argument form of test")
Signed-off-by: Simon Glass <sjg at chromium.org>
---

 include/configs/draco-etamin.h         |  4 ++--
 include/configs/siemens-am33x-common.h | 12 ++++++------
 include/configs/siemens-env-common.h   |  8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/configs/draco-etamin.h b/include/configs/draco-etamin.h
index 6ae85b575b7..b1b403980b1 100644
--- a/include/configs/draco-etamin.h
+++ b/include/configs/draco-etamin.h
@@ -99,10 +99,10 @@
 	"nand_args=run bootargs_defaults;" \
 		"mtdparts default;" \
 		"setenv ${partitionset_active} true;" \
-		"if test -n ${A}; then " \
+		"if test -n \"${A}\"; then " \
 			"setenv nand_active_ubi_vol ${rootfs_name}_a;" \
 		"fi;" \
-		"if test -n ${B}; then " \
+		"if test -n \"${B}\"; then " \
 			"setenv nand_active_ubi_vol ${rootfs_name}_b;" \
 		"fi;" \
 		"setenv nand_root ubi0:${nand_active_ubi_vol} rw " \
diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h
index a918dc1350c..da822556909 100644
--- a/include/configs/siemens-am33x-common.h
+++ b/include/configs/siemens-am33x-common.h
@@ -104,11 +104,11 @@
 				"then " \
 				"setenv upgrade_available 0;" \
 				"setenv ${partitionset_active} true;" \
-				"if test -n ${A}; then " \
+				"if test -n \"${A}\"; then " \
 					"setenv partitionset_active B; " \
 					"env delete A; " \
 				"fi;" \
-				"if test -n ${B}; then " \
+				"if test -n \"${B}\"; then " \
 					"setenv partitionset_active A; " \
 					"env delete B; " \
 				"fi;" \
@@ -205,11 +205,11 @@
 	"nand_args=run bootargs_defaults;" \
 		"mtdparts default;" \
 		"setenv ${partitionset_active} true;" \
-		"if test -n ${A}; then " \
+		"if test -n \"${A}\"; then " \
 			"setenv nand_active_ubi_vol ${nand_active_ubi_vol_A};" \
 			"setenv nand_src_addr ${nand_src_addr_A};" \
 		"fi;" \
-		"if test -n ${B}; then " \
+		"if test -n \"${B}\"; then " \
 			"setenv nand_active_ubi_vol ${nand_active_ubi_vol_B};" \
 			"setenv nand_src_addr ${nand_src_addr_B};" \
 		"fi;" \
@@ -279,10 +279,10 @@
 	"nand_args=run bootargs_defaults;" \
 		"mtdparts default;" \
 		"setenv ${partitionset_active} true;" \
-		"if test -n ${A}; then " \
+		"if test -n \"${A}\"; then " \
 			"setenv nand_active_ubi_vol ${rootfs_name}_a;" \
 		"fi;" \
-		"if test -n ${B}; then " \
+		"if test -n \"${B}\"; then " \
 			"setenv nand_active_ubi_vol ${rootfs_name}_b;" \
 		"fi;" \
 		"setenv nand_root ubi0:${nand_active_ubi_vol} rw " \
diff --git a/include/configs/siemens-env-common.h b/include/configs/siemens-env-common.h
index c028823e1eb..8ced77cc5e2 100644
--- a/include/configs/siemens-env-common.h
+++ b/include/configs/siemens-env-common.h
@@ -81,12 +81,12 @@
  */
 #define ENV_FCT_TOGGLE_PARTITION "toggle_partition="\
 	"setenv ${partitionset_active} true;" \
-	"if test -n ${A}; " \
+	"if test -n \"${A}\"; " \
 	"then " \
 		"setenv partitionset_active B; " \
 		"env delete A; " \
 	"fi;" \
-	"if test -n ${B}; "\
+	"if test -n \"${B}\"; "\
 	"then " \
 		"setenv partitionset_active A; " \
 		"env delete B; " \
@@ -103,11 +103,11 @@
  */
 #define ENV_EMMC_FCT_SET_ACTIVE_PARTITION "set_partition=" \
 	"setenv ${partitionset_active} true;" \
-	"if test -n ${A}; " \
+	"if test -n \"${A}\"; " \
 	"then " \
 		"setenv mmc_part_nr 1;" \
 	"fi;" \
-	"if test -n ${B}; " \
+	"if test -n \"${B}\"; " \
 	"then " \
 		"setenv mmc_part_nr 2;" \
 	"fi;" \
-- 
2.43.0



More information about the U-Boot mailing list