[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
two small patches to accommodate -Wstrict-overflow
From: |
Jim Meyering |
Subject: |
two small patches to accommodate -Wstrict-overflow |
Date: |
Sun, 29 May 2011 19:34:34 +0200 |
I won't do much for -Wstrict-overflow, but so far, not much
has been required to get close to warning-free.
>From 244906802a300a1744de8881857a3a2897b3db8b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 28 May 2011 16:00:20 +0200
Subject: [PATCH 1/2] trim: avoid a warning from -O2 -Wstrict-overflow
* lib/trim.c (trim2): Declare local to be "unsigned int", not "int".
---
ChangeLog | 5 +++++
lib/trim.c | 3 +--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 69c052c..5de6fa7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-28 Jim Meyering <address@hidden>
+
+ trim: avoid a warning from -O2 -Wstrict-overflow
+ * lib/trim.c (trim2): Declare local to be "unsigned int", not "int".
+
2011-05-29 Bruno Haible <address@hidden>
gnulib-tool: Fix bug in yesterday's commit.
diff --git a/lib/trim.c b/lib/trim.c
index 1f4d0c1..6515cfa 100644
--- a/lib/trim.c
+++ b/lib/trim.c
@@ -65,7 +65,7 @@ trim2 (const char *s, int how)
/* Trim trailing whitespaces. */
if (how != TRIM_LEADING)
{
- int state = 0;
+ unsigned int state = 0;
char *r IF_LINT (= NULL); /* used only while state = 2 */
mbi_init (i, d, strlen (d));
@@ -130,4 +130,3 @@ trim2 (const char *s, int how)
return d;
}
-
--
1.7.5.2.660.g9f46c
>From a8ff65c566a6391a3c1e832452b6b594eb51f180 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 28 May 2011 20:58:14 +0200
Subject: [PATCH 2/2] parse-datetime.y: accommodate -Wstrict-overflow
* lib/parse-datetime.y (yylex): Rearrange pointer arithmetic to
placate -Wstrict-overflow.
---
ChangeLog | 4 ++++
lib/parse-datetime.y | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5de6fa7..f9ee06b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2011-05-28 Jim Meyering <address@hidden>
+ parse-datetime.y: accommodate -Wstrict-overflow
+ * lib/parse-datetime.y (yylex): Rearrange pointer arithmetic to
+ placate -Wstrict-overflow.
+
trim: avoid a warning from -O2 -Wstrict-overflow
* lib/trim.c (trim2): Declare local to be "unsigned int", not "int".
diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y
index d77955f..23a9a41 100644
--- a/lib/parse-datetime.y
+++ b/lib/parse-datetime.y
@@ -1119,7 +1119,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc)
do
{
- if (p < buff + sizeof buff - 1)
+ if (p - buff < sizeof buff - 1)
*p++ = c;
c = *++pc->input;
}
--
1.7.5.2.660.g9f46c
- two small patches to accommodate -Wstrict-overflow,
Jim Meyering <=