Module Name:    src
Committed By:   lukem
Date:           Sat Apr 11 12:10:02 UTC 2009

Modified Files:
        src/usr.bin/chpass: edit.c field.c pw_yp.c table.c

Log Message:
Fix WARNS=4 (-Wcast-qual -Wsign-compare -Wshadow) issues.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/chpass/edit.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/chpass/field.c
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/chpass/pw_yp.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/chpass/table.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/chpass/edit.c
diff -u src/usr.bin/chpass/edit.c:1.19 src/usr.bin/chpass/edit.c:1.20
--- src/usr.bin/chpass/edit.c:1.19	Thu Jun  2 01:42:11 2005
+++ src/usr.bin/chpass/edit.c	Sat Apr 11 12:10:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: edit.c,v 1.19 2005/06/02 01:42:11 lukem Exp $	*/
+/*	$NetBSD: edit.c,v 1.20 2009/04/11 12:10:02 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)edit.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: edit.c,v 1.19 2005/06/02 01:42:11 lukem Exp $");
+__RCSID("$NetBSD: edit.c,v 1.20 2009/04/11 12:10:02 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -214,7 +214,7 @@
 	    "%s:%s:%d:%d:%s:%lu:%lu:%s:%s:%s",
 	    pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_class,
 	    (u_long)pw->pw_change, (u_long)pw->pw_expire, pw->pw_gecos,
-	    pw->pw_dir, pw->pw_shell) >= sizeof(buf)) {
+	    pw->pw_dir, pw->pw_shell) >= (int)sizeof(buf)) {
 		warnx("entries too long");
 		return (0);
 	}

Index: src/usr.bin/chpass/field.c
diff -u src/usr.bin/chpass/field.c:1.11 src/usr.bin/chpass/field.c:1.12
--- src/usr.bin/chpass/field.c:1.11	Thu Feb 17 17:09:48 2005
+++ src/usr.bin/chpass/field.c	Sat Apr 11 12:10:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: field.c,v 1.11 2005/02/17 17:09:48 xtraeme Exp $	*/
+/*	$NetBSD: field.c,v 1.12 2009/04/11 12:10:02 lukem Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)field.c	8.4 (Berkeley) 4/2/94";
 #else 
-__RCSID("$NetBSD: field.c,v 1.11 2005/02/17 17:09:48 xtraeme Exp $");
+__RCSID("$NetBSD: field.c,v 1.12 2009/04/11 12:10:02 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -85,9 +85,7 @@
 p_passwd(const char *p, struct passwd *pw, ENTRY *ep)
 {
 
-	if (!*p)
-		pw->pw_passwd = "";	/* "NOLOGIN"; */
-	else if (!(pw->pw_passwd = strdup(p))) {
+	if (!(pw->pw_passwd = strdup(p))) {
 		warnx("can't save password entry");
 		return (1);
 	}
@@ -163,9 +161,7 @@
 p_class(const char *p, struct passwd *pw, ENTRY *ep)
 {
 
-	if (!*p)
-		pw->pw_class = "";
-	else if (!(pw->pw_class = strdup(p))) {
+	if (!(pw->pw_class = strdup(p))) {
 		warnx("can't save entry");
 		return (1);
 	}
@@ -230,7 +226,10 @@
 	const char *t;
 
 	if (!*p) {
-		pw->pw_shell = _PATH_BSHELL;
+		if (!(pw->pw_shell = strdup(_PATH_BSHELL))) {
+			warnx("can't save entry");
+			return (1);
+		}
 		return (0);
 	}
 	/* only admin can change from or to "restricted" shells */

Index: src/usr.bin/chpass/pw_yp.c
diff -u src/usr.bin/chpass/pw_yp.c:1.21 src/usr.bin/chpass/pw_yp.c:1.22
--- src/usr.bin/chpass/pw_yp.c:1.21	Thu Feb 17 17:09:48 2005
+++ src/usr.bin/chpass/pw_yp.c	Sat Apr 11 12:10:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pw_yp.c,v 1.21 2005/02/17 17:09:48 xtraeme Exp $	*/
+/*	$NetBSD: pw_yp.c,v 1.22 2009/04/11 12:10:02 lukem Exp $	*/
 
 /*
  * Copyright (c) 1988 The Regents of the University of California.
@@ -33,7 +33,7 @@
 #if 0
 static char sccsid[] = "@(#)pw_yp.c	1.0 2/2/93";
 #else
-__RCSID("$NetBSD: pw_yp.c,v 1.21 2005/02/17 17:09:48 xtraeme Exp $");
+__RCSID("$NetBSD: pw_yp.c,v 1.22 2009/04/11 12:10:02 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -103,11 +103,11 @@
 }
 
 int
-pw_yp(struct passwd *pw, uid_t uid)
+pw_yp(struct passwd *pw, uid_t ypuid)
 {
 	char *master;
 	int r, rpcport, status;
-	struct yppasswd yppasswd;
+	struct yppasswd yppw;
 	struct timeval tv;
 	CLIENT *client;
 	
@@ -150,39 +150,38 @@
 	}
 
 	/* prompt for old password */
-	memset(&yppasswd, 0, sizeof yppasswd);
-	yppasswd.oldpass = "none";
-	yppasswd.oldpass = getpass("Old password:");
-	if (!yppasswd.oldpass) {
+	memset(&yppw, 0, sizeof yppw);
+	yppw.oldpass = getpass("Old password:");
+	if (!yppw.oldpass) {
 		warnx("Cancelled.");
 		return (1);
 	}
 
 	/* tell rpc.yppasswdd */
-	yppasswd.newpw.pw_name	 = strdup(pw->pw_name);
-	if (!yppasswd.newpw.pw_name) {
+	yppw.newpw.pw_name	 = strdup(pw->pw_name);
+	if (!yppw.newpw.pw_name) {
 		err(1, "strdup");
 		/*NOTREACHED*/
 	}
-	yppasswd.newpw.pw_passwd = strdup(pw->pw_passwd);
-	if (!yppasswd.newpw.pw_passwd) {
+	yppw.newpw.pw_passwd = strdup(pw->pw_passwd);
+	if (!yppw.newpw.pw_passwd) {
 		err(1, "strdup");
 		/*NOTREACHED*/
 	}
-	yppasswd.newpw.pw_uid 	 = pw->pw_uid;
-	yppasswd.newpw.pw_gid	 = pw->pw_gid;
-	yppasswd.newpw.pw_gecos  = strdup(pw->pw_gecos);
-	if (!yppasswd.newpw.pw_gecos) {
+	yppw.newpw.pw_uid 	 = pw->pw_uid;
+	yppw.newpw.pw_gid	 = pw->pw_gid;
+	yppw.newpw.pw_gecos	 = strdup(pw->pw_gecos);
+	if (!yppw.newpw.pw_gecos) {
 		err(1, "strdup");
 		/*NOTREACHED*/
 	}
-	yppasswd.newpw.pw_dir	 = strdup(pw->pw_dir);
-	if (!yppasswd.newpw.pw_dir) {
+	yppw.newpw.pw_dir	 = strdup(pw->pw_dir);
+	if (!yppw.newpw.pw_dir) {
 		err(1, "strdup");
 		/*NOTREACHED*/
 	}
-	yppasswd.newpw.pw_shell	 = strdup(pw->pw_shell);
-	if (!yppasswd.newpw.pw_shell) {
+	yppw.newpw.pw_shell	 = strdup(pw->pw_shell);
+	if (!yppw.newpw.pw_shell) {
 		err(1, "strdup");
 		/*NOTREACHED*/
 	}
@@ -197,7 +196,7 @@
 	tv.tv_sec = 5;
 	tv.tv_usec = 0;
 	r = clnt_call(client, YPPASSWDPROC_UPDATE,
-	    xdr_yppasswd, &yppasswd, xdr_int, &status, tv);
+	    xdr_yppasswd, &yppw, xdr_int, &status, tv);
 	if (r) {
 		warnx("rpc to yppasswdd failed.");
 		return (1);
@@ -211,10 +210,10 @@
 }
 
 void
-yppw_error(const char *name, int err, int eval)
+yppw_error(const char *name, int yperr, int eval)
 {
 
-	if (err) {
+	if (yperr) {
 		if (name)
 			warn("%s", name);
 		else

Index: src/usr.bin/chpass/table.c
diff -u src/usr.bin/chpass/table.c:1.6 src/usr.bin/chpass/table.c:1.7
--- src/usr.bin/chpass/table.c:1.6	Thu Aug  7 11:13:19 2003
+++ src/usr.bin/chpass/table.c	Sat Apr 11 12:10:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: table.c,v 1.6 2003/08/07 11:13:19 agc Exp $	*/
+/*	$NetBSD: table.c,v 1.7 2009/04/11 12:10:02 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)table.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: table.c,v 1.6 2003/08/07 11:13:19 agc Exp $");
+__RCSID("$NetBSD: table.c,v 1.7 2009/04/11 12:10:02 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -46,18 +46,18 @@
 char e2[] = ":,";
 
 ENTRY list[] = {
-	{ "login",		p_login,  1,   5, e1,   },
-	{ "password",		p_passwd, 1,   8, e1,   },
-	{ "uid",		p_uid,    1,   3, e1,   },
-	{ "gid",		p_gid,    1,   3, e1,   },
-	{ "class",		p_class,  1,   5, e1,   },
-	{ "change",		p_change, 1,   6, NULL, },
-	{ "expire",		p_expire, 1,   6, NULL, },
+	{ "login",		p_login,  1,   5, e1,   NULL },
+	{ "password",		p_passwd, 1,   8, e1,   NULL },
+	{ "uid",		p_uid,    1,   3, e1,   NULL },
+	{ "gid",		p_gid,    1,   3, e1,   NULL },
+	{ "class",		p_class,  1,   5, e1,   NULL },
+	{ "change",		p_change, 1,   6, NULL, NULL },
+	{ "expire",		p_expire, 1,   6, NULL, NULL },
 	{ "full name",		p_gecos,  0,   9, e2,   ""},
 	{ "office phone",	p_gecos,  0,  12, e2,   ""},
 	{ "home phone",		p_gecos,  0,  10, e2,   ""},
 	{ "location",		p_gecos,  0,   8, e2,   ""},
-	{ "home directory",	p_hdir,   1,  14, e1,   },
-	{ "shell",		p_shell,  0,   5, e1,   },
-	{ NULL, 0, },
+	{ "home directory",	p_hdir,   1,  14, e1,   NULL },
+	{ "shell",		p_shell,  0,   5, e1,   NULL },
+	{ NULL,			NULL,     0,   0, NULL, NULL },
 };

Reply via email to