{"thread":{"id":"10582","subject":"[PATCH] pack-objects: get rid of an ugly cast","startedAt":"2007-11-02T03:43:24Z","lastAt":"2007-11-02T03:43:24Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57921","messageId":"alpine.LFD.0.9999.0711012340330.21255@xanadu.home","threadId":"10582","inReplyTo":null,"subject":"[PATCH] pack-objects: get rid of an ugly cast","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-11-02T03:43:24Z","receivedAt":"2007-11-02T03:43:24Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"... when calling write_idx_file().\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 25ec65d..a9d7633 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -57,7 +57,7 @@ struct object_entry {\n  * nice \"minimum seek\" order.\n  */\n static struct object_entry *objects;\n-static struct object_entry **written_list;\n+static struct pack_idx_entry **written_list;\n static uint32_t nr_objects, nr_alloc, nr_result, nr_written;\n \n static int non_empty;\n@@ -577,7 +577,7 @@ static off_t write_one(struct sha1file *f,\n \t\te->idx.offset = 0;\n \t\treturn 0;\n \t}\n-\twritten_list[nr_written++] = e;\n+\twritten_list[nr_written++] = &e->idx;\n \n \t/* make sure off_t is sufficiently large not to wrap */\n \tif (offset > offset + size)\n@@ -599,7 +599,7 @@ static void write_pack_file(void)\n \n \tif (do_progress)\n \t\tprogress_state = start_progress(\"Writing objects\", nr_result);\n-\twritten_list = xmalloc(nr_objects * sizeof(struct object_entry *));\n+\twritten_list = xmalloc(nr_objects * sizeof(*written_list));\n \n \tdo {\n \t\tunsigned char sha1[20];\n@@ -651,9 +651,8 @@ static void write_pack_file(void)\n \t\t\tumask(mode);\n \t\t\tmode = 0444 & ~mode;\n \n-\t\t\tidx_tmp_name = write_idx_file(NULL,\n-\t\t\t\t\t(struct pack_idx_entry **) written_list,\n-\t\t\t\t\tnr_written, sha1);\n+\t\t\tidx_tmp_name = write_idx_file(NULL, written_list,\n+\t\t\t\t\t\t      nr_written, sha1);\n \t\t\tsnprintf(tmpname, sizeof(tmpname), \"%s-%s.pack\",\n \t\t\t\t base_name, sha1_to_hex(sha1));\n \t\t\tif (adjust_perm(pack_tmp_name, mode))\n@@ -677,7 +676,7 @@ static void write_pack_file(void)\n \n \t\t/* mark written objects as written to previous pack */\n \t\tfor (j = 0; j < nr_written; j++) {\n-\t\t\twritten_list[j]->idx.offset = (off_t)-1;\n+\t\t\twritten_list[j]->offset = (off_t)-1;\n \t\t}\n \t\tnr_remaining -= nr_written;\n \t} while (nr_remaining && i < nr_objects);\n"}]}