linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Enrico Jorns <ejo@pengutronix.de>
To: MTD Mailing List <linux-mtd@lists.infradead.org>
Cc: Enrico Jorns <ejo@pengutronix.de>
Subject: [PATCH] mtd-utils: ubinize: Always return error code (at least -1) in case of an error
Date: Fri, 11 Sep 2015 15:28:13 +0200	[thread overview]
Message-ID: <1441978093-20917-1-git-send-email-ejo@pengutronix.de> (raw)

ubinize should not fail silenty, this can be very annoying when using
it from other tools that rely on the exit code for determining the
success of their operation.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
 ubi-utils/ubinize.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ubi-utils/ubinize.c b/ubi-utils/ubinize.c
index 34f465a..60bbd9a 100644
--- a/ubi-utils/ubinize.c
+++ b/ubi-utils/ubinize.c
@@ -519,6 +519,7 @@ int main(int argc, char * const argv[])
 	 */
 	seek = ui.peb_size * 2;
 	if (lseek(args.out_fd, seek, SEEK_SET) != seek) {
+		err = -1;
 		sys_errmsg("cannot seek file \"%s\"", args.f_out);
 		goto out_free;
 	}
@@ -530,6 +531,7 @@ int main(int argc, char * const argv[])
 		int fd, j;
 
 		if (!sname) {
+			err = -1;
 			errmsg("ini-file parsing error (iniparser_getsecname)");
 			goto out_free;
 		}
@@ -550,6 +552,7 @@ int main(int argc, char * const argv[])
 		 */
 		for (j = 0; j < i; j++) {
 			if (vi[i].id == vi[j].id) {
+				err = -1;
 				errmsg("volume IDs must be unique, but ID %d "
 				       "in section \"%s\" is not",
 				       vi[i].id, sname);
@@ -557,6 +560,7 @@ int main(int argc, char * const argv[])
 			}
 
 			if (!strcmp(vi[i].name, vi[j].name)) {
+				err = -1;
 				errmsg("volume name must be unique, but name "
 				       "\"%s\" in section \"%s\" is not",
 				       vi[i].name, sname);
@@ -580,6 +584,7 @@ int main(int argc, char * const argv[])
 		if (img) {
 			fd = open(img, O_RDONLY);
 			if (fd == -1) {
+				err = fd;
 				sys_errmsg("cannot open \"%s\"", img);
 				goto out_free;
 			}
-- 
2.5.0

             reply	other threads:[~2015-09-11 13:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 13:28 Enrico Jorns [this message]
2015-09-29 13:20 ` [PATCH] mtd-utils: ubinize: Always return error code (at least -1) in case of an error Enrico Joerns
2015-09-29 13:40   ` Richard Weinberger
2015-09-29 19:20     ` Brian Norris

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=1441978093-20917-1-git-send-email-ejo@pengutronix.de \
    --to=ejo@pengutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).