Re: [PATCH v3 5/8] evolve: Add the change-table structure
- Date: Tue, 29 Jan 2019 00:08:27 +0100 (STD)
- From: Johannes Schindelin <Johannes.Schindelin@xxxxxx>
- Subject: Re: [PATCH v3 5/8] evolve: Add the change-table structure
On Mon, 28 Jan 2019, Johannes Schindelin wrote:
> On Sun, 27 Jan 2019, sxenos@xxxxxxxxxx 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:
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
@@ -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,
- index = (long)item->util;
+ index = (long)(intptr_t)item->util;