Skip to contentSkip to conversation

minor improvements for env tools

PATCH New Luka Perkov 2 participants 3 messages Sep 5, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 minor improvements for env tools

Patch from openwrt commit r20062 regarding erase_len.

Correct types inside two fprintf functions.

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

---

tools/env/fw_env.c +6 -3
index ed6b53f..4e4f6aa 100644
@@ -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;
 		}
#1 lore raw

PATCH 1/1 minor improvements for env tools

Dear Luka Perkov,

Quoted 21 lines · In message <[email protected]> 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 >

---

tools/env/fw_env.c +1 -1
index ed6b53f..4e4f6aa 100644
@@ -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;
 			}

tools/env/fw_env.c static int flash_write_buf (int dev, int fd, void *buf, size_t count, · line 785

Quoted 8 lines
tools/env/fw_env.c +4 -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

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"In matrimony, to hesitate is sometimes to be saved."        - Butler
#2 lore raw

PATCH 1/1 minor improvements for env tools

In reply to Luka Perkov

Dear Luka Perkov,

Quoted 5 lines · In message <[email protected]> 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

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Who alone has reason to *lie  himself  out*  of  actuality?  He  who
*suffers* from it."                             - Friedrich Nietzsche