Patchwork [4/5,v3,MTD-UTILS] Unified reading from standard input and from file

login
register
mail settings
Submitter Jehan Bing
Date Aug. 6, 2009, 12:41 a.m.
Message ID <4A7A26A4.6060803@orb.com>
Download mbox | patch
Permalink /patch/30816/
State Accepted
Commit ae2eeb41ad2b3209f90166b49fefedb40edc9432
Headers show

Comments

Jehan Bing - Aug. 6, 2009, 12:41 a.m.
Fix incorrect use of errno.

Signed-off-by: Jehan Bing <jehan@orb.com>

Patch

--- a/nandwrite.c	2009-08-04 17:10:59.000000000 -0700
+++ b/nandwrite.c	2009-08-04 17:11:03.000000000 -0700
@@ -626,8 +626,8 @@  int main(int argc, char * const argv[])
 		if (pwrite(fd, writebuf, meminfo.writesize, mtdoffset) != meminfo.writesize) {
 			erase_info_t erase;
 
-			perror ("pwrite");
 			if (errno != EIO) {
+				perror("pwrite");
 				goto closeall;
 			}
 
@@ -639,8 +639,9 @@  int main(int argc, char * const argv[])
 			fprintf(stderr, "Erasing failed write from %08lx-%08lx\n",
 				(long)erase.start, (long)erase.start+erase.length-1);
 			if (ioctl(fd, MEMERASE, &erase) != 0) {
+				int errno_tmp = errno;
 				perror("MEMERASE");
-				if (errno != EIO) {
+				if (errno_tmp != EIO) {
 					goto closeall;
 				}
 			}