[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
more gcc warnings
From: |
Eric Blake |
Subject: |
more gcc warnings |
Date: |
Fri, 08 Jul 2005 20:21:26 +0000 |
A couple of porting problems caught by compiling with gcc -Wall on cygwin:
ls.c and stty.c use ioctl without including <sys/ioctl.h>, triggering a
warning about implicit declarations. Even worse, since ioctl is a varargs
function, this is undefined C (luckily, it compiles and links okay on cygwin).
I think the macros m4/jm-winsz[12].m4 are at fault here. Cygwin has
TIOCGWINSZ only in <termios.h>; while ioctl is only in <sys/ioctl.h> (or
<term.h>, which includes <sys/ioctl.h>), so both headers are needed
before "ioctl (STDOUT_FILENO, TIOCGWINSZ, &ws)" will compile without
warning. This needs some autoconf magic (perhaps something that
defines IOCTL_IN_SYS_IOCTL), but I'm not sure of the best approach
for editing the existing m4 files.
id.c calls error (which ultimately gets to the printf family) with a format
%u for uid_t and gid_t. I really don't know of any portable way to print
an id_t, except that POSIX guarantees that they must be integer types
(with no further limitations, such as unsigned or not exceeding long). All
I could think of that won't truncate bits on some theoretical platform is
to cast to uintmax_t, which must work since they are integral.
2005-07-08 Eric Blake <address@hidden>
* src/id.c (print_user, print_group): Cast uid_t/gid_t to
uintmax_t before passing to printf family as %ju.
Index: src/id.c
===================================================================
RCS file: /cvsroot/coreutils/coreutils/src/id.c,v
retrieving revision 1.85
diff -u -r1.85 id.c
--- src/id.c 30 May 2005 07:33:00 -0000 1.85
+++ src/id.c 8 Jul 2005 20:09:17 -0000
@@ -202,7 +202,8 @@
pwd = getpwuid (uid);
if (pwd == NULL)
{
- error (0, 0, _("cannot find name for user ID %u"), uid);
+ error (0, 0, _("cannot find name for user ID %ju"),
+ (uintmax_t) uid);
ok = false;
}
}
@@ -225,7 +226,8 @@
grp = getgrgid (gid);
if (grp == NULL)
{
- error (0, 0, _("cannot find name for group ID %u"), gid);
+ error (0, 0, _("cannot find name for group ID %ju"),
+ (uintmax_t) gid);
ok = false;
}
}
--
Eric Blake
- more gcc warnings,
Eric Blake <=
Re: more gcc warnings, Eric Blake, 2005/07/09