All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Roys <roysjosh@gmail.com>
To: "Zivkov, Sasa" <sasa.zivkov@sap.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Unreachable code in builtin-merge.c ?
Date: Fri, 23 Oct 2009 11:14:43 -0400	[thread overview]
Message-ID: <4AE1C863.3070907@gmail.com> (raw)
In-Reply-To: <B221C4384AE5104EB414A877DFD0372C0B0092C0C5@DEWDFECCR04.wdf.sap.corp>

On 10/23/2009 11:03 AM, Zivkov, Sasa wrote:
> 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?
>
>
> Saša Živkov
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Hello,

Not quite :)  The strcmp() function actually returns 0 when the strings 
match (I know, it looks weird "!strcmp" -> "not string compare?!"), so 
the "if" really means: "if strategy is equal to 'recursive' or 
'subtree', do the following..."

Hope to help,

Josh

  parent reply	other threads:[~2009-10-23 15:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-23 15:03 Unreachable code in builtin-merge.c ? Zivkov, Sasa
2009-10-23 15:12 ` Mikael Magnusson
2009-10-23 15:14 ` Joshua Roys [this message]
2009-10-23 15:39   ` Zivkov, Sasa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AE1C863.3070907@gmail.com \
    --to=roysjosh@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sasa.zivkov@sap.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.