Re: Unreachable code in builtin-merge.c ?
- From
- Mikael Magnusson <mikachu@gmail.com>
- Date
- Oct 23, 2009, 15:12 UTC
- Message-ID
- <237967ef0910230812r621ac705qb029dade20c455a7@mail.gmail.com>
- In-Reply-To
- <B221C4384AE5104EB414A877DFD0372C0B0092C0C5@DEWDFECCR04.wdf.sap.corp>
2009/10/23 Zivkov, Sasa <sasa.zivkov@sap.com>:
Show 9 quoted lines
> In the try_merge_strategy function the expression in the following if statement seems to always evaluate to TRUE:
>
> if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree")) {
>
> If strategy is "recursive" then !strcmp(strategy, "subtree") evaluates to TRUE.
> If strategy is "subtree" then !strcmp(strategy, "recursive") evaluates to TRUE.
> If strategy is neither "recursive" nor "subtree" then any side of || evaluates to TRUE.
>
> Looks like the code in the else block is unreachable?You seem to have forgotten that strcmp returns 0 when the strings match. (It returns -1 or 1 when they don't, depending on their alphabetical ordering).
-- Mikael Magnusson