Re: Switch -Wunused-variable on?

Andreas Schwab
2012-04-25T07:51:03Z

"Maciej W. Rozycki" <macro@codesourcery.com> writes:

> Instead write this:
>
> int target_frobnicate (int count);
>
> #ifdef TARGET_NEEDS_HARD_FROBNICATION
> int target_frobnicate_harder (int count, int status);
> #define target_needs_hard_frobnication 1
> #else
> #define target_needs_hard_frobnication 0
> endif
>
> int
> handle_frobnication (int count)
> {
> int status;
> int i;
>
> status = target_frobnicate (count);
> if (target_needs_hard_frobnication)
> for (i = 0; i < count; i++)
> status = target_frobnicate_harder (i, status);
>
> return status;
> }
>
> -- "i" is now live in all cases and also IMHO handle_frobnication is more
> readable.

It also requires an unconditional declaration and definition of
target_frobnicate_harder.

Andreas.

--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."