summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2011-05-24 12:11:32 +0200
committerJim Meyering <meyering@redhat.com>2011-05-25 16:47:00 +0200
commitb4c6b7086bd496bbc5b15de657247919a143e3b2 (patch)
tree83b02ffb0c9a25737e27d54561ce45d40e290347
parent5a634c3834b189ccafe0ba62caae3534c86994cc (diff)
downloadpatch-b4c6b7086bd496bbc5b15de657247919a143e3b2.tar.gz
avoid a used-uninitialized error in fetchname
* src/util.c (fetchname): Avoid a used-uninitialized error. Before, when "*t == '\n'", stamp.tv_nsec would have been used undefined. The fix is to set that member rather than stamp.tv_sec, which is already set to the desired value. This was reported by coverity.
-rw-r--r--src/util.c5
1 files changed, 2 insertions, 3 deletions
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)
{