[PATCH] ldso - minor changes, saving some bytes

Rob Landley rob at landley.net
Sun Jan 11 06:34:49 UTC 2009


On Saturday 10 January 2009 11:55:55 olsajiri at gmail.com wrote:
>  	_dl_read(infile, header, _dl_pagesize);
>  	epnt = (ElfW(Ehdr) *) (intptr_t) header;
> -	if (epnt->e_ident[0] != 0x7f ||
> -			epnt->e_ident[1] != 'E' ||
> -			epnt->e_ident[2] != 'L' ||
> -			epnt->e_ident[3] != 'F')
> +	if (epnt->e_ident[EI_MAG0] != ELFMAG0 ||
> +	    epnt->e_ident[EI_MAG1] != ELFMAG1 ||
> +	    epnt->e_ident[EI_MAG2] != ELFMAG2 ||
> +	    epnt->e_ident[EI_MAG3] != ELFMAG3)

Why?  The values are never going to change (it would break compatability with 
the entire world), and using the constants you can see what they actually are 
and where they are.

Using macros here only serves to obscure the code to a casual reader.

Rob


More information about the uClibc mailing list