[U-Boot-Users] [RFD] Consistent debugging output structure

Wolfgang Denk wd at denx.de
Mon Mar 24 09:50:02 CET 2003


In message <200303240844.21463.h.schurig at mn-logistik.de> you wrote:
>
> In U-Boot, I have the perception that things happen differently. You say "new 

Right. U-Boot is less complex, it has different targets, and I'm  not
Linus ;-)

> So, basically it's a tradeoff. Have clean code and pain. Or have not-so-clean 
> code, possible with overhead, and less pain.

Right.

To make this clear: I am not against cleaning up code in general. BUt
I don;t think it is something that is so urgent that we should do  it
now  in all source files. The disadvantages (like dropping stability)
are IMHO bigger than the advantages.

Let's perform such cleanup whenever we notice it in existing  coe  we
touch for other reasons (i. e. functional changes).


I would also  like  to  point  out  the  there  are  cases  where  an
alternative approach perfectly makes sense:

Compare:

----------------------------------------------------
#ifdef DEBUG
	for (i=0; i<N; ++i) {
		int val;
		
		val = some_function(arguments);

		printf ("Value = %d\n", val);
	}
#endif
----------------------------------------------------


against:

----------------------------------------------------
	for (i=0; i<N; ++i) { 
		some_type val;
		
		val = some_function(arguments);

		debug ("Value = %d\n", (int)val); 
	}
----------------------------------------------------


Functionally both  are  equivalent.  (2)  uses  the  "cleaner"  debug
interface. Yet I prefer (1) here, which is much clearer to me.

Also, are you really, really sure that the call to  "some_function()"
will   be  optimized  out  in  the  second  case?  For  all  possible
combinations of "some_type" and "some_function()"?


Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
"UNIX was not designed to stop you from doing stupid things,  because
that would also stop you from doing clever things."       - Doug Gwyn




More information about the U-Boot mailing list