diff options
Diffstat (limited to 'inet')
-rw-r--r-- | inet/ether_hton.c | 4 | ||||
-rw-r--r-- | inet/ether_line.c | 4 | ||||
-rw-r--r-- | inet/ether_ntoh.c | 4 | ||||
-rw-r--r-- | inet/getnameinfo.c | 10 | ||||
-rw-r--r-- | inet/getnetgrent_r.c | 4 | ||||
-rw-r--r-- | inet/ruserpass.c | 50 |
6 files changed, 45 insertions, 31 deletions
diff --git a/inet/ether_hton.c b/inet/ether_hton.c index 4e24fbb89f..92353c19c8 100644 --- a/inet/ether_hton.c +++ b/inet/ether_hton.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -44,7 +44,7 @@ extern int __nss_ethers_lookup (service_user **nip, const char *name, int ether_hostton (const char *hostname, struct ether_addr *addr) { - static service_user *startp = NULL; + static service_user *startp; static lookup_function start_fct; service_user *nip; lookup_function fct; diff --git a/inet/ether_line.c b/inet/ether_line.c index 889be0a4e9..0911499c13 100644 --- a/inet/ether_line.c +++ b/inet/ether_line.c @@ -62,9 +62,7 @@ ether_line (const char *line, struct ether_addr *addr, char *hostname) } /* Remove trailing white space. */ - cp = strchr (line, '#'); - if (cp == NULL) - cp = strchr (line, '\0'); + cp = __strchrnul (line, '#'); while (cp > line && isspace (cp[-1])) --cp; *cp = '\0'; diff --git a/inet/ether_ntoh.c b/inet/ether_ntoh.c index ab3650f2a2..6937201c03 100644 --- a/inet/ether_ntoh.c +++ b/inet/ether_ntoh.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -45,7 +45,7 @@ extern int __nss_ethers_lookup (service_user **nip, const char *name, int ether_ntohost (char *hostname, const struct ether_addr *addr) { - static service_user *startp = NULL; + static service_user *startp; static lookup_function start_fct; service_user *nip; lookup_function fct; diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c index f31d3b9538..b69bdbe57d 100644 --- a/inet/getnameinfo.c +++ b/inet/getnameinfo.c @@ -66,15 +66,15 @@ static char * internal_function nrl_domainname (void) { - static char *domain = NULL; - static int first = 1; + static char *domain; + static int not_first; - if (first) + if (not_first) { __libc_lock_define_initialized (static, lock); __libc_lock_lock (lock); - if (first) + if (not_first) { char *c; struct hostent *h, th; @@ -82,7 +82,7 @@ nrl_domainname (void) char *tmpbuf = alloca (tmpbuflen); int herror; - first = 0; + not_first = 1; while (__gethostbyname_r ("localhost", &th, tmpbuf, tmpbuflen, &h, &herror)) diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c index d3443793bf..4bbba38ea2 100644 --- a/inet/getnetgrent_r.c +++ b/inet/getnetgrent_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998, 1999 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 @@ -48,7 +48,7 @@ static enum nss_status setup (void **fctp, const char *func_name, int all) { /* Remember the first service_entry, it's always the same. */ - static service_user *startp = NULL; + static service_user *startp; int no_more; if (startp == NULL) diff --git a/inet/ruserpass.c b/inet/ruserpass.c index d8ea79a046..2673fc5bf4 100644 --- a/inet/ruserpass.c +++ b/inet/ruserpass.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#ifndef lint +#if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94"; #endif /* not lint */ @@ -61,18 +61,35 @@ static FILE *cfile; static char tokval[100]; -static struct toktab { - const char *tokstr; +static const char tokstr[] = +{ +#define TOK_DEFAULT_IDX 0 + "default\0" +#define TOK_LOGIN_IDX (TOK_DEFAULT_IDX + sizeof "default") + "login\0" +#define TOK_PASSWORD_IDX (TOK_LOGIN_IDX + sizeof "login") + "password\0" +#define TOK_PASSWD_IDX (TOK_PASSWORD_IDX + sizeof "password") + "passwd\0" +#define TOK_ACCOUNT_IDX (TOK_PASSWD_IDX + sizeof "passwd") + "account\0" +#define TOK_MACHINE_IDX (TOK_ACCOUNT_IDX + sizeof "account") + "machine\0" +#define TOK_MACDEF_IDX (TOK_MACHINE_IDX + sizeof "machine") + "macdef" +}; + +static const struct toktab { + int tokstr_off; int tval; } toktab[]= { - { "default", DEFAULT }, - { "login", LOGIN }, - { "password", PASSWD }, - { "passwd", PASSWD }, - { "account", ACCOUNT }, - { "machine", MACHINE }, - { "macdef", MACDEF }, - { NULL, 0 } + { TOK_DEFAULT_IDX, DEFAULT }, + { TOK_LOGIN_IDX, LOGIN }, + { TOK_PASSWORD_IDX, PASSWD }, + { TOK_PASSWD_IDX, PASSWD }, + { TOK_ACCOUNT_IDX, ACCOUNT }, + { TOK_MACHINE_IDX, MACHINE }, + { TOK_MACDEF_IDX, MACDEF } }; @@ -106,8 +123,7 @@ ruserpass(host, aname, apass) } if (__gethostname(myname, sizeof(myname)) < 0) myname[0] = '\0'; - if ((mydomain = strchr(myname, '.')) == NULL) - mydomain = ""; + mydomain = __strchrnul(myname, '.'); next: while ((t = token())) switch(t) { @@ -262,7 +278,7 @@ token() { char *cp; int c; - struct toktab *t; + int i; if (feof_unlocked(cfile) || ferror_unlocked(cfile)) return (0); @@ -290,8 +306,8 @@ token() *cp = 0; if (tokval[0] == 0) return (0); - for (t = toktab; t->tokstr; t++) - if (!strcmp(t->tokstr, tokval)) - return (t->tval); + for (i = 0; i < sizeof (toktab) / sizeof (toktab[0]); ++i) + if (!strcmp(&tokstr[toktab[i].tokstr_off], tokval)) + return toktab[i].tval; return (ID); } |