{"thread":{"id":"33177","subject":"[PATCH] setup.c: Remove duplicate code from prefix_pathspec()","startedAt":"2013-03-14T00:24:55Z","lastAt":"2013-03-14T00:24:55Z","messageCount":1,"participants":["Lukas Fleischer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"211267","messageId":"1363220695-27911-1-git-send-email-git@cryptocrack.de","threadId":"33177","inReplyTo":null,"subject":"[PATCH] setup.c: Remove duplicate code from prefix_pathspec()","fromName":"Lukas Fleischer","fromEmail":"git@cryptocrack.de","sentAt":"2013-03-14T00:24:55Z","receivedAt":"2013-03-14T00:24:55Z","isPatch":true,"sender":{"key":"git@cryptocrack.de","avatar":null},"body":"Only check for ',' explicitly and handle both ')' and '\\0' in the else\nbranch. strcspn() can only return ',', ')' and '\\0' at this point so the\nnew code is completely equivalent to what we had before.\n\nThis also fixes following GCC warning:\n\n    setup.c: In function ‘get_pathspec’:\n    setup.c:207:8: warning: ‘nextat’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n    setup.c:205:15: note: ‘nextat’ was declared here\n\nSigned-off-by: Lukas Fleischer <git@cryptocrack.de>\n---\nThis removes the only warning that currently occurs when building the\nnext branch.\n\nJunio: Feel free to squash this into Andrew's patch (805da4dee15b,\n\"setup.c: stop prefix_pathspec() from looping past the end of string\").\n\n setup.c | 9 ++++-----\n 1 file changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex d2335a8..94c1e61 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -207,12 +207,11 @@ static const char *prefix_pathspec(const char *prefix, int prefixlen, const char\n \t\t     *copyfrom && *copyfrom != ')';\n \t\t     copyfrom = nextat) {\n \t\t\tsize_t len = strcspn(copyfrom, \",)\");\n-\t\t\tif (copyfrom[len] == '\\0')\n-\t\t\t\tnextat = copyfrom + len;\n-\t\t\telse if (copyfrom[len] == ')')\n-\t\t\t\tnextat = copyfrom + len;\n-\t\t\telse if (copyfrom[len] == ',')\n+\t\t\tif (copyfrom[len] == ',')\n \t\t\t\tnextat = copyfrom + len + 1;\n+\t\t\telse\n+\t\t\t\t/* handle ')' and '\\0' */\n+\t\t\t\tnextat = copyfrom + len;\n \t\t\tif (!len)\n \t\t\t\tcontinue;\n \t\t\tfor (i = 0; i < ARRAY_SIZE(pathspec_magic); i++)\n-- \n1.8.2.rc2.352.g908df73\n"}]}