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

Re: [PATCH v3 5/8] evolve: Add the change-table structure

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 28, 2019, 23:08 UTC
Message-ID
<nycvar.QRO.7.76.6.1901290005390.41@tvgsbejvaqbjf.bet>
In-Reply-To
<nycvar.QRO.7.76.6.1901280858060.41@tvgsbejvaqbjf.bet>
Hi Junio,
On Mon, 28 Jan 2019, Johannes Schindelin wrote:
Show 16 quoted lines
> On Sun, 27 Jan 2019, sxenos@google.com wrote:
> 
> > +	new_item->util = (void*)index;
> 
> This is not good. You are using a `long` here. The 80s called and want
> their now-obsolete data types back.
> 
> If you want a data type that can take an integer but also a pointer, use
> `intptr_t` instead.
> 
> But even that is not good practice. What you really want here is to use a
> union of the data types that you want to store in that `util` field.
> 
> This is not merely academic, your code causes compile errors on Windows:
> 
> https://dev.azure.com/gitgitgadget/git/_build/results?buildId=400&view=logs&jobId=fd490c07-0b22-5182-fac9-6d67fe1e939b&taskId=ce91d5d6-0c55-50f5-8ab9-6695c03ab102&lineStart=430&lineEnd=440&colStart=1&colEnd=1

Since Stefan did not grace us with an answer, Junio, could I ask you to squash this in (which is by no means a satisfactory fix, but it is a stopgap to get `pu` building again)?

-- snipsnap --
diff --git a/change-table.c b/change-table.c
index 2e0d935de846..197ce2783532 100644
--- a/change-table.c
+++ b/change-table.c
@@ -103,7 +103,7 @@ void change_table_add(struct change_table *to_modify, const char *refname,
 	new_head->hidden = starts_with(refname, "refs/hiddenmetas/");
 
 	new_item = string_list_insert(&to_modify->refname_to_change_head, refname);
-	new_item->util = (void*)index;
+	new_item->util = (void *)(intptr_t)index;
 	// Use pointers to the copy of the string we're retaining locally
 	refname = new_item->string;
 
@@ -201,6 +201,6 @@ struct change_head* get_change_head(struct change_table *heads,
 		return NULL;
 	}
 
-	index = (long)item->util;
+	index = (long)(intptr_t)item->util;
 	return &(heads->heads.array[index]);
 }
Previous: Johannes SchindelinNext: Stefan Xenos
Message 9 of 15 in “technical doc: add a design doc for the evolve command”
  1. 1/8 technical doc: add a design doc for the evolve commandsxenos@google.com, Jan 27, 2019
  2. 2/8 sha1-array: Implement oid_array_readonly_containssxenos@google.com, Jan 27, 2019
  3. Junio C HamanoJan 28, 2019
  4. 3/8 ref-filter: Add the metas namespace to ref-filtersxenos@google.com, Jan 27, 2019
  5. 4/8 evolve: Add support for parsing metacommitssxenos@google.com, Jan 27, 2019
  6. Junio C HamanoJan 28, 2019
  7. 5/8 evolve: Add the change-table structuresxenos@google.com, Jan 27, 2019
  8. Johannes SchindelinJan 28, 2019
  9. Johannes SchindelinJan 28, 2019
  10. Stefan XenosJan 28, 2019
  11. Junio C HamanoJan 29, 2019
  12. Stefan XenosJan 29, 2019
  13. 6/8 evolve: Add support for writing metacommitssxenos@google.com, Jan 27, 2019
  14. 7/8 evolve: Implement the git change commandsxenos@google.com, Jan 27, 2019
  15. 8/8 evolve: Add the git change list commandsxenos@google.com, Jan 27, 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.