mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] bareboxenv: Return proper exit code on failure.
@ 2013-02-26 11:20 Christian Kapeller
  2013-02-26 11:36 ` Marc Kleine-Budde
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Kapeller @ 2013-02-26 11:20 UTC (permalink / raw)
  To: barebox

In case environment loading/saving failed, the calling program
should be informed about that by returning a non zero exit code.

Signed-off-by: Christian Kapeller <christian.kapeller@cmotion.eu>
---
 scripts/bareboxenv.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index 707d63d..3fd1429 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -138,7 +138,7 @@ void usage(char *prgname)
 int main(int argc, char *argv[])
 {
 	int opt;
-	int save = 0, load = 0, pad = 0, fd;
+	int save = 0, load = 0, pad = 0, err = 0, fd;
 	char *filename = NULL, *dirname = NULL;
 	int verbose = 0;
 
@@ -191,12 +191,20 @@ int main(int argc, char *argv[])
 	if (load) {
 		if (verbose)
 			printf("loading env from file %s to %s\n", filename, dirname);
-		envfs_load(filename, dirname, 0);
+
+		err = envfs_load(filename, dirname, 0);
+
+		if(verbose && err)
+			printf("loading env failed: %d\n", err);
 	}
 	if (save) {
 		if (verbose)
 			printf("saving contents of %s to file %s\n", dirname, filename);
-		envfs_save(filename, dirname);
+
+		err = envfs_save(filename, dirname);
+
+		if(verbose && err)
+			printf("saving env failed: %d\n", err);
 	}
-	exit(0);
+	exit((err)?1:0);
 }
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] bareboxenv: Return proper exit code on failure.
  2013-02-26 11:20 [PATCH] bareboxenv: Return proper exit code on failure Christian Kapeller
@ 2013-02-26 11:36 ` Marc Kleine-Budde
  2013-02-26 12:04   ` Christian Kapeller
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2013-02-26 11:36 UTC (permalink / raw)
  To: Christian Kapeller; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 1826 bytes --]

On 02/26/2013 12:20 PM, Christian Kapeller wrote:
> In case environment loading/saving failed, the calling program
> should be informed about that by returning a non zero exit code.
> 
> Signed-off-by: Christian Kapeller <christian.kapeller@cmotion.eu>
> ---
>  scripts/bareboxenv.c |   16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
> index 707d63d..3fd1429 100644
> --- a/scripts/bareboxenv.c
> +++ b/scripts/bareboxenv.c
> @@ -138,7 +138,7 @@ void usage(char *prgname)
>  int main(int argc, char *argv[])
>  {
>  	int opt;
> -	int save = 0, load = 0, pad = 0, fd;
> +	int save = 0, load = 0, pad = 0, err = 0, fd;
>  	char *filename = NULL, *dirname = NULL;
>  	int verbose = 0;
>  
> @@ -191,12 +191,20 @@ int main(int argc, char *argv[])
>  	if (load) {
>  		if (verbose)
>  			printf("loading env from file %s to %s\n", filename, dirname);
> -		envfs_load(filename, dirname, 0);
> +
> +		err = envfs_load(filename, dirname, 0);
> +
> +		if(verbose && err)
                 ^^^

space please

> +			printf("loading env failed: %d\n", err);
>  	}
>  	if (save) {
>  		if (verbose)
>  			printf("saving contents of %s to file %s\n", dirname, filename);
> -		envfs_save(filename, dirname);
> +
> +		err = envfs_save(filename, dirname);
> +
> +		if(verbose && err)

dito

> +			printf("saving env failed: %d\n", err);
>  	}
> -	exit(0);
> +	exit((err)?1:0);
extra spaces, please: err ? 1 : 0
>  }
> 
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH] bareboxenv: Return proper exit code on failure.
  2013-02-26 11:36 ` Marc Kleine-Budde
@ 2013-02-26 12:04   ` Christian Kapeller
  2013-02-26 14:02     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Kapeller @ 2013-02-26 12:04 UTC (permalink / raw)
  To: barebox

In case environment loading/saving failed, the calling program
should be informed about that by returning a non zero exit code.

Signed-off-by: Christian Kapeller <christian.kapeller@cmotion.eu>
---
 scripts/bareboxenv.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index 707d63d..fa6d0ed 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -138,7 +138,7 @@ void usage(char *prgname)
 int main(int argc, char *argv[])
 {
 	int opt;
-	int save = 0, load = 0, pad = 0, fd;
+	int save = 0, load = 0, pad = 0, err = 0, fd;
 	char *filename = NULL, *dirname = NULL;
 	int verbose = 0;
 
@@ -191,12 +191,20 @@ int main(int argc, char *argv[])
 	if (load) {
 		if (verbose)
 			printf("loading env from file %s to %s\n", filename, dirname);
-		envfs_load(filename, dirname, 0);
+
+		err = envfs_load(filename, dirname, 0);
+
+		if (verbose && err)
+			printf("loading env failed: %d\n", err);
 	}
 	if (save) {
 		if (verbose)
 			printf("saving contents of %s to file %s\n", dirname, filename);
-		envfs_save(filename, dirname);
+
+		err = envfs_save(filename, dirname);
+
+		if (verbose && err)
+			printf("saving env failed: %d\n", err);
 	}
-	exit(0);
+	exit(err ? 1 : 0);
 }
-- 
1.7.9.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] bareboxenv: Return proper exit code on failure.
  2013-02-26 12:04   ` Christian Kapeller
@ 2013-02-26 14:02     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2013-02-26 14:02 UTC (permalink / raw)
  To: Christian Kapeller; +Cc: barebox

Hi Christian,

On Tue, Feb 26, 2013 at 01:04:39PM +0100, Christian Kapeller wrote:
> In case environment loading/saving failed, the calling program
> should be informed about that by returning a non zero exit code.
> 
> Signed-off-by: Christian Kapeller <christian.kapeller@cmotion.eu>

Applied, thanks

Sascha

> ---
>  scripts/bareboxenv.c |   16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
> index 707d63d..fa6d0ed 100644
> --- a/scripts/bareboxenv.c
> +++ b/scripts/bareboxenv.c
> @@ -138,7 +138,7 @@ void usage(char *prgname)
>  int main(int argc, char *argv[])
>  {
>  	int opt;
> -	int save = 0, load = 0, pad = 0, fd;
> +	int save = 0, load = 0, pad = 0, err = 0, fd;
>  	char *filename = NULL, *dirname = NULL;
>  	int verbose = 0;
>  
> @@ -191,12 +191,20 @@ int main(int argc, char *argv[])
>  	if (load) {
>  		if (verbose)
>  			printf("loading env from file %s to %s\n", filename, dirname);
> -		envfs_load(filename, dirname, 0);
> +
> +		err = envfs_load(filename, dirname, 0);
> +
> +		if (verbose && err)
> +			printf("loading env failed: %d\n", err);
>  	}
>  	if (save) {
>  		if (verbose)
>  			printf("saving contents of %s to file %s\n", dirname, filename);
> -		envfs_save(filename, dirname);
> +
> +		err = envfs_save(filename, dirname);
> +
> +		if (verbose && err)
> +			printf("saving env failed: %d\n", err);
>  	}
> -	exit(0);
> +	exit(err ? 1 : 0);
>  }
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-02-26 14:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-26 11:20 [PATCH] bareboxenv: Return proper exit code on failure Christian Kapeller
2013-02-26 11:36 ` Marc Kleine-Budde
2013-02-26 12:04   ` Christian Kapeller
2013-02-26 14:02     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox