public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 01/10] fw_env.c: Switch get_config to use '%ms' in sscanf
@ 2014-03-28 16:03 Tom Rini
  2014-03-28 16:03 ` [U-Boot] [PATCH v3 02/10] env_mmc.c: Allow environment to be used within SPL Tom Rini
                   ` (9 more replies)
  0 siblings, 10 replies; 20+ messages in thread
From: Tom Rini @ 2014-03-28 16:03 UTC (permalink / raw)
  To: u-boot

We currently limit ourself to 16 characters for the device name to read
the environment from.  This is insufficient for /dev/mmcblk0boot1 to
work for example.  Switch to '%ms' which gives us a dynamically
allocated buffer instead.  We're short lived enough to not bother
free()ing the buffer.

Signed-off-by: Tom Rini <trini@ti.com>

---
Changes in v2:
- Rework to use '%ms' in get_config per Wolfgang

Signed-off-by: Tom Rini <trini@ti.com>
---
 tools/env/fw_env.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index d228cc3..f5cd521 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -40,7 +40,7 @@
 	_min1 < _min2 ? _min1 : _min2; })
 
 struct envdev_s {
-	char devname[16];		/* Device name */
+	const char *devname;		/* Device name */
 	ulong devoff;			/* Device offset */
 	ulong env_size;			/* environment size */
 	ulong erase_size;		/* device erase size */
@@ -1243,7 +1243,7 @@ static int parse_config ()
 		return -1;
 	}
 #else
-	strcpy (DEVNAME (0), DEVICE1_NAME);
+	DEVNAME (0) = DEVICE1_NAME;
 	DEVOFFSET (0) = DEVICE1_OFFSET;
 	ENVSIZE (0) = ENV1_SIZE;
 	/* Default values are: erase-size=env-size */
@@ -1258,7 +1258,7 @@ static int parse_config ()
 #endif
 
 #ifdef HAVE_REDUND
-	strcpy (DEVNAME (1), DEVICE2_NAME);
+	DEVNAME (1) = DEVICE2_NAME;
 	DEVOFFSET (1) = DEVICE2_OFFSET;
 	ENVSIZE (1) = ENV2_SIZE;
 	/* Default values are: erase-size=env-size */
@@ -1297,6 +1297,7 @@ static int get_config (char *fname)
 	int i = 0;
 	int rc;
 	char dump[128];
+	char *devname;
 
 	fp = fopen (fname, "r");
 	if (fp == NULL)
@@ -1307,8 +1308,8 @@ static int get_config (char *fname)
 		if (dump[0] == '#')
 			continue;
 
-		rc = sscanf (dump, "%s %lx %lx %lx %lx",
-			     DEVNAME (i),
+		rc = sscanf (dump, "%ms %lx %lx %lx %lx",
+			     &devname,
 			     &DEVOFFSET (i),
 			     &ENVSIZE (i),
 			     &DEVESIZE (i),
@@ -1317,6 +1318,8 @@ static int get_config (char *fname)
 		if (rc < 3)
 			continue;
 
+		DEVNAME(i) = devname;
+
 		if (rc < 4)
 			/* Assume the erase size is the same as the env-size */
 			DEVESIZE(i) = ENVSIZE(i);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2014-04-18 13:22 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-28 16:03 [U-Boot] [PATCH v3 01/10] fw_env.c: Switch get_config to use '%ms' in sscanf Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 02/10] env_mmc.c: Allow environment to be used within SPL Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 03/10] env_mmc.c: Remove NULL check on tmp_env1/2 Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 04/10] mtd: Add a CONFIG_SPL_MTD_SUPPORT for a more full NAND subsystem in SPL Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 05/10] mtd: Build nand_util.o for CONFIG_ENV_IS_IN_NAND " Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 06/10] am335x_evm: Make SPL_OS also check the boot_os variable for falcon mode Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 07/10] README: Add CONFIG_SPL_OS_BOOT to README Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 08/10] README.falcon: Document environment variables for falcon mode Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 09/10] a3m071: Make spl_start_uboot test like getenv_yesno does Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-03-28 16:03 ` [U-Boot] [PATCH v3 10/10] spl_mmc/CONFIG_SPL_OS_BOOT: Allow environment to determine what to boot Tom Rini
2014-04-18 13:22   ` [U-Boot] [U-Boot, v3, " Tom Rini
2014-04-18 13:21 ` [U-Boot] [U-Boot, v3, 01/10] fw_env.c: Switch get_config to use '%ms' in sscanf Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox