{"thread":{"id":"786","subject":"[PATCH] Unused pos[] in apply.c","startedAt":"2005-06-01T04:20:06Z","lastAt":"2005-06-01T04:20:06Z","messageCount":1,"participants":["Pavel Roskin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4342","messageId":"1117599606.13776.26.camel@dv","threadId":"786","inReplyTo":null,"subject":"[PATCH] Unused pos[] in apply.c","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-06-01T04:20:06Z","receivedAt":"2005-06-01T04:20:06Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hello!\n\ngcc 4.0 complains about current cogito (and current git from Linus):\n\napply.c: In function 'apply_patch':\napply.c:622: warning: 'pos[0]' is used uninitialized in this function\napply.c:624: warning: 'pos[1]' is used uninitialized in this function\n\nIndeed, pos[] is never initialized and never used again.\n\nMy understanding of the code is that it's trying to figure out whether\nthe patch is adding or removing a file.  If the first line for the chunk\nor the line count for the old file is not 0, the old file existed, so\nthe patch is not adding the file.  Conversely, non-zero position or line\ncount for the new file means we are not deleting it.\n\nFollowing patch makes the code do what it was meant to do.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n\ndiff --git a/apply.c b/apply.c\n--- a/apply.c\n+++ b/apply.c\n@@ -611,7 +611,7 @@ static int parse_fragment(char *line, un\n {\n \tint added, deleted;\n \tint len = linelen(line, size), offset;\n-\tunsigned long pos[4], oldlines, newlines;\n+\tunsigned long oldlines, newlines;\n \n \toffset = parse_fragment_header(line, len, fragment);\n \tif (offset < 0)\n@@ -619,9 +619,9 @@ static int parse_fragment(char *line, un\n \toldlines = fragment->oldlines;\n \tnewlines = fragment->newlines;\n \n-\tif (patch->is_new < 0 && (pos[0] || oldlines))\n+\tif (patch->is_new < 0 && (fragment->oldpos || oldlines))\n \t\tpatch->is_new = 0;\n-\tif (patch->is_delete < 0 && (pos[1] || newlines))\n+\tif (patch->is_delete < 0 && (fragment->newpos || newlines))\n \t\tpatch->is_delete = 0;\n \n \t/* Parse the thing.. */\n\n\n-- \nRegards,\nPavel Roskin\n\n"}]}