Eliminate all of the console output message

Sterling Augustine sterling at tensilica.com
Tue Sep 26 15:47:41 UTC 2006


Why not just redirect stdout and stderr to /dev/null? Google for how to 
do this programmatically, internal to your application. It's not hard.

The problem you have is that an application could be calling "write" 
directly, without using any libc calls at all.



Jan-Benedict Glaw wrote:
> On Tue, 2006-09-26 17:40:42 +0800, colin <colin at realtek.com.tw> wrote:
> 
>>I am trying to eliminate all of the console output message of the embedded
>>application.
>>What I do is like this:
>>    #define puts do { } while (0)
>>
>>printf and putchar will also be replaced by this way.
>>Is it safe to do this?
> 
> 
> Consider:
> 
> 	while (1) {
> 		printf ("Next element: %d\n", n++);
> 		if (n == 10)
> 			break;
> 	}
> 
> So generally, this is not save, because you still need to evaluate the
> arguments.
> 
> However, in the Linux kernel uses something similar for embedded
> systems (linux-2.6.x/include/linux/kernel.h):
> 
> 150	static inline int printk(const char *s, ...)
> 151		__attribute__ ((format (printf, 1, 2)));
> 152	static inline int printk(const char *s, ...) { return 0; }
> 
> You can use something similar to still perform argument evaluation
> while optimizing out the whole call.  However, if you even miss to
> include your header containing this define, the program will still
> pull the function at link time.  Also keep in mind that some libraries
> will have wrapper macros for these funcions, pointing to actual
> differently named functions...
> 
> MfG, JBG
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://busybox.net/cgi-bin/mailman/listinfo/uclibc



More information about the uClibc mailing list