Re: [PATCH] fmt-merge-msg: show those involved in a merged series

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

>> Three of the five callers introduced in that commit cast the result to
>> int and the remaining two don't care, so it actually does seem to
>> matter for most of them, strictly speaking.  When I see a nit, I can't
>> resist the urge to pick it, apparently.
>
> Unfortunately, replacing intptr_t with int or casting the above
> again as int will result in
>
> builtin/fmt-merge-msg.c: In function 'record_person':
> builtin/fmt-merge-msg.c:213: error: cast to pointer from integer of different size
>
> So...

-- >8 --
Subject: [PATCH] fmt-merge-msg.c: make util_as_int() return "int"

As its name says, the return value from util_as_int() should be
usable where an int is called for without casting.

Spotted-by: René Scharfe
Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 builtin/fmt-merge-msg.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 40b90b1..8ddefb3 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -182,7 +182,7 @@ static void add_branch_desc(struct strbuf *out, const char *name)
 	strbuf_release(&desc);
 }
 
-#define util_as_int(elem) ((intptr_t)((elem)->util))
+#define util_as_int(elem) ((int)((elem)->util))
 
 static void record_person(int which, struct string_list *people,
 			  struct commit *commit)
@@ -210,7 +210,7 @@ static void record_person(int which, struct string_list *people,
 		elem = string_list_insert(people, name_buf);
 		elem->util = (void *)0;
 	}
-	elem->util = (void*)(util_as_int(elem) + 1);
+	elem->util = (void*)((intptr_t)(util_as_int(elem) + 1));
 }
 
 static int cmp_string_list_util_as_int(const void *a_, const void *b_)
@@ -226,13 +226,13 @@ static void add_people_count(struct strbuf *out, struct string_list *people)
 	else if (people->nr == 2)
 		strbuf_addf(out, "%s (%d) and %s (%d)",
 			    people->items[0].string,
-			    (int)util_as_int(&people->items[0]),
+			    util_as_int(&people->items[0]),
 			    people->items[1].string,
-			    (int)util_as_int(&people->items[1]));
+			    util_as_int(&people->items[1]));
 	else if (people->nr)
 		strbuf_addf(out, "%s (%d) and others",
 			    people->items[0].string,
-			    (int)util_as_int(&people->items[0]));
+			    util_as_int(&people->items[0]));
 }
 
 static int committer_is_me(const char *name)
-- 
1.7.10.rc0.28.g709d0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]