* [PATCH] Unused pos[] in apply.c
@ 2005-06-01 4:20 Pavel Roskin
0 siblings, 0 replies; only message in thread
From: Pavel Roskin @ 2005-06-01 4:20 UTC (permalink / raw)
To: git
Hello!
gcc 4.0 complains about current cogito (and current git from Linus):
apply.c: In function 'apply_patch':
apply.c:622: warning: 'pos[0]' is used uninitialized in this function
apply.c:624: warning: 'pos[1]' is used uninitialized in this function
Indeed, pos[] is never initialized and never used again.
My understanding of the code is that it's trying to figure out whether
the patch is adding or removing a file. If the first line for the chunk
or the line count for the old file is not 0, the old file existed, so
the patch is not adding the file. Conversely, non-zero position or line
count for the new file means we are not deleting it.
Following patch makes the code do what it was meant to do.
Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/apply.c b/apply.c
--- a/apply.c
+++ b/apply.c
@@ -611,7 +611,7 @@ static int parse_fragment(char *line, un
{
int added, deleted;
int len = linelen(line, size), offset;
- unsigned long pos[4], oldlines, newlines;
+ unsigned long oldlines, newlines;
offset = parse_fragment_header(line, len, fragment);
if (offset < 0)
@@ -619,9 +619,9 @@ static int parse_fragment(char *line, un
oldlines = fragment->oldlines;
newlines = fragment->newlines;
- if (patch->is_new < 0 && (pos[0] || oldlines))
+ if (patch->is_new < 0 && (fragment->oldpos || oldlines))
patch->is_new = 0;
- if (patch->is_delete < 0 && (pos[1] || newlines))
+ if (patch->is_delete < 0 && (fragment->newpos || newlines))
patch->is_delete = 0;
/* Parse the thing.. */
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-06-01 4:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-01 4:20 [PATCH] Unused pos[] in apply.c Pavel Roskin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).