[U-Boot] minor improvements for env tools

Submitted by Luka Perkov on Sept. 5, 2011, 8:38 p.m.

Details

Message ID 20110905203848.GA12498@w500.gigaset.lan
State Changes Requested
Headers show

Commit Message

Luka Perkov Sept. 5, 2011, 8:38 p.m.
Patch from openwrt commit r20062 regarding erase_len.

Correct types inside two fprintf functions.

Signed-off-by: Luka Perkov < lists ->-to->- lukaperkov.net >
---

Comments

Wolfgang Denk Sept. 5, 2011, 9:02 p.m.
Dear Luka Perkov,

In message <20110905203848.GA12498@w500.gigaset.lan> you wrote:
> Patch from openwrt commit r20062 regarding erase_len.
> 
> Correct types inside two fprintf functions.
> 
> Signed-off-by: Luka Perkov < lists ->-to->- lukaperkov.net >
> ---
> 
> diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
> index ed6b53f..4e4f6aa 100644
> --- a/tools/env/fw_env.c
> +++ b/tools/env/fw_env.c
> @@ -488,7 +488,7 @@ int fw_setenv(int argc, char *argv[])
>  			value = (char *)malloc(len - strlen(name));
>  			if (!value) {
>  				fprintf(stderr,
> -				"Cannot malloc %u bytes: %s\n",
> +				"Cannot malloc %zu bytes: %s\n",
>  				len - strlen(name), strerror(errno));
>  				return -1;
>  			}
> @@ -779,7 +779,10 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
>  	erase_offset = (offset / blocklen) * blocklen;
>  
>  	/* Maximum area we may use */
> -	erase_len = top_of_range - erase_offset;
> +	if (mtd_type == MTD_NANDFLASH)
> +		erase_len = top_of_range - erase_offset;
> +	else
> +		erase_len = blocklen;

This is obviously not a printf() type fix.  Please submit as separate
patch, with exact descrition what this is good for, i. e. which
problem it fixes.

Thanks.


Best regards,

Wolfgang Denk
Wolfgang Denk Sept. 5, 2011, 9:04 p.m.
Dear Luka Perkov,

In message <20110905203848.GA12498@w500.gigaset.lan> you wrote:
> Patch from openwrt commit r20062 regarding erase_len.
> 
> Correct types inside two fprintf functions.
> 
> Signed-off-by: Luka Perkov < lists ->-to->- lukaperkov.net >

Also, please fix you SoB line. "lists ->-to->- lukaperkov.net" is not
a valid mail address.

Best regards,

Wolfgang Denk

Patch hide | download patch | download mbox

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index ed6b53f..4e4f6aa 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -488,7 +488,7 @@  int fw_setenv(int argc, char *argv[])
 			value = (char *)malloc(len - strlen(name));
 			if (!value) {
 				fprintf(stderr,
-				"Cannot malloc %u bytes: %s\n",
+				"Cannot malloc %zu bytes: %s\n",
 				len - strlen(name), strerror(errno));
 				return -1;
 			}
@@ -779,7 +779,10 @@  static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 	erase_offset = (offset / blocklen) * blocklen;
 
 	/* Maximum area we may use */
-	erase_len = top_of_range - erase_offset;
+	if (mtd_type == MTD_NANDFLASH)
+		erase_len = top_of_range - erase_offset;
+	else
+		erase_len = blocklen;
 
 	blockstart = erase_offset;
 	/* Offset inside a block */
@@ -802,7 +805,7 @@  static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 		data = malloc (erase_len);
 		if (!data) {
 			fprintf (stderr,
-				 "Cannot malloc %u bytes: %s\n",
+				 "Cannot malloc %zu bytes: %s\n",
 				 erase_len, strerror (errno));
 			return -1;
 		}