From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>
Subject: [PATCH] Unused pos[] in apply.c
Date: Wed, 01 Jun 2005 00:20:06 -0400 [thread overview]
Message-ID: <1117599606.13776.26.camel@dv> (raw)
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
reply other threads:[~2005-06-01 4:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1117599606.13776.26.camel@dv \
--to=proski@gnu.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).