All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jehan Bing <jehan@orb.com>
To: linux-mtd@lists.infradead.org
Subject: Re: [PATH] [MTD-UTILS] Return error if failure when reading from standard input
Date: Mon, 08 Jun 2009 09:32:38 -0700	[thread overview]
Message-ID: <4A2D3D26.4090703@orb.com> (raw)
In-Reply-To: <1244441802.5847.337.camel@localhost.localdomain>

Fix nandwrite to return EXIT_FAILURE in case of error when using the
standard input instead of a file for input.


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

diff -up mtd-utils.loop/nandwrite.c mtd-utils.failed_patch/nandwrite.c
--- mtd-utils.loop/nandwrite.c	2009-06-05 18:32:56.000000000 -0700
+++ mtd-utils.failed_patch/nandwrite.c	2009-06-03 17:25:19.000000000 -0700
@@ -261,6 +261,7 @@ int main(int argc, char * const argv[])
 	int oobinfochanged = 0;
 	struct nand_oobinfo old_oobinfo;
 	int readcnt = 0;
+	bool failed = true;
 
 	process_options(argc, argv);
 
@@ -623,6 +624,8 @@ int main(int argc, char * const argv[])
 		mtdoffset += meminfo.writesize;
 	}
 
+	failed = false;
+
 closeall:
 	close(ifd);
 
@@ -637,7 +640,7 @@ restoreoob:
 
 	close(fd);
 
-	if ((ifd != STDIN_FILENO) && (imglen > 0)) {
+	if (failed || ((ifd != STDIN_FILENO) && (imglen > 0))) {
 		perror ("Data was only partially written due to error\n");
 		exit (EXIT_FAILURE);
 	}

  reply	other threads:[~2009-06-08 16:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-04 17:23 [PATH] [MTD-UTILS] Return error if failure when reading from standard input Nahor
2009-06-08  6:16 ` Artem Bityutskiy
2009-06-08 16:32   ` Jehan Bing [this message]
2009-06-09 12:39     ` Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A2D3D26.4090703@orb.com \
    --to=jehan@orb.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.