From b0e25abdfca1b2c1d15a60beea830cfb7b1b5df0 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 19 Nov 2005 22:32:53 +0000 Subject: [PATCH] - Document ttyname_r(). - Fix several compilation warnings. - Perform some style(9) cleanup. Submitted-by: Alexey Slynko --- lib/libc/gen/Makefile.inc | 4 +- lib/libc/gen/disklabel.c | 4 +- lib/libc/gen/disktab.c | 4 +- lib/libc/gen/getbootfile.c | 3 +- lib/libc/gen/getcap.c | 7 +- lib/libc/gen/getgrent.c | 4 +- lib/libc/gen/gethostname.c | 3 +- lib/libc/gen/getpagesize.c | 3 +- lib/libc/gen/getpwent.c | 185 +++++++++++++++++---------------- lib/libc/gen/initgroups.c | 4 +- lib/libc/gen/readdir.c | 4 +- lib/libc/gen/seekdir.c | 4 +- lib/libc/gen/sethostname.c | 9 +- lib/libc/gen/setmode.c | 7 +- lib/libc/gen/shmat.c | 5 +- lib/libc/gen/strtofflags.c | 3 +- lib/libc/gen/sysctlnametomib.c | 3 +- lib/libc/gen/syslog.c | 8 +- lib/libc/gen/termios.c | 4 +- lib/libc/gen/timezone.c | 6 +- lib/libc/gen/tls.c | 4 +- lib/libc/gen/ttyname.3 | 9 +- lib/libc/gen/ttyname.c | 3 +- lib/libc/gen/unvis.c | 7 +- 24 files changed, 156 insertions(+), 141 deletions(-) diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index fd87760ff5..403fef91ab 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -1,6 +1,6 @@ # @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # $FreeBSD: src/lib/libc/gen/Makefile.inc,v 1.62.2.19 2003/02/21 13:46:16 phantom Exp $ -# $DragonFly: src/lib/libc/gen/Makefile.inc,v 1.16 2005/10/08 11:29:20 corecode Exp $ +# $DragonFly: src/lib/libc/gen/Makefile.inc,v 1.17 2005/11/19 22:32:53 swildner Exp $ # machine-independent gen sources .PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/gen ${.CURDIR}/../libc/gen @@ -136,7 +136,7 @@ MLINKS+=tcsetattr.3 cfgetispeed.3 tcsetattr.3 cfgetospeed.3 \ tcsetattr.3 cfmakeraw.3 tcsetattr.3 cfsetispeed.3 \ tcsetattr.3 cfsetospeed.3 tcsetattr.3 cfsetspeed.3 \ tcsetattr.3 tcgetattr.3 -MLINKS+=ttyname.3 isatty.3 ttyname.3 ttyslot.3 +MLINKS+=ttyname.3 isatty.3 ttyname.3 ttyslot.3 ttyname.3 ttyname_r.3 MLINKS+=tzset.3 tzsetwall.3 MLINKS+=unvis.3 strunvis.3 unvis.3 strunvisx.3 MLINKS+=vis.3 strvis.3 vis.3 strvisx.3 diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c index d35929ee8c..f435631c1e 100644 --- a/lib/libc/gen/disklabel.c +++ b/lib/libc/gen/disklabel.c @@ -32,7 +32,7 @@ * * @(#)disklabel.c 8.2 (Berkeley) 5/3/95 * $FreeBSD: src/lib/libc/gen/disklabel.c,v 1.9.2.1 2001/03/05 08:40:47 obrien Exp $ - * $DragonFly: src/lib/libc/gen/disklabel.c,v 1.7 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/disklabel.c,v 1.8 2005/11/19 22:32:53 swildner Exp $ */ #include @@ -63,7 +63,7 @@ getdiskbyname(const char *name) pfsize[3], poffset[3], ptype[3]; u_int32_t *dx; - if (cgetent(&buf, db_array, (char *) name) < 0) + if (cgetent(&buf, db_array, (char *)name) < 0) return NULL; bzero((char *)&disk, sizeof(disk)); diff --git a/lib/libc/gen/disktab.c b/lib/libc/gen/disktab.c index 8b845b781f..0b7ef8adae 100644 --- a/lib/libc/gen/disktab.c +++ b/lib/libc/gen/disktab.c @@ -32,7 +32,7 @@ * * @(#)disklabel.c 8.2 (Berkeley) 5/3/95 * $FreeBSD: src/lib/libc/gen/disklabel.c,v 1.9.2.1 2001/03/05 08:40:47 obrien Exp $ - * $DragonFly: src/lib/libc/gen/disktab.c,v 1.7 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/disktab.c,v 1.8 2005/11/19 22:32:53 swildner Exp $ */ #include @@ -63,7 +63,7 @@ getdiskbyname(const char *name) pfsize[3], poffset[3], ptype[3]; u_int32_t *dx; - if (cgetent(&buf, db_array, (char *) name) < 0) + if (cgetent(&buf, db_array, (char *)name) < 0) return NULL; bzero((char *)&disk, sizeof(disk)); diff --git a/lib/libc/gen/getbootfile.c b/lib/libc/gen/getbootfile.c index e854286b32..190fcf400d 100644 --- a/lib/libc/gen/getbootfile.c +++ b/lib/libc/gen/getbootfile.c @@ -32,11 +32,12 @@ * * @(#)gethostname.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/gen/getbootfile.c,v 1.5 1999/08/27 23:58:37 peter Exp $ - * $DragonFly: src/lib/libc/gen/getbootfile.c,v 1.2 2003/06/17 04:26:42 dillon Exp $ + * $DragonFly: src/lib/libc/gen/getbootfile.c,v 1.3 2005/11/19 22:32:53 swildner Exp $ */ #include #include +#include const char * getbootfile(void) diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c index a8844f1a21..1a57080cb1 100644 --- a/lib/libc/gen/getcap.c +++ b/lib/libc/gen/getcap.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/getcap.c,v 1.11.2.2 2001/01/15 06:48:09 gad Exp $ - * $DragonFly: src/lib/libc/gen/getcap.c,v 1.6 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/getcap.c,v 1.7 2005/11/19 22:32:53 swildner Exp $ * * @(#)getcap.c 8.3 (Berkeley) 3/25/94 */ @@ -196,6 +196,9 @@ getent(char **cap, u_int *len, char **db_array, int fd, char *name, int depth, int tc_not_resolved; char pbuf[_POSIX_PATH_MAX]; + rp = NULL; + myfd = 0; + /* * Return with ``loop detected'' error if we've recursed more than * MAX_RECURSION times. @@ -641,6 +644,8 @@ cgetnext(char **bp, char **db_array) char *cp, *line, *rp, *np, buf[BSIZE], nbuf[BSIZE]; u_int dummy; + savederrno = 0; + if (dbp == NULL) dbp = db_array; diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index 648230bda3..2197f9bb27 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -34,7 +34,7 @@ * * @(#)getgrent.c 8.2 (Berkeley) 3/21/94 * $FreeBSD: src/lib/libc/gen/getgrent.c,v 1.17.6.1 2001/03/05 08:56:02 obrien Exp $ - * $DragonFly: src/lib/libc/gen/getgrent.c,v 1.4 2005/04/27 12:36:31 joerg Exp $ + * $DragonFly: src/lib/libc/gen/getgrent.c,v 1.5 2005/11/19 22:32:53 swildner Exp $ */ #include @@ -499,7 +499,7 @@ static int _nextypgroup(struct group *gr) { static char *key; - static int keylen; + static size_t keylen; char *lastkey, *result; static char resultbuf[YPMAXRECORD + 2]; size_t resultlen; diff --git a/lib/libc/gen/gethostname.c b/lib/libc/gen/gethostname.c index c3fe19b62d..af36aaa6e4 100644 --- a/lib/libc/gen/gethostname.c +++ b/lib/libc/gen/gethostname.c @@ -31,11 +31,12 @@ * SUCH DAMAGE. * * @(#)gethostname.c 8.1 (Berkeley) 6/4/93 - * $DragonFly: src/lib/libc/gen/gethostname.c,v 1.3 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/gethostname.c,v 1.4 2005/11/19 22:32:53 swildner Exp $ */ #include #include +#include int gethostname(char *name, int namelen) diff --git a/lib/libc/gen/getpagesize.c b/lib/libc/gen/getpagesize.c index e2883d3c2d..cb21391f9c 100644 --- a/lib/libc/gen/getpagesize.c +++ b/lib/libc/gen/getpagesize.c @@ -31,11 +31,12 @@ * SUCH DAMAGE. * * @(#)getpagesize.c 8.1 (Berkeley) 6/4/93 - * $DragonFly: src/lib/libc/gen/getpagesize.c,v 1.3 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/getpagesize.c,v 1.4 2005/11/19 22:32:53 swildner Exp $ */ #include #include +#include /* * This is unlikely to change over the running time of any diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 4a5ec4b921..507896af78 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -32,7 +32,7 @@ * * @(#)getpwent.c 8.2 (Berkeley) 4/27/95 * $FreeBSD: src/lib/libc/gen/getpwent.c,v 1.53.2.2 2001/03/05 09:52:13 obrien Exp $ - * $DragonFly: src/lib/libc/gen/getpwent.c,v 1.6 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/getpwent.c,v 1.7 2005/11/19 22:32:53 swildner Exp $ */ #include "namespace.h" @@ -96,6 +96,98 @@ static char * _get_adjunct_pw (const char *); static int __hashpw(DBT *); static int __initdb(void); + +/* + * Parse the + entries in the password database and do appropriate + * NIS lookups. While ugly to look at, this is optimized to do only + * as many lookups as are absolutely necessary in any given case. + * Basically, the getpwent() function will feed us + and - lines + * as they appear in the database. For + lines, we do netgroup/group + * and user lookups to find all usernames that match the rule and + * extract them from the NIS passwd maps. For - lines, we save the + * matching names in a database and a) exlude them, and b) make sure + * we don't consider them when processing other + lines that appear + * later. + */ +static inline int +unwind(char *grp) +{ + char *user, *host, *domain; + static int latch = 0; + static struct group *gr = NULL; + int rv = 0; + + if (grp[0] == '+') { + if (strlen(grp) == 1) { + return(_nextyppass(&_pw_passwd)); + } + if (grp[1] == '@') { + _pw_stepping_yp = 1; +grpagain: + if (gr != NULL) { + if (*gr->gr_mem != NULL) { + if (lookup(*gr->gr_mem)) { + gr->gr_mem++; + goto grpagain; + } + rv = _getyppass(&_pw_passwd, + *gr->gr_mem, + "passwd.byname"); + gr->gr_mem++; + return(rv); + } else { + latch = 0; + _pw_stepping_yp = 0; + gr = NULL; + return(0); + } + } + if (!latch) { + setnetgrent(grp+2); + latch++; + } +again: + if (getnetgrent(&host, &user, &domain) == 0) { + if ((gr = getgrnam(grp+2)) != NULL) + goto grpagain; + latch = 0; + _pw_stepping_yp = 0; + return(0); + } else { + if (lookup(user)) + goto again; + if (_getyppass(&_pw_passwd, user, + "passwd.byname")) + return(1); + else + goto again; + } + } else { + if (lookup(grp+1)) + return(0); + return(_getyppass(&_pw_passwd, grp+1, "passwd.byname")); + } + } else { + if (grp[1] == '@') { + setnetgrent(grp+2); + rv = 0; + while(getnetgrent(&host, &user, &domain) != 0) { + store(user); + rv++; + } + if (!rv && (gr = getgrnam(grp+2)) != NULL) { + while(*gr->gr_mem) { + store(*gr->gr_mem); + gr->gr_mem++; + } + } + } else { + store(grp+1); + } + } + return(0); +} + struct passwd * getpwent(void) { @@ -386,97 +478,6 @@ store(const char *key) (_ypcache->put)(_ypcache, &lkey, &empty, R_NOOVERWRITE); } -/* - * Parse the + entries in the password database and do appropriate - * NIS lookups. While ugly to look at, this is optimized to do only - * as many lookups as are absolutely necessary in any given case. - * Basically, the getpwent() function will feed us + and - lines - * as they appear in the database. For + lines, we do netgroup/group - * and user lookups to find all usernames that match the rule and - * extract them from the NIS passwd maps. For - lines, we save the - * matching names in a database and a) exlude them, and b) make sure - * we don't consider them when processing other + lines that appear - * later. - */ -static inline int -unwind(char *grp) -{ - char *user, *host, *domain; - static int latch = 0; - static struct group *gr = NULL; - int rv = 0; - - if (grp[0] == '+') { - if (strlen(grp) == 1) { - return(_nextyppass(&_pw_passwd)); - } - if (grp[1] == '@') { - _pw_stepping_yp = 1; -grpagain: - if (gr != NULL) { - if (*gr->gr_mem != NULL) { - if (lookup(*gr->gr_mem)) { - gr->gr_mem++; - goto grpagain; - } - rv = _getyppass(&_pw_passwd, - *gr->gr_mem, - "passwd.byname"); - gr->gr_mem++; - return(rv); - } else { - latch = 0; - _pw_stepping_yp = 0; - gr = NULL; - return(0); - } - } - if (!latch) { - setnetgrent(grp+2); - latch++; - } -again: - if (getnetgrent(&host, &user, &domain) == 0) { - if ((gr = getgrnam(grp+2)) != NULL) - goto grpagain; - latch = 0; - _pw_stepping_yp = 0; - return(0); - } else { - if (lookup(user)) - goto again; - if (_getyppass(&_pw_passwd, user, - "passwd.byname")) - return(1); - else - goto again; - } - } else { - if (lookup(grp+1)) - return(0); - return(_getyppass(&_pw_passwd, grp+1, "passwd.byname")); - } - } else { - if (grp[1] == '@') { - setnetgrent(grp+2); - rv = 0; - while(getnetgrent(&host, &user, &domain) != 0) { - store(user); - rv++; - } - if (!rv && (gr = getgrnam(grp+2)) != NULL) { - while(*gr->gr_mem) { - store(*gr->gr_mem); - gr->gr_mem++; - } - } - } else { - store(grp+1); - } - } - return(0); -} - /* * See if a user is a member of a particular group. */ diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c index 67b3b4d08c..8868c90afc 100644 --- a/lib/libc/gen/initgroups.c +++ b/lib/libc/gen/initgroups.c @@ -32,7 +32,7 @@ * * @(#)initgroups.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/gen/initgroups.c,v 1.3.8.1 2001/12/19 15:49:35 tobez Exp $ - * $DragonFly: src/lib/libc/gen/initgroups.c,v 1.5 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/initgroups.c,v 1.6 2005/11/19 22:32:53 swildner Exp $ */ #include @@ -44,7 +44,7 @@ int initgroups(const char *uname, int agroup) { - gid_t ngroups; + int ngroups; /* * Provide space for one group more than NGROUPS to allow * setgroups to fail and set errno. diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c index 2fcf29e6ca..203921246a 100644 --- a/lib/libc/gen/readdir.c +++ b/lib/libc/gen/readdir.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/readdir.c,v 1.5.2.4 2002/02/26 22:53:57 alfred Exp $ - * $DragonFly: src/lib/libc/gen/readdir.c,v 1.7 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/readdir.c,v 1.8 2005/11/19 22:32:53 swildner Exp $ * * @(#)readdir.c 8.3 (Berkeley) 9/29/94 */ @@ -96,7 +96,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { struct dirent *dp; - int ret, saved_errno; + int saved_errno; saved_errno = errno; errno = 0; diff --git a/lib/libc/gen/seekdir.c b/lib/libc/gen/seekdir.c index bd4f5d69c5..0c43c5f144 100644 --- a/lib/libc/gen/seekdir.c +++ b/lib/libc/gen/seekdir.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/seekdir.c,v 1.2.8.1 2001/03/05 09:52:13 obrien Exp $ - * $DragonFly: src/lib/libc/gen/seekdir.c,v 1.5 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/seekdir.c,v 1.6 2005/11/19 22:32:53 swildner Exp $ * * @(#)seekdir.c 8.1 (Berkeley) 6/4/93 */ @@ -44,8 +44,6 @@ #include "libc_private.h" -extern void _seekdir ( DIR *, long ); - /* * Seek to an entry in a directory. * _seekdir is in telldir.c so that it can share opaque data structures. diff --git a/lib/libc/gen/sethostname.c b/lib/libc/gen/sethostname.c index a99151fbf2..fccd68a2ef 100644 --- a/lib/libc/gen/sethostname.c +++ b/lib/libc/gen/sethostname.c @@ -31,20 +31,15 @@ * SUCH DAMAGE. * * @(#)sethostname.c 8.1 (Berkeley) 6/4/93 + * $DragonFly: src/lib/libc/gen/sethostname.c,v 1.3 2005/11/19 22:32:53 swildner Exp $ */ #include #include +#include -#if __STDC__ int sethostname(const char *name, int namelen) -#else -int -sethostname(name, namelen) - char *name; - int namelen; -#endif { int mib[2]; diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c index 0cf03cd949..8c9ad85768 100644 --- a/lib/libc/gen/setmode.c +++ b/lib/libc/gen/setmode.c @@ -35,7 +35,7 @@ * * @(#)setmode.c 8.2 (Berkeley) 3/25/94 * $FreeBSD: src/lib/libc/gen/setmode.c,v 1.5.2.1 2001/03/05 09:34:10 obrien Exp $ - * $DragonFly: src/lib/libc/gen/setmode.c,v 1.6 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/setmode.c,v 1.7 2005/11/19 22:32:53 swildner Exp $ */ #include "namespace.h" @@ -46,6 +46,7 @@ #include #include #include +#include #ifdef SETMODE_DEBUG #include @@ -80,7 +81,7 @@ static void dumpmode (BITCMD *); * bits) followed by a '+' (set bits). */ mode_t -getmode(void *bbox, mode_t omode) +getmode(const void *bbox, mode_t omode) { BITCMD *set; mode_t clrval, newmode, value; @@ -163,7 +164,7 @@ common: if (set->cmd2 & CMD2_CLR) { #define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO) void * -setmode(char *p) +setmode(const char *p) { int perm, who; char op; diff --git a/lib/libc/gen/shmat.c b/lib/libc/gen/shmat.c index ed404b8435..ccd1b7617f 100644 --- a/lib/libc/gen/shmat.c +++ b/lib/libc/gen/shmat.c @@ -1,13 +1,14 @@ /* * $FreeBSD: src/lib/libc/gen/shmat.c,v 1.4 1999/08/27 23:58:56 peter Exp $ - * $DragonFly: src/lib/libc/gen/shmat.c,v 1.3 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/shmat.c,v 1.4 2005/11/19 22:32:53 swildner Exp $ */ #include #include #include -void *shmat(int shmid, void *shmaddr, int shmflg) +void * +shmat(int shmid, void *shmaddr, int shmflg) { return ((void *)shmsys(0, shmid, shmaddr, shmflg)); } diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c index 456de06171..63ee492a6d 100644 --- a/lib/libc/gen/strtofflags.c +++ b/lib/libc/gen/strtofflags.c @@ -32,7 +32,7 @@ * * @(#)stat_flags.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/lib/libc/gen/strtofflags.c,v 1.18.2.1 2000/06/28 01:52:24 joe Exp $ - * $DragonFly: src/lib/libc/gen/strtofflags.c,v 1.3 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/strtofflags.c,v 1.4 2005/11/19 22:32:53 swildner Exp $ */ #include @@ -41,6 +41,7 @@ #include #include #include +#include static struct { char *name; diff --git a/lib/libc/gen/sysctlnametomib.c b/lib/libc/gen/sysctlnametomib.c index 371a586608..95265d1637 100644 --- a/lib/libc/gen/sysctlnametomib.c +++ b/lib/libc/gen/sysctlnametomib.c @@ -24,11 +24,12 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/sysctlnametomib.c,v 1.1.2.1 2001/03/05 08:13:28 obrien Exp $ - * $DragonFly: src/lib/libc/gen/sysctlnametomib.c,v 1.2 2003/06/17 04:26:42 dillon Exp $ + * $DragonFly: src/lib/libc/gen/sysctlnametomib.c,v 1.3 2005/11/19 22:32:53 swildner Exp $ */ #include #include +#include /* * This function uses a presently undocumented interface to the kernel diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 150844969f..21e09828b9 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -32,7 +32,7 @@ * * @(#)syslog.c 8.5 (Berkeley) 4/29/95 * $FreeBSD: src/lib/libc/gen/syslog.c,v 1.21.2.3 2002/11/18 11:49:55 ru Exp $ - * $DragonFly: src/lib/libc/gen/syslog.c,v 1.8 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/syslog.c,v 1.9 2005/11/19 22:32:53 swildner Exp $ */ #include "namespace.h" @@ -80,9 +80,7 @@ struct bufcookie { * is `unlimited'. */ static int -writehook(void *cookie, /* really [struct bufcookie *] */ - char *buf, /* characters to copy */ - int len) /* length to copy */ +writehook(void *cookie, const char *buf, int len) { struct bufcookie *h; /* private `handle' */ @@ -125,6 +123,8 @@ vsyslog(int pri, const char *fmt, va_list ap) struct bufcookie tbuf_cookie; struct bufcookie fmt_cookie; + stdp = NULL; + #define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID /* Check for invalid bits. */ if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) { diff --git a/lib/libc/gen/termios.c b/lib/libc/gen/termios.c index 5fe9b6590f..f31468ba3b 100644 --- a/lib/libc/gen/termios.c +++ b/lib/libc/gen/termios.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/termios.c,v 1.9.2.1 2000/03/18 23:13:25 jasone Exp $ - * $DragonFly: src/lib/libc/gen/termios.c,v 1.4 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/termios.c,v 1.5 2005/11/19 22:32:53 swildner Exp $ * * @(#)termios.c 8.2 (Berkeley) 2/21/94 */ @@ -154,7 +154,7 @@ cfmakeraw(struct termios *t) } int -tcsendbreak(int fd, int len) +tcsendbreak(int fd, int len __unused) { struct timeval sleepytime; diff --git a/lib/libc/gen/timezone.c b/lib/libc/gen/timezone.c index 56ed6fb805..963cfc0318 100644 --- a/lib/libc/gen/timezone.c +++ b/lib/libc/gen/timezone.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)timezone.c 8.1 (Berkeley) 6/4/93 - * $DragonFly: src/lib/libc/gen/timezone.c,v 1.4 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/timezone.c,v 1.5 2005/11/19 22:32:53 swildner Exp $ */ #include @@ -41,7 +41,7 @@ #include #define TZ_MAX_CHARS 255 -char *_tztab(); +char *_tztab(int, int); /* * timezone -- @@ -94,7 +94,7 @@ static struct zone { {-10*60,"EST", "EST"}, /* Aust: Eastern */ {-10*60+30,"CST", "CST"}, /* Aust: Central */ {-8*60, "WST", 0}, /* Aust: Western */ - {-1} + {-1, NULL, NULL} }; /* diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index a713f17968..8531714a68 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/tls.c,v 1.7 2005/03/01 23:42:00 davidxu Exp $ - * $DragonFly: src/lib/libc/gen/tls.c,v 1.9 2005/05/11 19:46:52 dillon Exp $ + * $DragonFly: src/lib/libc/gen/tls.c,v 1.10 2005/11/19 22:32:53 swildner Exp $ */ /* @@ -245,7 +245,7 @@ _libc_init_tls(void) } } if (phdr == 0 || phent != sizeof(Elf_Phdr) || phnum == 0) - return; + return(NULL); for (i = 0; (unsigned)i < phnum; i++) { if (phdr[i].p_type == PT_TLS) { diff --git a/lib/libc/gen/ttyname.3 b/lib/libc/gen/ttyname.3 index c5935bd838..eb3769d9fe 100644 --- a/lib/libc/gen/ttyname.3 +++ b/lib/libc/gen/ttyname.3 @@ -31,7 +31,7 @@ .\" .\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD: src/lib/libc/gen/ttyname.3,v 1.5.2.3 2001/12/14 18:33:51 ru Exp $ -.\" $DragonFly: src/lib/libc/gen/ttyname.3,v 1.2 2003/06/17 04:26:42 dillon Exp $ +.\" $DragonFly: src/lib/libc/gen/ttyname.3,v 1.3 2005/11/19 22:32:53 swildner Exp $ .\" .Dd June 4, 1993 .Dt TTYNAME 3 @@ -47,6 +47,8 @@ .In unistd.h .Ft char * .Fn ttyname "int fd" +.Ft char * +.Fn ttyname_r "int fd" "char *buf" "size_t len" .Ft int .Fn isatty "int fd" .Ft int @@ -84,6 +86,11 @@ a file descriptor for which is true .Pp The +.Fn ttyname_r +function is a thread-safe version of +.Fn ttyname +.Pp +The .Fn ttyslot function fetches the current process' control terminal number from the diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c index eda489962c..469e48c916 100644 --- a/lib/libc/gen/ttyname.c +++ b/lib/libc/gen/ttyname.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/ttyname.c,v 1.10.6.2 2002/10/15 19:46:46 fjoe Exp $ - * $DragonFly: src/lib/libc/gen/ttyname.c,v 1.13 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/ttyname.c,v 1.14 2005/11/19 22:32:53 swildner Exp $ * * @(#)ttyname.c 8.2 (Berkeley) 1/27/94 */ @@ -58,6 +58,7 @@ static char static_buf[TTY_PATH_MAX] = _PATH_DEV; static char *oldttyname(int, struct stat *); static char *ttyname_threaded(int fd); static char *ttyname_unthreaded(int fd); +extern int __sys_fstat(int, struct stat *); static pthread_mutex_t ttyname_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_key_t ttyname_key; diff --git a/lib/libc/gen/unvis.c b/lib/libc/gen/unvis.c index 05122d9864..63b9ea1d3f 100644 --- a/lib/libc/gen/unvis.c +++ b/lib/libc/gen/unvis.c @@ -31,12 +31,13 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/gen/unvis.c,v 1.4.8.1 2000/08/17 08:25:54 jhb Exp $ - * $DragonFly: src/lib/libc/gen/unvis.c,v 1.4 2005/11/13 00:07:42 swildner Exp $ + * $DragonFly: src/lib/libc/gen/unvis.c,v 1.5 2005/11/19 22:32:53 swildner Exp $ * * @(#)unvis.c 8.1 (Berkeley) 6/4/93 */ #include +#include #include /* @@ -54,7 +55,7 @@ #define S_HTTP 0x080 /* %HEXHEX escape */ #define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') -#define ishex(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '9' || ((u_char)(c)) >= 'a' && ((u_char)(c)) <= 'f') +#define ishex(c) ((((u_char)(c)) >= '0' && ((u_char)(c)) <= '9') || (((u_char)(c)) >= 'a' && ((u_char)(c)) <= 'f')) /* * unvis - decode characters previously encoded by vis @@ -105,7 +106,7 @@ unvis(char *cp, int c, int *astate, int flag) *astate = S_OCTAL2; return (0); case 'M': - *cp = 0200; + *cp = (char)0200; *astate = S_META; return (0); case '^': -- 2.41.0