[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-patch] [PATCH] avoid a used-uninitialized error
From: |
Andreas Gruenbacher |
Subject: |
Re: [bug-patch] [PATCH] avoid a used-uninitialized error |
Date: |
Wed, 25 May 2011 14:44:04 +0200 |
User-agent: |
KMail/1.12.4 (Linux/2.6.36-rc7+; KDE/4.3.5; i686; ; ) |
On Tuesday 24 May 2011 13:15:37 Jim Meyering wrote:
> I did not try to see if fixing this bug changes how patch works.
It doesn't as far as I can see. It doesn't fix a real bug either, but avoids
a static checker error (so it's a good thing). I'd rather initialize stamp
completely at the top of the function though, like this:
diff --git a/src/util.c b/src/util.c
index 6950842..75486f4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1428,6 +1428,7 @@ fetchname (char const *at, int strip_leading, bool
maybe_quoted, char **pname,
struct timespec stamp;
stamp.tv_sec = -1;
+ stamp.tv_nsec = 0;
while (ISSPACE ((unsigned char) *at))
at++;
@@ -1497,9 +1498,7 @@ fetchname (char const *at, int strip_leading, bool
maybe_quoted, char **pname,
timestr[u - t] = 0;
}
- if (*t == '\n')
- stamp.tv_sec = -1;
- else
+ if (*t != '\n')
{
if (! pstamp)
{
--
Okay?
Andreas