{"thread":{"id":"25902","subject":"[PATCH] commit: Remove backward goto in read_craft_line()","startedAt":"2010-12-01T19:59:06Z","lastAt":"2010-12-01T19:59:06Z","messageCount":1,"participants":["Ralf Thielow"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"157002","messageId":"1291233546-4962-1-git-send-email-ralf.thielow@googlemail.com","threadId":"25902","inReplyTo":null,"subject":"[PATCH] commit: Remove backward goto in read_craft_line()","fromName":"Ralf Thielow","fromEmail":"ralf.thielow@googlemail.com","sentAt":"2010-12-01T19:59:06Z","receivedAt":"2010-12-01T19:59:06Z","isPatch":true,"sender":{"key":"ralf.thielow@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1275832?v=4"},"body":" Bad graft data is noticed in several places in read_graft_line and\n in each case we go back to the first site of detection.  Move the\n error handling to the end of the function for better readability.\n\nSigned-off-by: Ralf Thielow <ralf.thielow@googlemail.com>\n---\n commit.c |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 0094ec1..642ee34 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -137,12 +137,8 @@ struct commit_graft *read_graft_line(char *buf, int len)\n \t\tbuf[--len] = '\\0';\n \tif (buf[0] == '#' || buf[0] == '\\0')\n \t\treturn NULL;\n-\tif ((len + 1) % 41) {\n-\tbad_graft_data:\n-\t\terror(\"bad graft data: %s\", buf);\n-\t\tfree(graft);\n-\t\treturn NULL;\n-\t}\n+\tif ((len + 1) % 41)\n+\t\tgoto bad_graft_data;\n \ti = (len + 1) / 41 - 1;\n \tgraft = xmalloc(sizeof(*graft) + 20 * i);\n \tgraft->nr_parent = i;\n@@ -155,6 +151,10 @@ struct commit_graft *read_graft_line(char *buf, int len)\n \t\t\tgoto bad_graft_data;\n \t}\n \treturn graft;\n+ bad_graft_data:\n+\terror(\"bad graft data: %s\", buf);\n+\tfree(graft);\n+\treturn NULL;\n }\n \n static int read_graft_file(const char *graft_file)\n-- \n1.7.1\n"}]}