This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make the compiler do the math 2.


Nick Clifton <nickc@redhat.com> writes:

> Like this:
>
>   if (CONST_STRNEQ (o->name, GCC_EXCEPT_TABLE))
>     {
>       char *fn_name;
>       char *sec_name;
>       asection *fn_text;
>       unsigned o_name_prefix_len  = sizeof (GCC_EXCEPT_TABLE) - 1;
>       unsigned fn_name_prefix_len = sizeof (DOT_TEXT_DOT) - 1;

I'd make that use strlen anyway.  It more clearly states the intent and
the compiler can optimize it out nevertheless.

>   Actually I think that it might be clearer if we used two %s operators
> inside the sprintf like this:
>
>       sprintf (fn_name, "%s%s", DOT_TEXT_DOT, sec_name);

I agree.  Again, the compiler is allowed to optimize sprintf out of
existence.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]