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

Re: [PATCH 4/5] Make 'diff_populate_filespec()' use the new 'strbuf_readlink()'

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Dec 18, 2008, 17:41 UTC
Message-ID
<494A8B57.6070106@lsrfire.ath.cx>
In-Reply-To
<alpine.LFD.2.00.0812180851120.14014@localhost.localdomain>
Linus Torvalds schrieb:
Show 34 quoted lines
> 
> On Thu, 18 Dec 2008, Mark Burton wrote:
>> Does it need a cast on some architectures?
> 
> Gaah. My bad. It should work fine ("unsigned long" is physically the same 
> type as "size_t" in your case), but on 32-bit x86, size_t is generally 
> "unsigned int" - which is the same physical type there (both int and long 
> are 32-bit) but causes a valid warning.
> 
> I think we should just make the "size" member "size_t". I use "unsigned 
> long" out of much too long habit, since we traditionally avoided "size_t" 
> in the kernel due to it just being another unnecessary architecture- 
> specific detail.
> 
> So the proper patch is probably just the following. Sorry about that,
> 
> 		Linus
> ---
>  diffcore.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/diffcore.h b/diffcore.h
> index 5b63458..16a73e6 100644
> --- a/diffcore.h
> +++ b/diffcore.h
> @@ -30,7 +30,7 @@ struct diff_filespec {
>  	void *data;
>  	void *cnt_data;
>  	const char *funcname_pattern_ident;
> -	unsigned long size;
> +	size_t size;
>  	int count;               /* Reference count */
>  	int xfrm_flags;		 /* for use by the xfrm */
>  	int rename_used;         /* Count of rename users */
Yes, but now I get two new warnings:

diff.c: In function `diff_populate_filespec': diff.c:1809: warning: passing arg 2 of `sha1_object_info' from incompatible pointer type diff.c:1811: warning: passing arg 3 of `read_sha1_file' from incompatible pointer type

If we followed that way along we'd convert just about everything to use size_t, which is going a bit too far during the -rc phase..

René
PS: In the other subthread, I was missing the "t" in "st" in line 1757,
not 1760.  Ahem.
Previous: Linus TorvaldsNext: Linus Torvalds
Message 15 of 33 in “Be careful about lstat()-vs-readlink()”
  1. 0/5 Be careful about lstat()-vs-readlink()Linus Torvalds, Dec 17, 2008
  2. 1/5 Add generic 'strbuf_readlink()' helper functionLinus Torvalds, Dec 17, 2008
  3. 2/5 Make 'ce_compare_link()' use the new 'strbuf_readlink()'Linus Torvalds, Dec 17, 2008
  4. 3/5 Make 'index_path()' use 'strbuf_readlink()'Linus Torvalds, Dec 17, 2008
  5. 4/5 Make 'diff_populate_filespec()' use the new 'strbuf_readlink()'Linus Torvalds, Dec 17, 2008
  6. 5/5 Make 'prepare_temp_file()' ignore st_size for symlinksLinus Torvalds, Dec 17, 2008
  7. 6/5 make_absolute_path(): check bounds when seeing an overlong symlinkJunio C Hamano, Dec 17, 2008
  8. 7/5 builtin-blame.c: use strbuf_readlink()Junio C Hamano, Dec 17, 2008
  9. 8/5 combine-diff.c: use strbuf_readlink()Junio C Hamano, Dec 17, 2008
  10. Linus TorvaldsDec 17, 2008
  11. Junio C HamanoDec 17, 2008
  12. Junio C HamanoDec 17, 2008
  13. Mark BurtonDec 18, 2008
  14. Linus TorvaldsDec 18, 2008
  15. René ScharfeDec 18, 2008
  16. Linus TorvaldsDec 18, 2008
  17. Olivier GalibertDec 18, 2008
  18. René ScharfeDec 18, 2008
  19. René ScharfeDec 18, 2008
  20. diff.c: fix pointer type warningRené Scharfe, Dec 19, 2008
  21. Junio C HamanoDec 19, 2008
  22. Junio C HamanoDec 17, 2008
  23. Jay SoffianDec 17, 2008
  24. Linus TorvaldsDec 17, 2008
  25. strbuf_readlink semantics update.Pierre Habouzit, Dec 23, 2008
  26. Pierre HabouzitDec 23, 2008
  27. Linus TorvaldsDec 23, 2008
  28. Pierre HabouzitDec 24, 2008
  29. René ScharfeDec 24, 2008
  30. Junio C HamanoDec 25, 2008
  31. Pierre HabouzitJan 4, 2009
  32. strbuf: instate cleanup rule in case of non-memory errorsRené Scharfe, Jan 6, 2009
  33. Junio C HamanoJan 7, 2009

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.