[PATCH] Check mac-address first in fsl_soc.c

Timur Tabi timur at freescale.com
Wed Feb 14 04:45:15 EST 2007


Kumar Gala wrote:

> How about something like comparing against a local null array instead.  
> Something like:
> 
>     u8 null_mac_addr[6] = { 0 };
>     if (!mac_addr || (memcmp(mac_addr, null_mac_addr, 6) == 0)) {

I believe this will cause the compiler to generate more code, not less.  When 
you declare an initialized array as a local variable, the compiler reserves 
space on the stack, and then it generates code to copy the data from some global 
storage to the stack.

If I inline a string instead, however, the compiler will just put the string in 
global storage and reference it directly.  The compiler should be able to detect 
multiple instances of the same string, and store them as a single string.

If you still want null_mac_addr[], you would need to do this:

	static const u8 null_mac_addr[6] = { 0 };

Although frankly it would be nice if the Ethernet module had static globals and 
functions for this sort of thing.

Do you still want me to create null_mac_addr[], as above?  I was going to put 
the code inside an inline function anyway, per Sergei's request.

-- 
Timur Tabi
Linux Kernel Developer @ Freescale



More information about the Linuxppc-dev mailing list