{"thread":{"id":"81","subject":"[PATCH] Remove unused arguments from index_fd()","startedAt":"2005-04-17T10:31:00Z","lastAt":"2005-04-17T10:31:00Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"462","messageId":"7vu0m5wv8b.fsf@assigned-by-dhcp.cox.net","threadId":"81","inReplyTo":null,"subject":"[PATCH] Remove unused arguments from index_fd()","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-17T10:31:00Z","receivedAt":"2005-04-17T10:31:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The function index_fd() in update-cache.c takes 5 arguments, but\ntwo is not necessary and one that is a pointer to a structure\nreally needs to be a pointer to one member of that structure.\nThis patch cleans it up.\n\nAlso it removes printf() apparently left after initial\ndebugging.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n update-cache.c |   15 ++++++---------\n 1 files changed, 6 insertions(+), 9 deletions(-)\n\nupdate-cache.c: 5afecd1a4fd90d2505753ce2d5044d780fe69a7f\n--- update-cache.c\n+++ update-cache.c\t2005-04-17 03:22:39.000000000 -0700\n@@ -14,13 +14,13 @@\n  */\n static int allow_add = 0, allow_remove = 0;\n \n-static int index_fd(const char *path, int namelen, struct cache_entry *ce, int fd, struct stat *st)\n+static int index_fd(unsigned char *sha1, int fd, struct stat *st)\n {\n \tz_stream stream;\n \tunsigned long size = st->st_size;\n-\tint max_out_bytes = namelen + size + 200;\n+\tint max_out_bytes = size + 200;\n \tvoid *out = malloc(max_out_bytes);\n-\tvoid *metadata = malloc(namelen + 200);\n+\tvoid *metadata = malloc(200);\n \tvoid *in;\n \tSHA_CTX c;\n \n@@ -56,9 +56,9 @@\n \t\n \tSHA1_Init(&c);\n \tSHA1_Update(&c, out, stream.total_out);\n-\tSHA1_Final(ce->sha1, &c);\n+\tSHA1_Final(sha1, &c);\n \n-\treturn write_sha1_buffer(ce->sha1, out, stream.total_out);\n+\treturn write_sha1_buffer(sha1, out, stream.total_out);\n }\n \n /*\n@@ -109,7 +109,7 @@\n \tce->ce_mode = create_ce_mode(st.st_mode);\n \tce->ce_flags = htons(namelen);\n \n-\tif (index_fd(path, namelen, ce, fd, &st) < 0)\n+\tif (index_fd(ce->sha1, fd, &st) < 0)\n \t\treturn -1;\n \n \treturn add_cache_entry(ce, allow_add);\n@@ -244,13 +244,10 @@\n \n \tif (sscanf(arg1, \"%o\", &mode) != 1)\n \t\treturn -1;\n-\tprintf(\"got mode %o\\n\", mode);\n \tif (get_sha1_hex(arg2, sha1))\n \t\treturn -1;\n-\tprintf(\"got sha1 %s\\n\", sha1_to_hex(sha1));\n \tif (!verify_path(arg3))\n \t\treturn -1;\n-\tprintf(\"got path %s\\n\", arg3);\n \n \tlen = strlen(arg3);\n \tsize = cache_entry_size(len);\n\n"}]}