--- embedtools/src/imgupd.c 2014/02/06 00:56:16 1.6.2.3 +++ embedtools/src/imgupd.c 2014/02/06 01:23:56 1.6.2.4 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: imgupd.c,v 1.6.2.3 2014/02/06 00:56:16 misho Exp $ + * $Id: imgupd.c,v 1.6.2.4 2014/02/06 01:23:56 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -92,8 +92,11 @@ EmptyStore(int img) for (i = howmany(iSize, bufSize); i < howmany(imgSize, bufSize); i++) if ((wlen = write(img, buf, bufSize)) == -1 || (wlen && wlen != bufSize)) { - EERROR(EIO, "Error at chunk %d init %d bytes, " - "should be %u\n", i, wlen, bufSize); + if (wlen == -1) + ESYSERR(0); + else + EERROR(EIO, "Error at chunk %d init %d bytes, " + "should be %u\n", i, wlen, bufSize); return -1; } else VERB(1) printf("+Written chunk #%d\n", i); @@ -271,6 +274,7 @@ main(int argc, char **argv) return 4; } } else { /* GET */ + iSize ^= iSize; if (EmptyStore(fd) == -1) { if (fd > 2) close(fd);