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

Re: [PATCH/RFC v1 1/1] Use size_t instead of unsigned long

From
René Scharfe <l.s.r@web.de>
Date
Nov 19, 2018, 18:15 UTC
Message-ID
<0e38e87d-0b8a-054d-1ae0-37a225845e3b@web.de>
In-Reply-To
<f0c0e2e8-717d-9973-5533-8b806474e119@web.de>
Am 19.11.2018 um 06:33 schrieb Torsten Bögershausen:
Show 30 quoted lines
> The archive-tar.c is actually a good example, why a step-by-step update
> is not ideal (the code would not work any more on Win64).
> 
> If we look here:
> 
> static int stream_blocked(const struct object_id *oid)
> {
> 	struct git_istream *st;
> 	enum object_type type;
> 	size_t sz;
> 	char buf[BLOCKSIZE];
> 	ssize_t readlen;
> 
> 	st = open_istream(oid, &type, &sz, NULL);
>                                       ^^^^^
> 	if (!st)
> 		return error(_("cannot stream blob %s"), oid_to_hex(oid));
> 	for (;;) {
> 
> The sz variable must follow whatever open_istream() uses, so if we start
> with archive-tar.c, we must use either size_t or ulong, whatever
> open_istream() needs. Otherwise things will break:
> archive-tar.c uses ulong, open_istream() size_t, but we are passing pointers
> around, and here &ulong != &size_t
> 
> If we only update open_istream(), but not archive-tar.c, then
> things are not better:
> &size_t != &ulong.
> 
> I don't have a good idea how to split the patch.

sz is not actually used later in that function; this change can be done independently of any other ulong/size_t conversion in that file.

Hmm, looking at that call I wonder why open_istream() doesn't return type and size in the struct git_istream. To make it match read_object_file(), I suppose. Perhaps it's an opportunity to improve its interface?

René
Previous: Torsten BögershausenNext: Torsten Bögershausen
Message 5 of 13 in “Use size_t instead of unsigned long”
  1. 1/1 Use size_t instead of unsigned longtboegi@web.de, Nov 17, 2018
  2. Derrick StoleeNov 18, 2018
  3. Junio C HamanoNov 18, 2018
  4. Torsten BögershausenNov 19, 2018
  5. René ScharfeNov 19, 2018
  6. Torsten BögershausenNov 19, 2018
  7. Junio C HamanoNov 20, 2018
  8. 1/1 Use size_t instead of 'unsigned long' for data in memorytboegi@web.de, Nov 20, 2018
  9. Derrick StoleeNov 21, 2018
  10. Thomas BraunJan 16, 2019
  11. Torsten BögershausenJan 19, 2019
  12. Thomas BraunJan 22, 2019
  13. 1/1 Use size_t instead of 'unsigned long' for data in memorytboegi@web.de, Apr 13, 2019

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.