git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jens Lehmann <Jens.Lehmann@web.de>
To: Quint Guvernator <quintus.public@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] general style: replaces memcmp() with starts_with()
Date: Wed, 12 Mar 2014 16:47:24 +0100	[thread overview]
Message-ID: <5320818C.8070200@web.de> (raw)
In-Reply-To: <1394631854-11208-1-git-send-email-quintus.public@gmail.com>

Am 12.03.2014 14:44, schrieb Quint Guvernator:
> memcmp() is replaced with starts_with() when comparing strings from the
> beginning. starts_with() looks nicer and it saves the extra argument of
> the length of the comparing string.
> 
> Signed-off-by: Quint Guvernator <quintus.public@gmail.com>
> ---

...

> diff --git a/submodule.c b/submodule.c
> index b80ecac..1edebc1 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -203,7 +203,7 @@ void gitmodules_config(void)
>  			if (active_nr > pos) {  /* there is a .gitmodules */
>  				const struct cache_entry *ce = active_cache[pos];
>  				if (ce_namelen(ce) == 11 &&
> -				    !memcmp(ce->name, ".gitmodules", 11))
> +				    !starts_with(ce->name, ".gitmodules"))
>  					gitmodules_is_unmerged = 1;
>  			}
>  		} else if (pos < active_nr) {

I think this hunk should be dropped as the memcmp() here doesn't mean
"starts with" but "is identical" (due to the "ce_namelen(ce) == 11" in
the line above).

  parent reply	other threads:[~2014-03-12 15:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-12 13:44 [PATCH] general style: replaces memcmp() with starts_with() Quint Guvernator
2014-03-12 13:51 ` Duy Nguyen
2014-03-12 14:06   ` Quint Guvernator
2014-03-13 16:05     ` Michael Haggerty
2014-03-14 16:32       ` Quint Guvernator
2014-03-12 15:47 ` Jens Lehmann [this message]
2014-03-12 16:46   ` Quint Guvernator
2014-03-12 17:22     ` Jens Lehmann
2014-03-12 18:00       ` Jeff King
2014-03-12 23:26       ` Duy Nguyen

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=5320818C.8070200@web.de \
    --to=jens.lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=quintus.public@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).