public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] zlib: fix code when DEBUG is defined
  2009-09-03  9:30 [U-Boot] [PATCH v2] zlib: fix code when DEBUG is defined Giuseppe CONDORELLI
@ 2009-09-03  8:26 ` Wolfgang Denk
  2009-09-03  9:41   ` Giuseppe CONDORELLI
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2009-09-03  8:26 UTC (permalink / raw)
  To: u-boot

Dear Giuseppe CONDORELLI,

In message <1251970209-9053-1-git-send-email-giuseppe.condorelli@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@st.com>
> ---
>  lib_generic/zlib.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

old:
	1 files changed, 29 insertions(+), 30 deletions(-)
new:
	1 files changed, 2 insertions(+), 2 deletions(-)

Isn't that great?

> @@ -2000,7 +2001,6 @@ void z_error (m)
>      char *m;
>  {
>  	fprintf(stderr, "%s\n", m);
> -	exit(1);
>  }
>  #endif

Sorry for not catching this in the first round.

What happens when we return here? Obviously this function is supposed
to never return. Should we call hang() here?

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
"Where shall I begin, please your Majesty?" he asked. "Begin  at  the
beginning,"  the  King said, gravely, "and go on till you come to the
end: then stop."    - Alice's Adventures in Wonderland, Lewis Carroll

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

* [U-Boot] [PATCH v2] zlib: fix code when DEBUG is defined
@ 2009-09-03  9:30 Giuseppe CONDORELLI
  2009-09-03  8:26 ` Wolfgang Denk
  0 siblings, 1 reply; 4+ messages in thread
From: Giuseppe CONDORELLI @ 2009-09-03  9:30 UTC (permalink / raw)
  To: u-boot

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@st.com>
---
 lib_generic/zlib.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib_generic/zlib.c b/lib_generic/zlib.c
index 1b6db32..25ae88f 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,10 +84,10 @@ 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 fprintf(fp,...)	printf(__VA_ARGS__)
 #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 ;}
@@ -2000,7 +2001,6 @@ void z_error (m)
     char *m;
 {
 	fprintf(stderr, "%s\n", m);
-	exit(1);
 }
 #endif
 
-- 
1.6.0.6

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

* [U-Boot] [PATCH v2] zlib: fix code when DEBUG is defined
  2009-09-03  8:26 ` Wolfgang Denk
@ 2009-09-03  9:41   ` Giuseppe CONDORELLI
  2009-09-03 10:09     ` Wolfgang Denk
  0 siblings, 1 reply; 4+ messages in thread
From: Giuseppe CONDORELLI @ 2009-09-03  9:41 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Isn't that great?
Sure!!! :)

> What happens when we return here? Obviously this function is supposed
> to never return. Should we call hang() here?

Given that z_error is invoked by Assert macro (never used) and that "exit"
function (other than closing all
opened stream) will terminate program execution, I suggest to remove it
without adding others instructions letting
u-boot to hang by itself (if it will do this).

What's your idea?
Thanks,
Giuseppe

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de] 
Sent: Thursday, September 03, 2009 10:26 AM
To: Giuseppe CONDORELLI
Cc: u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH v2] zlib: fix code when DEBUG is defined

Dear Giuseppe CONDORELLI,

In message <1251970209-9053-1-git-send-email-giuseppe.condorelli@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@st.com>
> ---
>  lib_generic/zlib.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

old:
	1 files changed, 29 insertions(+), 30 deletions(-)
new:
	1 files changed, 2 insertions(+), 2 deletions(-)

Isn't that great?

> @@ -2000,7 +2001,6 @@ void z_error (m)
>      char *m;
>  {
>  	fprintf(stderr, "%s\n", m);
> -	exit(1);
>  }
>  #endif

Sorry for not catching this in the first round.

What happens when we return here? Obviously this function is supposed
to never return. Should we call hang() here?

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
"Where shall I begin, please your Majesty?" he asked. "Begin  at  the
beginning,"  the  King said, gravely, "and go on till you come to the
end: then stop."    - Alice's Adventures in Wonderland, Lewis Carroll

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

* [U-Boot] [PATCH v2] zlib: fix code when DEBUG is defined
  2009-09-03  9:41   ` Giuseppe CONDORELLI
@ 2009-09-03 10:09     ` Wolfgang Denk
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Denk @ 2009-09-03 10:09 UTC (permalink / raw)
  To: u-boot

Dear Giuseppe CONDORELLI,

In message <011301ca2c7a$b5d83c40$c08182a4@st.com> you wrote:
> 
> > What happens when we return here? Obviously this function is supposed
> > to never return. Should we call hang() here?
> 
> Given that z_error is invoked by Assert macro (never used) and that "exit"
> function (other than closing all
> opened stream) will terminate program execution, I suggest to remove it
> without adding others instructions letting
> u-boot to hang by itself (if it will do this).

Well, if you just return from z_error() after an error condition  was
detected, and continue to run, this will cause undefined behaviour. I
prefer  to  have  a  clear  error  condition  which halts the system,
instead of having a system which continues to  run  but  does  random
things on me, eventually causing bigger damages.

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
Time is a drug. Too much of it kills you.
                                      - Terry Pratchett, _Small Gods_

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

end of thread, other threads:[~2009-09-03 10:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-03  9:30 [U-Boot] [PATCH v2] zlib: fix code when DEBUG is defined Giuseppe CONDORELLI
2009-09-03  8:26 ` Wolfgang Denk
2009-09-03  9:41   ` Giuseppe CONDORELLI
2009-09-03 10:09     ` Wolfgang Denk

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