From d3d3aa621a23f4e4debf860217b2785d6947315c Mon Sep 17 00:00:00 2001 From: lukem Date: Sun, 19 Apr 2009 06:06:39 +0000 Subject: [PATCH] Fix WARNS=4 issues (-Wshadow -Wcast-qual -Wsign-compare) --- usr.sbin/ypserv/common/yplib_host.c | 8 ++--- usr.sbin/ypserv/common/yplib_host.h | 4 +-- usr.sbin/ypserv/makedbm/makedbm.c | 12 +++---- usr.sbin/ypserv/mkalias/mkalias.c | 8 ++--- usr.sbin/ypserv/mknetid/mknetid.c | 12 +++---- usr.sbin/ypserv/revnetgroup/hash.c | 6 ++-- usr.sbin/ypserv/revnetgroup/revnetgroup.c | 6 ++-- usr.sbin/ypserv/stdethers/stdethers.c | 7 ++-- usr.sbin/ypserv/stdhosts/stdhosts.c | 7 ++-- usr.sbin/ypserv/yppush/yppush.c | 16 ++++----- usr.sbin/ypserv/yppush/yppush.h | 4 +-- usr.sbin/ypserv/yppush/yppush_err.c | 6 ++-- usr.sbin/ypserv/yppush/yppush_svc.c | 8 ++--- usr.sbin/ypserv/ypserv/ypserv_db.c | 12 +++---- usr.sbin/ypserv/ypserv/ypserv_proc.c | 8 ++--- usr.sbin/ypserv/ypxfr/ypxfr.c | 40 +++++++++++------------ 16 files changed, 83 insertions(+), 81 deletions(-) diff --git a/usr.sbin/ypserv/common/yplib_host.c b/usr.sbin/ypserv/common/yplib_host.c index 426d7a0780d5..28ff307b4c63 100644 --- a/usr.sbin/ypserv/common/yplib_host.c +++ b/usr.sbin/ypserv/common/yplib_host.c @@ -1,4 +1,4 @@ -/* $NetBSD: yplib_host.c,v 1.7 2004/10/30 16:01:48 dsl Exp $ */ +/* $NetBSD: yplib_host.c,v 1.8 2009/04/19 06:06:39 lukem Exp $ */ /* * Copyright (c) 1992, 1993 Theo de Raadt @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: yplib_host.c,v 1.7 2004/10/30 16:01:48 dsl Exp $"); +__RCSID("$NetBSD: yplib_host.c,v 1.8 2009/04/19 06:06:39 lukem Exp $"); #endif #include @@ -136,7 +136,7 @@ yp_match_host(CLIENT *client, char *indomain, char *inmap, const char *inkey, yprk.domain = indomain; yprk.map = inmap; - yprk.keydat.dptr = (char *)inkey; + yprk.keydat.dptr = __UNCONST(inkey); yprk.keydat.dsize = inkeylen; memset(&yprv, 0, sizeof yprv); @@ -228,7 +228,7 @@ yp_next_host(CLIENT *client, char *indomain, char *inmap, char *inkey, } int -yp_all_host(CLIENT *client, char *indomain, char *inmap, +yp_all_host(CLIENT *client, const char *indomain, const char *inmap, struct ypall_callback *incallback) { struct ypreq_nokey yprnk; diff --git a/usr.sbin/ypserv/common/yplib_host.h b/usr.sbin/ypserv/common/yplib_host.h index ebd224bed5eb..ba452d199465 100644 --- a/usr.sbin/ypserv/common/yplib_host.h +++ b/usr.sbin/ypserv/common/yplib_host.h @@ -1,4 +1,4 @@ -/* $NetBSD: yplib_host.h,v 1.3 2003/12/10 12:06:26 agc Exp $ */ +/* $NetBSD: yplib_host.h,v 1.4 2009/04/19 06:06:39 lukem Exp $ */ /* * Copyright (c) 1992, 1993 Theo de Raadt @@ -42,7 +42,7 @@ int yp_master_host(CLIENT *client, char *indomain, char *inmap, char **outname); int yp_order_host(CLIENT *client, char *indomain, char *inmap, int *outorder); -int yp_all_host(CLIENT *client, char *indomain, char *inmap, +int yp_all_host(CLIENT *client, const char *indomain, const char *inmap, struct ypall_callback *incallback); int yp_maplist_host(CLIENT *client, char *indomain, struct ypmaplist **outmaplist); diff --git a/usr.sbin/ypserv/makedbm/makedbm.c b/usr.sbin/ypserv/makedbm/makedbm.c index e22bd8ba5a48..185004f4be03 100644 --- a/usr.sbin/ypserv/makedbm/makedbm.c +++ b/usr.sbin/ypserv/makedbm/makedbm.c @@ -1,4 +1,4 @@ -/* $NetBSD: makedbm.c,v 1.22 2008/02/29 03:00:47 lukem Exp $ */ +/* $NetBSD: makedbm.c,v 1.23 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1994 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: makedbm.c,v 1.22 2008/02/29 03:00:47 lukem Exp $"); +__RCSID("$NetBSD: makedbm.c,v 1.23 2009/04/19 06:06:40 lukem Exp $"); #endif #include @@ -57,7 +57,7 @@ __RCSID("$NetBSD: makedbm.c,v 1.22 2008/02/29 03:00:47 lukem Exp $"); int main(int, char *[]); void usage(void); -int add_record(DBM *, char *, char *, int); +int add_record(DBM *, const char *, const char *, int); char *file_date(char *); void list_database(char *); void create_database(char *, char *, char *, char *, char *, char *, @@ -149,12 +149,12 @@ main(int argc, char *argv[]) } int -add_record(DBM *db, char *str1, char *str2, int check) +add_record(DBM *db, const char *str1, const char *str2, int check) { datum key, val; int status; - key.dptr = str1; + key.dptr = __UNCONST(str1); key.dsize = strlen(str1); if (check) { @@ -163,7 +163,7 @@ add_record(DBM *db, char *str1, char *str2, int check) if (val.dptr != NULL) return 0; /* already there */ } - val.dptr = str2; + val.dptr = __UNCONST(str2); val.dsize = strlen(str2); status = ypdb_store(db, key, val, YPDB_INSERT); diff --git a/usr.sbin/ypserv/mkalias/mkalias.c b/usr.sbin/ypserv/mkalias/mkalias.c index 4831362d93d6..764cdab3d1c4 100644 --- a/usr.sbin/ypserv/mkalias/mkalias.c +++ b/usr.sbin/ypserv/mkalias/mkalias.c @@ -1,4 +1,4 @@ -/* $NetBSD: mkalias.c,v 1.15 2008/02/29 03:00:47 lukem Exp $ */ +/* $NetBSD: mkalias.c,v 1.16 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1997 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: mkalias.c,v 1.15 2008/02/29 03:00:47 lukem Exp $"); +__RCSID("$NetBSD: mkalias.c,v 1.16 2009/04/19 06:06:40 lukem Exp $"); #endif #include @@ -300,7 +300,7 @@ main(int argc, char *argv[]) if (new_db != NULL) { snprintf(datestr, sizeof(datestr), "%010d", (int)time(NULL)); - key.dptr = YP_LAST_KEY; + key.dptr = __UNCONST(YP_LAST_KEY); key.dsize = strlen(YP_LAST_KEY); val.dptr = datestr; val.dsize = strlen(datestr); @@ -313,7 +313,7 @@ main(int argc, char *argv[]) if (new_db != NULL) { localhostname(myname, sizeof(myname) - 1); - key.dptr = YP_MASTER_KEY; + key.dptr = __UNCONST(YP_MASTER_KEY); key.dsize = strlen(YP_MASTER_KEY); val.dptr = myname; val.dsize = strlen(myname); diff --git a/usr.sbin/ypserv/mknetid/mknetid.c b/usr.sbin/ypserv/mknetid/mknetid.c index e5412f28ae85..102380820705 100644 --- a/usr.sbin/ypserv/mknetid/mknetid.c +++ b/usr.sbin/ypserv/mknetid/mknetid.c @@ -1,4 +1,4 @@ -/* $NetBSD: mknetid.c,v 1.15 2004/10/30 16:01:48 dsl Exp $ */ +/* $NetBSD: mknetid.c,v 1.16 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1996 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: mknetid.c,v 1.15 2004/10/30 16:01:48 dsl Exp $"); +__RCSID("$NetBSD: mknetid.c,v 1.16 2009/04/19 06:06:40 lukem Exp $"); #endif /* @@ -89,10 +89,10 @@ struct user_list hroot[HASHMAX]; int main(int argc, char *argv[]) { - char *HostFile = _PATH_HOSTS; - char *PasswdFile = _PATH_PASSWD; - char *GroupFile = _PATH_GROUP; - char *NetidFile = "/etc/netid"; + const char *HostFile = _PATH_HOSTS; + const char *PasswdFile = _PATH_PASSWD; + const char *GroupFile = _PATH_GROUP; + const char *NetidFile = "/etc/netid"; int qflag, ch; char *domain; diff --git a/usr.sbin/ypserv/revnetgroup/hash.c b/usr.sbin/ypserv/revnetgroup/hash.c index bd3005198833..931321f5f482 100644 --- a/usr.sbin/ypserv/revnetgroup/hash.c +++ b/usr.sbin/ypserv/revnetgroup/hash.c @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.4 2006/03/18 14:33:07 bouyer Exp $ */ +/* $NetBSD: hash.c,v 1.5 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1995 @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hash.c,v 1.4 2006/03/18 14:33:07 bouyer Exp $"); +__RCSID("$NetBSD: hash.c,v 1.5 2009/04/19 06:06:40 lukem Exp $"); #endif #include @@ -116,7 +116,7 @@ hashkey(const char *key) if (key == NULL) return (-1); - return(hash((void *)key, strlen(key)) & HASH_MASK); + return(hash((const void *)key, strlen(key)) & HASH_MASK); } /* Find an entry in the hash table (may be hanging off a linked list). */ diff --git a/usr.sbin/ypserv/revnetgroup/revnetgroup.c b/usr.sbin/ypserv/revnetgroup/revnetgroup.c index 8cf333a28f2f..111a35ecca01 100644 --- a/usr.sbin/ypserv/revnetgroup/revnetgroup.c +++ b/usr.sbin/ypserv/revnetgroup/revnetgroup.c @@ -1,4 +1,4 @@ -/* $NetBSD: revnetgroup.c,v 1.13 2004/10/30 16:01:48 dsl Exp $ */ +/* $NetBSD: revnetgroup.c,v 1.14 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1995 @@ -41,7 +41,7 @@ #include #ifndef lint -__RCSID("$NetBSD: revnetgroup.c,v 1.13 2004/10/30 16:01:48 dsl Exp $"); +__RCSID("$NetBSD: revnetgroup.c,v 1.14 2009/04/19 06:06:40 lukem Exp $"); #endif #include @@ -61,7 +61,7 @@ void usage(void); /* Default location of netgroup file. */ -char *netgroup = "/etc/netgroup"; +const char *netgroup = "/etc/netgroup"; /* Stored hash table version of 'forward' netgroup database. */ struct group_entry *gtable[TABLESIZE]; diff --git a/usr.sbin/ypserv/stdethers/stdethers.c b/usr.sbin/ypserv/stdethers/stdethers.c index 2627e9b01d13..63463670f583 100644 --- a/usr.sbin/ypserv/stdethers/stdethers.c +++ b/usr.sbin/ypserv/stdethers/stdethers.c @@ -1,4 +1,4 @@ -/* $NetBSD: stdethers.c,v 1.16 2007/03/10 01:21:08 hubertf Exp $ */ +/* $NetBSD: stdethers.c,v 1.17 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1995 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: stdethers.c,v 1.16 2007/03/10 01:21:08 hubertf Exp $"); +__RCSID("$NetBSD: stdethers.c,v 1.17 2009/04/19 06:06:40 lukem Exp $"); #endif #include @@ -61,7 +61,8 @@ main(int argc, char *argv[]) FILE *data_file; size_t line_no; size_t len; - char *fname, *p; + const char *fname; + char *p; char hostname[MAXHOSTNAMELEN + 1]; if (argc > 2) diff --git a/usr.sbin/ypserv/stdhosts/stdhosts.c b/usr.sbin/ypserv/stdhosts/stdhosts.c index ac7ff76e615a..64f4783c452e 100644 --- a/usr.sbin/ypserv/stdhosts/stdhosts.c +++ b/usr.sbin/ypserv/stdhosts/stdhosts.c @@ -1,4 +1,4 @@ -/* $NetBSD: stdhosts.c,v 1.17 2004/10/30 16:01:48 dsl Exp $ */ +/* $NetBSD: stdhosts.c,v 1.18 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1994 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: stdhosts.c,v 1.17 2004/10/30 16:01:48 dsl Exp $"); +__RCSID("$NetBSD: stdhosts.c,v 1.18 2009/04/19 06:06:40 lukem Exp $"); #endif #include @@ -61,7 +61,8 @@ main(int argc, char *argv[]) FILE *data_file; size_t line_no; size_t len; - char *line, *k, *v, *addr_string, *fname; + char *line, *k, *v, *addr_string; + const char *fname; int ch; int af = 1 << 4; /*IPv4*/ struct addrinfo hints, *res; diff --git a/usr.sbin/ypserv/yppush/yppush.c b/usr.sbin/ypserv/yppush/yppush.c index 3a9ef27047a2..df96956355f2 100644 --- a/usr.sbin/ypserv/yppush/yppush.c +++ b/usr.sbin/ypserv/yppush/yppush.c @@ -1,4 +1,4 @@ -/* $NetBSD: yppush.c,v 1.21 2008/02/29 03:00:47 lukem Exp $ */ +/* $NetBSD: yppush.c,v 1.22 2009/04/19 06:06:40 lukem Exp $ */ /* * @@ -113,7 +113,7 @@ main(int argc, char *argv[]) const char *cp; char *master; DBM *ypdb; - datum datum; + datum dat; CLIENT *ypserv; struct timeval tv; enum clnt_stat retval; @@ -178,16 +178,16 @@ main(int argc, char *argv[]) if (ypdb == NULL) err(1, "ypdb_open %s/%s/%s", YP_DB_PATH, ypi.ourdomain, ypi.map); - datum.dptr = YP_LAST_KEY; - datum.dsize = YP_LAST_LEN; - datum = ypdb_fetch(ypdb, datum); - if (datum.dptr == NULL) + dat.dptr = YP_LAST_KEY; + dat.dsize = YP_LAST_LEN; + dat = ypdb_fetch(ypdb, dat); + if (dat.dptr == NULL) errx(1, "unable to fetch %s key: check database with 'makedbm -u'", YP_LAST_KEY); ypi.order = 0; - cp = datum.dptr; - while (cp < datum.dptr + datum.dsize) { + cp = dat.dptr; + while (cp < dat.dptr + dat.dsize) { if (!isdigit((unsigned char)*cp)) errx(1, "invalid order number: check database with 'makedbm -u'"); diff --git a/usr.sbin/ypserv/yppush/yppush.h b/usr.sbin/ypserv/yppush/yppush.h index e474adc81da2..735eda4af41b 100644 --- a/usr.sbin/ypserv/yppush/yppush.h +++ b/usr.sbin/ypserv/yppush/yppush.h @@ -1,4 +1,4 @@ -/* $NetBSD: yppush.h,v 1.3 2003/11/12 13:31:08 grant Exp $ */ +/* $NetBSD: yppush.h,v 1.4 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1996 Mats O Jansson @@ -51,4 +51,4 @@ void *yppushproc_xfrresp_1_svc(void *, struct svc_req *); void yppush_xfrrespprog_1(struct svc_req *, SVCXPRT *); -char *yppush_err_string(int); +const char *yppush_err_string(int); diff --git a/usr.sbin/ypserv/yppush/yppush_err.c b/usr.sbin/ypserv/yppush/yppush_err.c index 5a2ebf9d226f..85756984a76d 100644 --- a/usr.sbin/ypserv/yppush/yppush_err.c +++ b/usr.sbin/ypserv/yppush/yppush_err.c @@ -1,4 +1,4 @@ -/* $NetBSD: yppush_err.c,v 1.4 2002/07/06 00:46:12 wiz Exp $ */ +/* $NetBSD: yppush_err.c,v 1.5 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1996 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: yppush_err.c,v 1.4 2002/07/06 00:46:12 wiz Exp $"); +__RCSID("$NetBSD: yppush_err.c,v 1.5 2009/04/19 06:06:40 lukem Exp $"); #endif #include @@ -47,7 +47,7 @@ __RCSID("$NetBSD: yppush_err.c,v 1.4 2002/07/06 00:46:12 wiz Exp $"); #include "yppush.h" -char * +const char * yppush_err_string(int y) { static char errstr[64]; diff --git a/usr.sbin/ypserv/yppush/yppush_svc.c b/usr.sbin/ypserv/yppush/yppush_svc.c index 0b1ed28d3dd1..8e1b6e234dfc 100644 --- a/usr.sbin/ypserv/yppush/yppush_svc.c +++ b/usr.sbin/ypserv/yppush/yppush_svc.c @@ -1,4 +1,4 @@ -/* $NetBSD: yppush_svc.c,v 1.7 2003/11/12 13:31:08 grant Exp $ */ +/* $NetBSD: yppush_svc.c,v 1.8 2009/04/19 06:06:40 lukem Exp $ */ /* * Copyright (c) 1996 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: yppush_svc.c,v 1.7 2003/11/12 13:31:08 grant Exp $"); +__RCSID("$NetBSD: yppush_svc.c,v 1.8 2009/04/19 06:06:40 lukem Exp $"); #endif /* @@ -69,10 +69,10 @@ int _rpcpmstart; /* Started by a port monitor ? */ int _rpcfdtype; /* Whether Stream or Datagram ? */ int _rpcsvcdirty; /* Still serving ? */ -static void _msgout(char *); +static void _msgout(const char *); static -void _msgout(char *msg) +void _msgout(const char *msg) { #ifdef RPC_SVC_FG if (_rpcpmstart) diff --git a/usr.sbin/ypserv/ypserv/ypserv_db.c b/usr.sbin/ypserv/ypserv/ypserv_db.c index dcb1d062d68f..d179d4c4d135 100644 --- a/usr.sbin/ypserv/ypserv/ypserv_db.c +++ b/usr.sbin/ypserv/ypserv/ypserv_db.c @@ -1,4 +1,4 @@ -/* $NetBSD: ypserv_db.c,v 1.19 2008/02/29 03:00:47 lukem Exp $ */ +/* $NetBSD: ypserv_db.c,v 1.20 2009/04/19 06:06:41 lukem Exp $ */ /* * Copyright (c) 1994 Mats O Jansson @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ypserv_db.c,v 1.19 2008/02/29 03:00:47 lukem Exp $"); +__RCSID("$NetBSD: ypserv_db.c,v 1.20 2009/04/19 06:06:41 lukem Exp $"); #endif /* @@ -241,8 +241,8 @@ DBM * ypdb_open_db(const char *domain, const char *map, u_int *status, struct opt_map **map_info) { - static char *domain_key = YP_INTERDOMAIN_KEY; - static char *secure_key = YP_SECURE_KEY; + static const char *domain_key = YP_INTERDOMAIN_KEY; + static const char *secure_key = YP_SECURE_KEY; char map_path[MAXPATHLEN]; struct stat finfo; struct opt_domain *d = NULL; @@ -695,7 +695,7 @@ struct ypresp_order ypdb_get_order(const char *domain, const char *map) { static struct ypresp_order res; - static char *order_key = YP_LAST_KEY; + static const char *order_key = YP_LAST_KEY; char order[MAX_LAST_LEN + 1]; DBM *db; datum k, v; @@ -727,7 +727,7 @@ struct ypresp_master ypdb_get_master(const char *domain, const char *map) { static struct ypresp_master res; - static char *master_key = YP_MASTER_KEY; + static const char *master_key = YP_MASTER_KEY; static char master[MAX_MASTER_LEN + 1]; DBM *db; datum k, v; diff --git a/usr.sbin/ypserv/ypserv/ypserv_proc.c b/usr.sbin/ypserv/ypserv/ypserv_proc.c index b76dc488e6df..afe07966af13 100644 --- a/usr.sbin/ypserv/ypserv/ypserv_proc.c +++ b/usr.sbin/ypserv/ypserv/ypserv_proc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ypserv_proc.c,v 1.12 2007/08/22 16:49:17 christos Exp $ */ +/* $NetBSD: ypserv_proc.c,v 1.13 2009/04/19 06:06:41 lukem Exp $ */ /* * Copyright (c) 1994 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ypserv_proc.c,v 1.12 2007/08/22 16:49:17 christos Exp $"); +__RCSID("$NetBSD: ypserv_proc.c,v 1.13 2009/04/19 06:06:41 lukem Exp $"); #endif #include @@ -357,7 +357,7 @@ void * ypproc_master_2_svc(void *argp, struct svc_req *rqstp) { static struct ypresp_master res; - static char *nopeer = ""; + static const char *nopeer = ""; struct sockaddr *caller = svc_getrpccaller(rqstp->rq_xprt)->buf; struct ypreq_nokey *k = argp; int secure; @@ -389,7 +389,7 @@ ypproc_master_2_svc(void *argp, struct svc_req *rqstp) * xdr_string in ypserv_xdr.c may be a better place? */ if (res.master == NULL) - res.master = nopeer; + res.master = __UNCONST(nopeer); return ((void *)&res); } diff --git a/usr.sbin/ypserv/ypxfr/ypxfr.c b/usr.sbin/ypserv/ypxfr/ypxfr.c index 23ae0c77d0cb..e6c6adbe2414 100644 --- a/usr.sbin/ypserv/ypxfr/ypxfr.c +++ b/usr.sbin/ypserv/ypxfr/ypxfr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ypxfr.c,v 1.15 2008/02/29 03:00:47 lukem Exp $ */ +/* $NetBSD: ypxfr.c,v 1.16 2009/04/19 06:06:41 lukem Exp $ */ /* * Copyright (c) 1994 Mats O Jansson @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ypxfr.c,v 1.15 2008/02/29 03:00:47 lukem Exp $"); +__RCSID("$NetBSD: ypxfr.c,v 1.16 2009/04/19 06:06:41 lukem Exp $"); #endif #include @@ -301,9 +301,9 @@ get_local_ordernum(char *domain, char *map, u_int *lordernum) char order_key[] = YP_LAST_KEY; char order[MAX_LAST_LEN+1]; struct stat finfo; - DBM *db; + DBM *ldb; datum k, v; - int status; + unsigned int status; status = YPPUSH_SUCC; @@ -328,8 +328,8 @@ get_local_ordernum(char *domain, char *map, u_int *lordernum) /* Open the map file. */ snprintf(map_path, sizeof(map_path), "%s/%s/%s", YP_DB_PATH, domain, map); - db = ypdb_open(map_path); - if (db == NULL) { + ldb = ypdb_open(map_path); + if (ldb == NULL) { status = YPPUSH_DBM; goto out; } @@ -337,7 +337,7 @@ get_local_ordernum(char *domain, char *map, u_int *lordernum) k.dptr = (char *)&order_key; k.dsize = YP_LAST_LEN; - v = ypdb_fetch(db, k); + v = ypdb_fetch(ldb, k); if (v.dptr == NULL) *lordernum = 0; @@ -346,7 +346,7 @@ get_local_ordernum(char *domain, char *map, u_int *lordernum) order[v.dsize] = '\0'; *lordernum = (u_int)atoi((char *)&order); } - ypdb_close(db); + ypdb_close(ldb); out: if ((status == YPPUSH_NOMAP) || (status == YPPUSH_DBM)) { @@ -387,14 +387,14 @@ DBM * create_db(char *domain, char *map, char *db_temp, size_t db_temp_len) { static const char template[] = "ypdbXXXXXX"; - DBM *db; + DBM *ldb; snprintf(db_temp, db_temp_len, "%s/%s/%s", YP_DB_PATH, domain, template); - db = ypdb_mktemp(db_temp); + ldb = ypdb_mktemp(db_temp); - return db; + return ldb; } int @@ -426,7 +426,7 @@ unlink_db(char *domain, char *map, char *db_temp) } int -add_order(DBM *db, u_int ordernum) +add_order(DBM *ldb, u_int ordernum) { char datestr[11]; datum key, val; @@ -441,7 +441,7 @@ add_order(DBM *db, u_int ordernum) val.dptr = datestr; val.dsize = strlen(datestr); - status = ypdb_store(db, key, val, YPDB_INSERT); + status = ypdb_store(ldb, key, val, YPDB_INSERT); if(status >= 0) status = YPPUSH_SUCC; else @@ -451,7 +451,7 @@ add_order(DBM *db, u_int ordernum) } int -add_master(CLIENT *client, char *domain, char *map, DBM *db) +add_master(CLIENT *client, char *domain, char *map, DBM *ldb) { char keystr[] = YP_MASTER_KEY; char *master; @@ -470,7 +470,7 @@ add_master(CLIENT *client, char *domain, char *map, DBM *db) val.dptr = master; val.dsize = strlen(master); - status = ypdb_store(db, key, val, YPDB_INSERT); + status = ypdb_store(ldb, key, val, YPDB_INSERT); if (status >= 0) status = YPPUSH_SUCC; else @@ -481,7 +481,7 @@ add_master(CLIENT *client, char *domain, char *map, DBM *db) } int -add_interdomain(CLIENT *client, char *domain, char *map, DBM *db) +add_interdomain(CLIENT *client, char *domain, char *map, DBM *ldb) { char keystr[] = YP_INTERDOMAIN_KEY; char *value; @@ -501,7 +501,7 @@ add_interdomain(CLIENT *client, char *domain, char *map, DBM *db) v.dsize = vallen; if (v.dptr != NULL) { - status = ypdb_store(db, k, v, YPDB_INSERT); + status = ypdb_store(ldb, k, v, YPDB_INSERT); if (status >= 0) status = YPPUSH_SUCC; else @@ -513,7 +513,7 @@ add_interdomain(CLIENT *client, char *domain, char *map, DBM *db) } int -add_secure(CLIENT *client, char *domain, char *map, DBM *db) +add_secure(CLIENT *client, char *domain, char *map, DBM *ldb) { char keystr[] = YP_SECURE_KEY; char *value; @@ -528,12 +528,12 @@ add_secure(CLIENT *client, char *domain, char *map, DBM *db) status = yp_match_host(client, domain, map, k.dptr, k.dsize, &value, &vallen); - if (status == 0 && value > 0) { + if (status == 0 && value != 0) { v.dptr = value; v.dsize = vallen; if (v.dptr != NULL) { - status = ypdb_store(db, k, v, YPDB_INSERT); + status = ypdb_store(ldb, k, v, YPDB_INSERT); if (status >= 0) status = YPPUSH_SUCC; else