Patchwork [4/4] libpayload: Use fprintf(stderr, ...) in library

login
register
about
Submitter Patrick Georgi
Date 2011-02-11 10:00:09
Message ID <1297436253.7802.3.camel@linux-0a8x.site>
Download mbox | patch
Permalink /patch/2626/
State Accepted
Commit r6359
Headers show

Comments

Patrick Georgi - 2011-02-11 10:00:09
If we have it, why not use it?

Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>
---
 payloads/libpayload/include/assert.h |    3 ++-
 payloads/libpayload/libc/lib.c       |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Stefan Reinauer - 2011-02-11 18:04:39
On 11.02.2011, at 02:00, Patrick Georgi <Patrick.Georgi@secunet.com> wrote:

> If we have it, why not use it?
> 
> Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>

Acked-by: Stefan Reinauer <stefan.reinauer@coreboot.org> 


> ---
> payloads/libpayload/include/assert.h |    3 ++-
> payloads/libpayload/libc/lib.c       |    2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/payloads/libpayload/include/assert.h b/payloads/libpayload/include/assert.h
> index fda4bc0..9968504 100644
> --- a/payloads/libpayload/include/assert.h
> +++ b/payloads/libpayload/include/assert.h
> @@ -28,6 +28,7 @@
>  */
> 
> #include <stdlib.h>
> +#include <stdio.h>
> 
> // assert's existence depends on NDEBUG state on _last_ inclusion of assert.h,
> // so don't guard this against double-includes.
> @@ -35,5 +36,5 @@
> // Heisenbugs appear if statement has side-effects. This could be worked around but does the standard allow for that?
> #define assert(statement)
> #else
> -#define assert(statement) if ((statement) == 0) { printf("assertion failed in file %s, function %s(), line %s\n", __FILE__, __FUNCTION__, __LINE__); abort(); }
> +#define assert(statement) if ((statement) == 0) { fprintf(stderr, "assertion failed in file %s, function %s(), line %s\n", __FILE__, __FUNCTION__, __LINE__); abort(); }
> #endif
> diff --git a/payloads/libpayload/libc/lib.c b/payloads/libpayload/libc/lib.c
> index baccc07..c8539cb 100644
> --- a/payloads/libpayload/libc/lib.c
> +++ b/payloads/libpayload/libc/lib.c
> @@ -109,7 +109,7 @@ u8 hex2bin(u8 h)
>  */
> void fatal(const char *msg)
> {
> -    printf("%s",msg);
> +    fprintf(stderr, "%s",msg);
>    halt();
> }
> 
> -- 
> 1.7.1
> 
> -- 
> coreboot mailing list: coreboot@coreboot.org
> http://www.coreboot.org/mailman/listinfo/coreboot
>

Patch

diff --git a/payloads/libpayload/include/assert.h b/payloads/libpayload/include/assert.h
index fda4bc0..9968504 100644
--- a/payloads/libpayload/include/assert.h
+++ b/payloads/libpayload/include/assert.h
@@ -28,6 +28,7 @@ 
  */
 
 #include <stdlib.h>
+#include <stdio.h>
 
 // assert's existence depends on NDEBUG state on _last_ inclusion of assert.h,
 // so don't guard this against double-includes.
@@ -35,5 +36,5 @@ 
 // Heisenbugs appear if statement has side-effects. This could be worked around but does the standard allow for that?
 #define assert(statement)
 #else
-#define assert(statement) if ((statement) == 0) { printf("assertion failed in file %s, function %s(), line %s\n", __FILE__, __FUNCTION__, __LINE__); abort(); }
+#define assert(statement) if ((statement) == 0) { fprintf(stderr, "assertion failed in file %s, function %s(), line %s\n", __FILE__, __FUNCTION__, __LINE__); abort(); }
 #endif
diff --git a/payloads/libpayload/libc/lib.c b/payloads/libpayload/libc/lib.c
index baccc07..c8539cb 100644
--- a/payloads/libpayload/libc/lib.c
+++ b/payloads/libpayload/libc/lib.c
@@ -109,7 +109,7 @@  u8 hex2bin(u8 h)
  */
 void fatal(const char *msg)
 {
-	printf("%s",msg);
+	fprintf(stderr, "%s",msg);
 	halt();
 }