git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] general style: replaces memcmp() with starts_with()

From
Jens Lehmann <jens.lehmann@web.de>
Date
Mar 12, 2014, 15:47 UTC
Message-ID
<5320818C.8070200@web.de>
In-Reply-To
<1394631854-11208-1-git-send-email-quintus.public@gmail.com>
Am 12.03.2014 14:44, schrieb Quint Guvernator:
Show 6 quoted lines
> 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>
> ---
...
Show 13 quoted lines
> 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).

Previous: Quint GuvernatorNext: Quint Guvernator
Message 6 of 10 in “general style: replaces memcmp() with starts_with()”
  1. general style: replaces memcmp() with starts_with()Quint Guvernator, Mar 12, 2014
  2. Duy NguyenMar 12, 2014
  3. Quint GuvernatorMar 12, 2014
  4. Michael HaggertyMar 13, 2014
  5. Quint GuvernatorMar 14, 2014
  6. Jens LehmannMar 12, 2014
  7. Quint GuvernatorMar 12, 2014
  8. Jens LehmannMar 12, 2014
  9. Jeff KingMar 12, 2014
  10. Duy NguyenMar 12, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.