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

Re: [PATCH]: tree-walk.h: Warning fix

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 23, 2007, 06:19 UTC
Message-ID
<7v1wg39oqc.fsf@assigned-by-dhcp.pobox.com>
In-Reply-To
<20070619231127.7ffe273b@gnut>

"Luiz Fernando N. Capitulino" <lcapitulino@mandriva.com.br> writes:

Show 13 quoted lines
> diff --git a/tree-walk.h b/tree-walk.h
> index ee747ab..625198f 100644
> --- a/tree-walk.h
> +++ b/tree-walk.h
> @@ -22,7 +22,7 @@ static inline const unsigned char *tree_entry_extract(struct tree_desc *desc, co
>  
>  static inline int tree_entry_len(const char *name, const unsigned char *sha1)
>  {
> -	return (char *)sha1 - (char *)name - 1;
> +	return (const char *)sha1 - (const char *)name - 1;
>  }
>  
>  void update_tree_entry(struct tree_desc *);

Grumble. Incoming "name" is already (const char*), isn't it? I'd cast only the sha1 side and apply.

However, I think -Wcast-qual is a pretty useless option.  

The nastiest one, if you care, is exec_cmd.c::execv_git_cmd() where we never muck with "const char **argv" ourselves, but we have to call execve(), which takes (char**) as its second parameter. We cast away constness for that call; otherwise you would then get prototype mismatch.

Previous: Luiz Fernando N. CapitulinoNext: Luiz Fernando N. Capitulino
Message 2 of 3 in “: tree-walk.h: Warning fix”
  1. : tree-walk.h: Warning fixLuiz Fernando N. Capitulino, Jun 20, 2007
  2. Junio C HamanoJun 23, 2007
  3. Luiz Fernando N. CapitulinoJun 24, 2007

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.