Some signed warnings less
Andreas Jaeger
aj@suse.de
Tue Jan 2 07:02:00 GMT 2001
We're getting lots of these warnings for all strto* functions:
../sysdeps/generic/strtol.c: In function `__strtoll_internal':
../sysdeps/generic/strtol.c:357: warning: comparison between signed and unsigned
../sysdeps/generic/strtol.c:360: warning: comparison between signed and unsigned
../sysdeps/generic/strtol.c:369: warning: comparison between signed and unsigned
../sysdeps/generic/strtol.c:372: warning: comparison between signed and unsigned
../sysdeps/generic/strtol.c:409: warning: comparison between signed and unsigned
../sysdeps/generic/strtol.c:412: warning: comparison between signed and unsigned
../sysdeps/generic/strtol.c:457: warning: comparison between signed and unsigned
../sysdeps/generic/strtol.c:460: warning: comparison between signed and unsigned
and for printf_fphex:
../sysdeps/generic/printf_fphex.c: In function `__printf_fphex':
../sysdeps/generic/printf_fphex.c:258: warning: signed and unsigned type in conditional expression
../sysdeps/generic/printf_fphex.c:258: warning: comparison between signed and unsigned
../sysdeps/generic/printf_fphex.c:260: warning: signed and unsigned type in conditional expression
../sysdeps/generic/printf_fphex.c:260: warning: comparison between signed and unsigned
[...]
and for vfscanf.c
vfscanf.c: In function `_IO_vfscanf':
vfscanf.c:422: warning: signed and unsigned type in conditional expression
vfscanf.c:450: warning: signed and unsigned type in conditional expression
and for wgenops.c:
wgenops.c: In function `_IO_wdoallocbuf':
wgenops.c:406: warning: comparison between signed and unsigned
wgenops.c: In function `_IO_switch_to_wget_mode':
wgenops.c:456: warning: comparison between signed and unsigned
wgenops.c: In function `_IO_sputbackwc':
wgenops.c:625: warning: comparison between signed and unsigned
wgenops.c: In function `_IO_sungetwc':
wgenops.c:645: warning: comparison between signed and unsigned
The appended patch removes these warnings and fixes also some macro
usage in wegenops. Ok to commit?
A similar patch as to printf_fphex can be applied to printf_size.c and
printf_fp.c.
Andreas
2001-01-02 Andreas Jaeger <aj@suse.de>
* sysdeps/generic/strtol.c (strtol): Make cnt size_t for correct
signedness.
* sysdeps/generic/printf_fphex.c (putc): Cast _IO_putwc_unlocked
to (int) to avoid warnings.
* stdio-common/vfscanf.c (__vfscanf): Make done signed.
* libio/wgenops.c (_IO_wdoallocbuf): Use correct wide access macro.
(_IO_switch_to_wget_mode): Likewise.
(_IO_sputbackwc): Likewise.
(_IO_sungetwc): Use wint_t for result.
============================================================
Index: sysdeps/generic/strtol.c
--- sysdeps/generic/strtol.c 2000/07/28 17:44:07 1.4
+++ sysdeps/generic/strtol.c 2001/01/02 14:12:56
@@ -1,5 +1,5 @@
/* Convert string representation of a number into an integer value.
- Copyright (C) 1991,92,94,95,96,97,98,99,2000 Free Software Foundation, Inc.
+ Copyright (C) 1991,92,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -244,7 +244,7 @@
const STRING_TYPE *save, *end;
int overflow;
#ifndef USE_WIDE_CHAR
- int cnt;
+ size_t cnt;
#endif
#ifdef USE_NUMBER_GROUPING
============================================================
Index: sysdeps/generic/printf_fphex.c
--- sysdeps/generic/printf_fphex.c 2000/11/16 18:05:01 1.9
+++ sysdeps/generic/printf_fphex.c 2001/01/02 14:12:57
@@ -1,5 +1,5 @@
/* Print floating point number in hexadecimal notation according to ISO C99.
- Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -43,7 +43,7 @@
names equal. */
# undef putc
# define putc(c, f) (wide \
- ? _IO_putwc_unlocked (c, f) : _IO_putc_unlocked (c, f))
+ ? (int)_IO_putwc_unlocked (c, f) : _IO_putc_unlocked (c, f))
# define size_t _IO_size_t
# define FILE _IO_FILE
#else /* ! USE_IN_LIBIO */
============================================================
Index: stdio-common/vfscanf.c
--- stdio-common/vfscanf.c 2000/12/01 03:24:30 1.86
+++ stdio-common/vfscanf.c 2001/01/02 14:13:00
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -266,7 +266,7 @@
va_list arg;
register const CHAR_T *f = format;
register UCHAR_T fc; /* Current character of the format. */
- register size_t done = 0; /* Assignments done. */
+ register int done = 0; /* Assignments done. */
register size_t read_in = 0; /* Chars read in. */
register WINT_T c = 0; /* Last char read. */
register int width; /* Maximum field width. */
============================================================
Index: libio/wgenops.c
--- libio/wgenops.c 2000/08/13 18:16:57 1.5
+++ libio/wgenops.c 2001/01/02 14:13:00
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1993,1995,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU IO Library.
Written by Ulrich Drepper <drepper@cygnus.com>.
Based on the single byte version by Per Bothner <bothner@cygnus.com>.
@@ -403,7 +403,7 @@
if (fp->_wide_data->_IO_buf_base)
return;
if (!(fp->_flags & _IO_UNBUFFERED))
- if (_IO_DOALLOCATE (fp) != WEOF)
+ if ((wint_t)_IO_WDOALLOCATE (fp) != WEOF)
return;
_IO_wsetb (fp, fp->_wide_data->_shortbuf, fp->_wide_data->_shortbuf + 1, 0);
}
@@ -453,7 +453,7 @@
_IO_FILE *fp;
{
if (fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_write_base)
- if (_IO_OVERFLOW (fp, WEOF) == WEOF)
+ if ((wint_t)_IO_WOVERFLOW (fp, WEOF) == WEOF)
return EOF;
if (_IO_in_backup (fp))
fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_backup_base;
@@ -622,7 +622,7 @@
else
result = _IO_PBACKFAIL (fp, c);
- if (result != EOF)
+ if (result != WEOF)
fp->_flags &= ~_IO_EOF_SEEN;
return result;
@@ -632,7 +632,7 @@
_IO_sungetwc (fp)
_IO_FILE *fp;
{
- int result;
+ wint_t result;
if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base)
{
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
More information about the Libc-hacker
mailing list