Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: Unreachable code in builtin-merge.c ?

From: Mikael Magnusson <hidden>
Date: 2016-06-15 22:47:36

2009/10/23 Zivkov, Sasa [off-list ref]:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help