[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] getndelim2.c: avoid a warning from gcc
From: |
Jim Meyering |
Subject: |
[PATCH] getndelim2.c: avoid a warning from gcc |
Date: |
Wed, 30 Apr 2008 17:42:16 +0200 |
Hi Eric,
This warning causes coreutils' "make distcheck" to fail,
so I propose to fix it like this.
cc1: warnings being treated as errors
getndelim2.c: In function 'getndelim2':
getndelim2.c:103: error: 'c' may be used uninitialized in this function
make[6]: *** [getndelim2.o] Error 1
Ok to commit?
>From 3b143fa6ef70d152163ca72125a942523e896b55 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 30 Apr 2008 17:39:54 +0200
Subject: [PATCH] avoid a warning from gcc
* lib/getndelim2.c (IF_LINT): Define.
(getndelim2): Use it to void a "may be used uninitialized" warning.
Signed-off-by: Jim Meyering <address@hidden>
---
ChangeLog | 4 ++++
lib/getndelim2.c | 9 ++++++++-
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 54d88c5..a08c1b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2008-04-30 Jim Meyering <address@hidden>
+ avoid a warning from gcc
+ * lib/getndelim2.c (IF_LINT): Define.
+ (getndelim2): Use it to void a "may be used uninitialized" warning.
+
vc-list-files: work properly with build-aux/cvsu, too
* build-aux/vc-list-files: Hoist the "./"-removing code to apply
to all cvs-based clauses.
diff --git a/lib/getndelim2.c b/lib/getndelim2.c
index be34e40..1a0ec11 100644
--- a/lib/getndelim2.c
+++ b/lib/getndelim2.c
@@ -51,6 +51,13 @@
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif
+/* Use this to suppress gcc's `...may be used before initialized' warnings. */
+#ifdef lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
/* The maximum value that getndelim2 can return without suffering from
overflow problems, either internally (because of pointer
subtraction overflow) or due to the API (because of ssize_t). */
@@ -100,7 +107,7 @@ getndelim2 (char **lineptr, size_t *linesize, size_t
offset, size_t nmax,
{
/* Here always ptr + size == read_pos + nbytes_avail. */
- int c;
+ int c IF_LINT (= 0);
const char *buffer;
size_t buffer_len;
--
1.5.5.1.100.g56ad1
- [PATCH] getndelim2.c: avoid a warning from gcc,
Jim Meyering <=