{"thread":{"id":"51809","subject":"[PATCH v2 1/4] am: fail if no author line is given in --rebasing mode","startedAt":"2019-09-05T22:49:07Z","lastAt":"2019-09-06T12:39:38Z","messageCount":5,"participants":["Stephan Beyer"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"381929","messageId":"20190905224833.24913-1-s-beyer@gmx.net","threadId":"51809","inReplyTo":null,"subject":"[PATCH v2 1/4] am: fail if no author line is given in --rebasing mode","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2019-09-05T22:48:30Z","receivedAt":"2019-09-05T22:49:07Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"This prevents a potential segmentation fault.\n\nSigned-off-by: Stephan Beyer <s-beyer@gmx.net>\n---\n builtin/am.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 1aea657a7f..71da34913c 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1272,7 +1272,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)\n \tbuffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());\n\n \tident_line = find_commit_header(buffer, \"author\", &ident_len);\n-\n+\tif (!ident_line)\n+\t\tdie(_(\"no author line\"));\n \tif (split_ident_line(&id, ident_line, ident_len) < 0)\n \t\tdie(_(\"invalid ident line: %.*s\"), (int)ident_len, ident_line);\n\n--\n2.23.0.43.g31ebfd7ae6.dirty\n\n"},{"id":"381930","messageId":"20190905224833.24913-3-s-beyer@gmx.net","threadId":"51809","inReplyTo":"20190905224833.24913-1-s-beyer@gmx.net","subject":"[PATCH v2 3/4] pack-objects: fix maybe-uninitialized warning for index_pos","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2019-09-05T22:48:32Z","receivedAt":"2019-09-05T22:49:10Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"gcc 9.2.1 with -flto shows a maybe-uninitialized warning for index_pos\nin builtin/pack-objects.c's add_object_entry().  Tracking it down,\nthe variable should be initialized in pack_objects.c's packlist_find().\n\nThe return value of locate_object_entry_hash(), which becomes index_pos,\nis either (in case of found = 1) the position where the (already included)\nOID is, or (in case of found = 0), index_pos is the position where the\n(not yet included) OID will be after insertion (which takes place in\npacklist_alloc() if the hash table is still large enough).\n\nHowever, packlist_find() does not invoke locate_object_entry_hash() if\nthe index size is zero (which might be the case on the first run).\nThis is the only case where index_pos is undefined; and it is irrelevant\nsince the first run will increase the size of the hash table to 1024 and\nthen the undefined value index_pos is ignored.\n\nThis patch sets index_pos to zero on the first run to silence the warning.\n\nSigned-off-by: Stephan Beyer <s-beyer@gmx.net>\n---\n pack-objects.c | 5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/pack-objects.c b/pack-objects.c\nindex 52560293b6..726147a75d 100644\n--- a/pack-objects.c\n+++ b/pack-objects.c\n@@ -74,8 +74,11 @@ struct object_entry *packlist_find(struct packing_data *pdata,\n \tuint32_t i;\n \tint found;\n\n-\tif (!pdata->index_size)\n+\tif (!pdata->index_size) {\n+\t\tif (index_pos)\n+\t\t\t*index_pos = 0; /* silence uninitialized warning */\n \t\treturn NULL;\n+\t}\n\n \ti = locate_object_entry_hash(pdata, oid, &found);\n\n--\n2.23.0.43.g31ebfd7ae6.dirty\n\n"},{"id":"381931","messageId":"20190905224833.24913-2-s-beyer@gmx.net","threadId":"51809","inReplyTo":"20190905224833.24913-1-s-beyer@gmx.net","subject":"[PATCH v2 2/4] test-read-cache: fix maybe-uninitialized warning for namelen","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2019-09-05T22:48:31Z","receivedAt":"2019-09-05T22:49:11Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"This is done by removing namelen at all. It is only used once\nand simply strlen(name), hence we use strlen(name) directly.\n\nSuggested-by: Jeff King <peff@peff.net>\nSigned-off-by: Stephan Beyer <s-beyer@gmx.net>\n---\n t/helper/test-read-cache.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c\nindex 7e79b555de..244977a29b 100644\n--- a/t/helper/test-read-cache.c\n+++ b/t/helper/test-read-cache.c\n@@ -4,11 +4,10 @@\n\n int cmd__read_cache(int argc, const char **argv)\n {\n-\tint i, cnt = 1, namelen;\n+\tint i, cnt = 1;\n \tconst char *name = NULL;\n\n \tif (argc > 1 && skip_prefix(argv[1], \"--print-and-refresh=\", &name)) {\n-\t\tnamelen = strlen(name);\n \t\targc--;\n \t\targv++;\n \t}\n@@ -24,7 +23,7 @@ int cmd__read_cache(int argc, const char **argv)\n\n \t\t\trefresh_index(&the_index, REFRESH_QUIET,\n \t\t\t\t      NULL, NULL, NULL);\n-\t\t\tpos = index_name_pos(&the_index, name, namelen);\n+\t\t\tpos = index_name_pos(&the_index, name, strlen(name));\n \t\t\tif (pos < 0)\n \t\t\t\tdie(\"%s not in index\", name);\n \t\t\tprintf(\"%s is%s up to date\\n\", name,\n--\n2.23.0.43.g31ebfd7ae6.dirty\n\n"},{"id":"381932","messageId":"20190905224833.24913-4-s-beyer@gmx.net","threadId":"51809","inReplyTo":"20190905224833.24913-1-s-beyer@gmx.net","subject":"[PATCH v2 4/4] Silence false-positive maybe-uninitialized warnings found by gcc 9 -flto","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2019-09-05T22:48:33Z","receivedAt":"2019-09-05T22:49:12Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"gcc 9.2.1 with -flto flag suspects some uninitialized variables which become\ninitialized in every code path where they are used.  These false positives\nare \"fixed\" by this patch in the most naïve way.\n\nThis allows to compile git with gcc 9, link-time optimization, and using the\nDEVELOPER=1 switch (which sets -Werror).\n\nSigned-off-by: Stephan Beyer <s-beyer@gmx.net>\n---\n bulk-checkin.c | 2 ++\n fast-import.c  | 3 ++-\n 2 files changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 39ee7d6107..87fa28c227 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -200,6 +200,8 @@ static int deflate_to_pack(struct bulk_checkin_state *state,\n \tstruct hashfile_checkpoint checkpoint;\n \tstruct pack_idx_entry *idx = NULL;\n\n+\tcheckpoint.offset = 0;\n+\n \tseekback = lseek(fd, 0, SEEK_CUR);\n \tif (seekback == (off_t) -1)\n \t\treturn error(\"cannot find the current offset\");\ndiff --git a/fast-import.c b/fast-import.c\nindex b44d6a467e..58f73f9105 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -903,7 +903,8 @@ static int store_object(\n \tstruct object_entry *e;\n \tunsigned char hdr[96];\n \tstruct object_id oid;\n-\tunsigned long hdrlen, deltalen;\n+\tunsigned long hdrlen;\n+\tunsigned long deltalen = 0;\n \tgit_hash_ctx c;\n \tgit_zstream s;\n\n--\n2.23.0.43.g31ebfd7ae6.dirty\n\n"},{"id":"381954","messageId":"ef73e7ac-4a72-4fb2-088a-be424fa56af1@gmx.net","threadId":"51809","inReplyTo":"20190905224833.24913-1-s-beyer@gmx.net","subject":"Re: [PATCH v2 1/4] am: fail if no author line is given in --rebasing mode","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2019-09-06T12:39:17Z","receivedAt":"2019-09-06T12:39:38Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\njust to make it also clear in this thread: you can ignore this patch\nseries in favor of the better patch series by Peff [1] that has found\nits way to the mailing list at the same time.\n\n1.\nhttps://public-inbox.org/git/20190905224859.GA28660@sigill.intra.peff.net/\n\nStephan\n"}]}