[U-Boot] [PATCH] zlib: fix code when DEBUG is defined
Wolfgang Denk
wd at denx.de
Thu Sep 3 09:59:43 CEST 2009
Dear Giuseppe CONDORELLI,
In message <1251965311-5739-1-git-send-email-giuseppe.condorelli at st.com> you wrote:
> Removed stdio.h inclusion and moved trace macros to use printf avoiding to
> write debug informations to standard error.
>
> Signed-off-by: Giuseppe Condorelli <giuseppe.condorelli at st.com>
> ---
> lib_generic/zlib.c | 59 +++++++++++++++++++++++++--------------------------
> 1 files changed, 29 insertions(+), 30 deletions(-)
>
> diff --git a/lib_generic/zlib.c b/lib_generic/zlib.c
> index 1b6db32..8dca594 100644
> --- a/lib_generic/zlib.c
> +++ b/lib_generic/zlib.c
> @@ -27,6 +27,7 @@
> #define ZLIB_INTERNAL
>
> #include "u-boot/zlib.h"
> +#include <common.h>
> /* To avoid a build time warning */
> #ifdef STDC
> #include <malloc.h>
> @@ -83,15 +84,14 @@ typedef unsigned long ulg;
>
> /* Diagnostic functions */
> #ifdef DEBUG
> -#include <stdio.h>
> extern int z_verbose;
> extern void z_error OF((char *m));
> #define Assert(cond,msg) {if(!(cond)) z_error(msg);}
> -#define Trace(x) {if (z_verbose>=0) fprintf x ;}
> -#define Tracev(x) {if (z_verbose>0) fprintf x ;}
> -#define Tracevv(x) {if (z_verbose>1) fprintf x ;}
> -#define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
> -#define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
> +#define Trace(x) {if (z_verbose>=0) printf x ;}
> +#define Tracev(x) {if (z_verbose>0) printf x ;}
> +#define Tracevv(x) {if (z_verbose>1) printf x ;}
> +#define Tracec(c,x) {if (z_verbose>0 && (c)) printf x ;}
> +#define Tracecv(c,x) {if (z_verbose>1 && (c)) printf x ;}
> #else
> #define Assert(cond,msg)
> #define Trace(x)
> @@ -502,7 +502,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
> bits -= op;
> op = (unsigned)(this.op);
> if (op == 0) { /* literal */
> - Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
> + Tracevv((this.val >= 0x20 && this.val < 0x7f ?
Hm... instead of changing all the Trace* macro definitions and all
places where these are used it would be less intrusive to define
something like this:
#define fprintf(fp,...) printf(__VA_ARGS__)
(add before the Trace* defintiions).
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In the beginning, there was nothing, which exploded.
- Terry Pratchett, _Lords and Ladies_
More information about the U-Boot
mailing list