[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gperf] avoid compilation warnings
From: |
Eric Blake |
Subject: |
[bug-gperf] avoid compilation warnings |
Date: |
Mon, 21 Dec 2009 21:15:42 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Trying to run 'make check' on the latest git sources for gperf on cygwin
triggered several compilation warnings. The patch to getopt is the
minimum needed to avoid the warnings, but you may want to instead update
to a more modern version of getopt.c for bug fixes that have occurred
upstream.
./getopt.c: In function `_getopt_internal':
./getopt.c:567: warning: implicit declaration of function `strcmp'
./getopt.c:646: warning: implicit declaration of function `strlen'
./getopt.c:688: warning: suggest explicit braces to avoid ambiguous `else'
./test2.c: In function `main':
./test2.c:41: warning: implicit declaration of function `setmode'
./smtp.gperf: In function `main':
./smtp.gperf:186: warning: array subscript has type `char'
./smtp.gperf:187: warning: array subscript has type `char'
./smtp.gperf:188: warning: array subscript has type `char'
./smtp.gperf:189: warning: array subscript has type `char'
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkswR+0ACgkQ84KuGfSFAYCYBgCgjIE7FWVKY/9UN+1bReGuSFz4
zggAnjUus91YbQSt6al3PvmKhAFjHpOM
=rb5K
-----END PGP SIGNATURE-----
>From 40a4a7c617081d3ca34905c7b3ebe7795cf4773d Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 14 Dec 2009 14:22:53 -0700
Subject: [PATCH] Avoid compiler warnings.
* lib/getopt.c (_getopt_internal): Include ncessary header, and
avoid warning about ambiguous else.
* tests/smtp.gperf: Avoid undefined behavior.
* tests/test2.c (O_BINARY): Include necessary header.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 8 ++++++++
lib/getopt.c | 5 ++++-
tests/smtp.gperf | 8 ++++----
tests/test2.c | 1 +
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 78a4b8a..6643258 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-12-21 Eric Blake <address@hidden>
+
+ Avoid compiler warnings.
+ * lib/getopt.c (_getopt_internal): Include ncessary header, and
+ avoid warning about ambiguous else.
+ * tests/smtp.gperf: Avoid undefined behavior.
+ * tests/test2.c (O_BINARY): Include necessary header.
+
2009-12-20 Bruno Haible <address@hidden>
* doc/gperf.info: Regenerated.
diff --git a/lib/getopt.c b/lib/getopt.c
index 32d6efc..dce9b55 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -3,7 +3,7 @@
"Keep this file name-space clean" means, talk to address@hidden
before changing it!
- Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98
+ Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 09
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -38,6 +38,7 @@
#endif
#include <stdio.h>
+#include <string.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
@@ -686,6 +687,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind,
long_only)
else
{
if (opterr)
+ {
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
@@ -696,6 +698,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind,
long_only)
fprintf (stderr,
_("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
+ }
nextchar += strlen (nextchar);
diff --git a/tests/smtp.gperf b/tests/smtp.gperf
index 33137b9..5d26f5e 100644
--- a/tests/smtp.gperf
+++ b/tests/smtp.gperf
@@ -183,10 +183,10 @@ main (argc, argv)
if (len)
{
for (k = 0; k < len; k++)
- if (isupper (s[k]))
- s[k] = tolower (s[k]);
- else if (islower (s[k]))
- s[k] = toupper (s[k]);
+ if (isupper ((unsigned char) s[k]))
+ s[k] = tolower ((unsigned char) s[k]);
+ else if (islower ((unsigned char) s[k]))
+ s[k] = toupper ((unsigned char) s[k]);
hs = header_entry (s, len);
if (!(hs && my_case_strcmp (hs->field_name, s) == 0))
{
diff --git a/tests/test2.c b/tests/test2.c
index 2a2c36d..e408d45 100644
--- a/tests/test2.c
+++ b/tests/test2.c
@@ -15,6 +15,7 @@
# undef O_BINARY
#endif
#if O_BINARY
+# include <io.h>
# define SET_BINARY(f) setmode (f, O_BINARY)
#else
# define SET_BINARY(f) (void)0
--
1.6.5.rc1
- [bug-gperf] avoid compilation warnings,
Eric Blake <=