{"thread":{"id":"3449","subject":"[PATCH] fix warning from pack-objects.c","startedAt":"2006-02-23T22:42:39Z","lastAt":"2006-02-23T22:51:00Z","messageCount":2,"participants":["Luck, Tony","Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"16641","messageId":"200602232242.k1NMgdAJ018406@agluck-lia64.sc.intel.com","threadId":"3449","inReplyTo":null,"subject":"[PATCH] fix warning from pack-objects.c","fromName":"Luck, Tony","fromEmail":"tony.luck@intel.com","sentAt":"2006-02-23T22:42:39Z","receivedAt":"2006-02-23T22:42:39Z","isPatch":true,"sender":{"key":"tony.luck@intel.com","avatar":"https://avatars.githubusercontent.com/u/5446021?v=4"},"body":"When compiling on ia64 I get this warning (from gcc 3.4.3):\n\ngcc -o pack-objects.o -c -g -O2 -Wall -DSHA1_HEADER='<openssl/sha.h>'  pack-objects.c\npack-objects.c: In function `pack_revindex_ix':\npack-objects.c:94: warning: cast from pointer to integer of different size\n\nA double cast (first to long, then to int) shuts gcc up, but is there\na better way?\n\nSigned-off-by: Tony Luck <tony.luck@intel.com>\n\n---\n\ndiff --git a/pack-objects.c b/pack-objects.c\nindex 8f352aa..c985fab 100644\n--- a/pack-objects.c\n+++ b/pack-objects.c\n@@ -91,7 +91,7 @@ static int reused_delta = 0;\n \n static int pack_revindex_ix(struct packed_git *p)\n {\n-\tunsigned int ui = (unsigned int) p;\n+\tunsigned int ui = (unsigned int)(long)p;\n \tint i;\n \n \tui = ui ^ (ui >> 16); /* defeat structure alignment */\n"},{"id":"16642","messageId":"43FE3C54.2080103@op5.se","threadId":"3449","inReplyTo":"200602232242.k1NMgdAJ018406@agluck-lia64.sc.intel.com","subject":"Re: [PATCH] fix warning from pack-objects.c","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-02-23T22:51:00Z","receivedAt":"2006-02-23T22:51:00Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Luck, Tony wrote:\n> When compiling on ia64 I get this warning (from gcc 3.4.3):\n> \n> gcc -o pack-objects.o -c -g -O2 -Wall -DSHA1_HEADER='<openssl/sha.h>'  pack-objects.c\n> pack-objects.c: In function `pack_revindex_ix':\n> pack-objects.c:94: warning: cast from pointer to integer of different size\n> \n> A double cast (first to long, then to int) shuts gcc up, but is there\n> a better way?\n> \n\nMake ui and i unsigned long and cast p to unsigned long (or perhaps \nptrdiff_t is preferred?). On 32-bit archs it's no difference, but 64-bit \narchs can work with their native size. It's slightly faster (although I \nexpect the compiler takes care of that anyways).\n\nI noticed this earlier on my shiny AMD FX2 64-bit. The tests run just \nfine with my solution. I expect they will with yours as well.\n\n> Signed-off-by: Tony Luck <tony.luck@intel.com>\n> \n> ---\n> \n> diff --git a/pack-objects.c b/pack-objects.c\n> index 8f352aa..c985fab 100644\n> --- a/pack-objects.c\n> +++ b/pack-objects.c\n> @@ -91,7 +91,7 @@ static int reused_delta = 0;\n>  \n>  static int pack_revindex_ix(struct packed_git *p)\n>  {\n> -\tunsigned int ui = (unsigned int) p;\n> +\tunsigned int ui = (unsigned int)(long)p;\n>  \tint i;\n>  \n>  \tui = ui ^ (ui >> 16); /* defeat structure alignment */\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"}]}