Skip to contentSkip to conversation

tools: env: fix config file loading in env library

PATCH In review Anatolij Gustschin 3 participants 3 messages Apr 29, 2016 – May 4, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: env: fix config file loading in env library

env library is broken as the config file pointer is only initialized in main(). When running in the env library parse_config() fails:

Cannot parse config file '(null)': Bad address

Ensure that config file pointer is always initialized.

---
 tools/env/fw_env.c |    3 +++
 1 file changed, 3 insertions(+)
tools/env/fw_env.c +3 -0
index 1420ac5..06cf63d 100644
@@ -1325,6 +1325,9 @@ static int parse_config ()
 	struct stat st;
 
 #if defined(CONFIG_FILE)
+	if (!common_args.config_file)
+		common_args.config_file = CONFIG_FILE;
+
 	/* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */
 	if (get_config(common_args.config_file)) {
 		fprintf(stderr, "Cannot parse config file '%s': %m\n",
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 9 lines · Anatolij Gustschin

env library is broken as the config file pointer is only initialized in main(). When running in the env library parse_config() fails:

Cannot parse config file '(null)': Bad address

Ensure that config file pointer is always initialized.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160502/f1a99cfc/attachment.sig>
#2 lore raw

PATCH 1/1 tools: env: fix config file loading in env library

In reply to Anatolij Gustschin
Quoted 19 lines · Anatolij Gustschin

env library is broken as the config file pointer is only initialized in main(). When running in the env library parse_config() fails:

Cannot parse config file '(null)': Bad address

Ensure that config file pointer is always initialized.

---
 tools/env/fw_env.c |    3 +++
 1 file changed, 3 insertions(+)
tools/env/fw_env.c +0 -0
index 1420ac5..06cf63d 100644

tools/env/fw_env.c static int parse_config () · line 1333

Quoted 9 lines
tools/env/fw_env.c +3 -0
@@ -1325,6 +1325,9 @@ static int parse_config ()
 	struct stat st;
 
 #if defined(CONFIG_FILE)
+	if (!common_args.config_file)
+		common_args.config_file = CONFIG_FILE;
+
 	/* Fills in DEVNAME(), ENVSIZE(), DEVESIZE(). Or don't. */
 	if (get_config(common_args.config_file)) {
 		fprintf(stderr, "Cannot parse config file '%s': %m\n",

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================