Patchwork [U-Boot,3/3] common/cmd_ximg.c: add ifdef protection for gzip uncompression

login
register
mail settings
Submitter Matthew McClintock
Date May 23, 2011, 6:29 p.m.
Message ID <1306175353-2983-3-git-send-email-msm@freescale.com>
Download mbox | patch
Permalink /patch/97028/
State Superseded
Headers show

Comments

Matthew McClintock - May 23, 2011, 6:29 p.m.
Print a message if we do not have the ability to uncompress a gzip
image. Before, u-boot would just assume the routines were available

Signed-off-by: Matthew McClintock <msm@freescale.com>
---
 common/cmd_ximg.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Mike Frysinger - May 24, 2011, 3:10 a.m.
On Monday, May 23, 2011 14:29:13 Matthew McClintock wrote:
> --- a/common/cmd_ximg.c
> +++ b/common/cmd_ximg.c
>  			break;
>  		case IH_COMP_GZIP:
> +#ifdef CONFIG_GZIP
>  			printf ("   Uncompressing part %d ... ", part);
>  			if (gunzip ((void *) dest, unc_len,
>  				    (uchar *) data, &len) != 0) {
>  				puts ("GUNZIP ERROR - image not loaded\n");
>  				return 1;
>  			}
> +#else
> +			printf("    gzip decompression not supported in this"
> +				" build!\n");
> +			return 1;
> +#endif

a few things ...
 - dont split string constants
 - if you arent using any formats, then puts() is better
 - the #else isnt even necessary ... wrap the "case" in the #ifdef too, and 
then at runtime this will automatically fall through to the already existing 
default: case
-mike

Patch

diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
index dceb975..2ec7ba4 100644
--- a/common/cmd_ximg.c
+++ b/common/cmd_ximg.c
@@ -216,12 +216,18 @@  do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 #endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
 			break;
 		case IH_COMP_GZIP:
+#ifdef CONFIG_GZIP
 			printf ("   Uncompressing part %d ... ", part);
 			if (gunzip ((void *) dest, unc_len,
 				    (uchar *) data, &len) != 0) {
 				puts ("GUNZIP ERROR - image not loaded\n");
 				return 1;
 			}
+#else
+			printf("    gzip decompression not supported in this"
+				" build!\n");
+			return 1;
+#endif
 			break;
 #if defined(CONFIG_BZIP2)
 		case IH_COMP_BZIP2: