All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd-utils: ubinize: Always return error code (at least -1) in case of an error
@ 2015-09-11 13:28 Enrico Jorns
  2015-09-29 13:20 ` Enrico Joerns
  0 siblings, 1 reply; 4+ messages in thread
From: Enrico Jorns @ 2015-09-11 13:28 UTC (permalink / raw)
  To: MTD Mailing List; +Cc: Enrico Jorns

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd-utils: ubinize: Always return error code (at least -1) in case of an error
  2015-09-11 13:28 [PATCH] mtd-utils: ubinize: Always return error code (at least -1) in case of an error Enrico Jorns
@ 2015-09-29 13:20 ` Enrico Joerns
  2015-09-29 13:40   ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Enrico Joerns @ 2015-09-29 13:20 UTC (permalink / raw)
  To: MTD Mailing List

Any comments on this?

On 09/11/2015 03:28 PM, Enrico Jorns wrote:
> 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;
>   			}
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd-utils: ubinize: Always return error code (at least -1) in case of an error
  2015-09-29 13:20 ` Enrico Joerns
@ 2015-09-29 13:40   ` Richard Weinberger
  2015-09-29 19:20     ` Brian Norris
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2015-09-29 13:40 UTC (permalink / raw)
  To: Enrico Joerns; +Cc: MTD Mailing List

On Tue, Sep 29, 2015 at 3:20 PM, Enrico Joerns <ejo@pengutronix.de> wrote:
> Any comments on this?

Looks good to me!

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd-utils: ubinize: Always return error code (at least -1) in case of an error
  2015-09-29 13:40   ` Richard Weinberger
@ 2015-09-29 19:20     ` Brian Norris
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2015-09-29 19:20 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: Enrico Joerns, MTD Mailing List

On Tue, Sep 29, 2015 at 03:40:38PM +0200, Richard Weinberger wrote:
> On Tue, Sep 29, 2015 at 3:20 PM, Enrico Joerns <ejo@pengutronix.de> wrote:
> > Any comments on this?
> 
> Looks good to me!

Pushed to mtd-utils.git.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-29 19:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-11 13:28 [PATCH] mtd-utils: ubinize: Always return error code (at least -1) in case of an error Enrico Jorns
2015-09-29 13:20 ` Enrico Joerns
2015-09-29 13:40   ` Richard Weinberger
2015-09-29 19:20     ` Brian Norris

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.