summaryrefslogtreecommitdiffstats
path: root/usr.bin/chpass
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2002-03-30 13:44:45 +0000
committerdwmalone <dwmalone@FreeBSD.org>2002-03-30 13:44:45 +0000
commit63e149f8f69bbc0f9afbc2596a3a2cc06c2f4f57 (patch)
tree72761bb8ca8b3722b87ab2628eba1492a503c85f /usr.bin/chpass
parent631238220a5b5f952606b7e8cdd805b95ea1c17a (diff)
downloadFreeBSD-src-63e149f8f69bbc0f9afbc2596a3a2cc06c2f4f57.zip
FreeBSD-src-63e149f8f69bbc0f9afbc2596a3a2cc06c2f4f57.tar.gz
Minor post warns stuff.
1) Fix up vendor IDs for files I'm touching and put FBSDID in the right place. 2) Cast return value of snprintf to size_t rather than casting sizeof() to an int, 'cos we know snprintf returns a non-genative number. 3) Avoid 'char *blank = "";' by just strduping. This could be bad sometimes, but all these variables usually point at malloced memory so this makes them always point at malloced memory.
Diffstat (limited to 'usr.bin/chpass')
-rw-r--r--usr.bin/chpass/edit.c8
-rw-r--r--usr.bin/chpass/field.c18
-rw-r--r--usr.bin/chpass/pw_yp.c7
3 files changed, 14 insertions, 19 deletions
diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c
index e671d58..0ec0f10 100644
--- a/usr.bin/chpass/edit.c
+++ b/usr.bin/chpass/edit.c
@@ -31,9 +31,11 @@
* SUCH DAMAGE.
*/
+#if 0
#ifndef lint
-static const char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94";
+static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
+#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -252,12 +254,12 @@ bad: (void)fclose(fp);
while ((len = strlen(pw->pw_gecos)) && pw->pw_gecos[len - 1] == ',')
pw->pw_gecos[len - 1] = '\0';
- if (snprintf(buf, sizeof(buf),
+ if ((size_t)snprintf(buf, sizeof(buf),
"%s:%s:%lu:%lu:%s:%ld:%ld:%s:%s:%s",
pw->pw_name, pw->pw_passwd, (unsigned long)pw->pw_uid,
(unsigned long)pw->pw_gid, pw->pw_class, (long)pw->pw_change,
(long)pw->pw_expire, pw->pw_gecos, pw->pw_dir,
- pw->pw_shell) >= (int)sizeof(buf)) {
+ pw->pw_shell) >= sizeof(buf)) {
warnx("entries too long");
free(p);
return (0);
diff --git a/usr.bin/chpass/field.c b/usr.bin/chpass/field.c
index 264cf08..0e2770b 100644
--- a/usr.bin/chpass/field.c
+++ b/usr.bin/chpass/field.c
@@ -31,9 +31,11 @@
* SUCH DAMAGE.
*/
+#if 0
#ifndef lint
-static const char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94";
+static char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94";
#endif /* not lint */
+#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -54,8 +56,6 @@ __FBSDID("$FreeBSD$");
#include "chpass.h"
#include "pathnames.h"
-static char blank[] = "";
-
/* ARGSUSED */
int
p_login(char *p, struct passwd *pw, ENTRY *ep __unused)
@@ -86,9 +86,7 @@ p_login(char *p, struct passwd *pw, ENTRY *ep __unused)
int
p_passwd(char *p, struct passwd *pw, ENTRY *ep __unused)
{
- if (!*p)
- pw->pw_passwd = blank; /* "NOLOGIN"; */
- else if (!(pw->pw_passwd = strdup(p))) {
+ if (!(pw->pw_passwd = strdup(p))) {
warnx("can't save password entry");
return (1);
}
@@ -155,9 +153,7 @@ p_gid(char *p, struct passwd *pw, ENTRY *ep __unused)
int
p_class(char *p, struct passwd *pw, ENTRY *ep __unused)
{
- if (!*p)
- pw->pw_class = blank;
- else if (!(pw->pw_class = strdup(p))) {
+ if (!(pw->pw_class = strdup(p))) {
warnx("can't save entry");
return (1);
}
@@ -189,9 +185,7 @@ p_expire(char *p, struct passwd *pw, ENTRY *ep __unused)
int
p_gecos(char *p, struct passwd *pw __unused, ENTRY *ep __unused)
{
- if (!*p)
- ep->save = blank;
- else if (!(ep->save = strdup(p))) {
+ if (!(ep->save = strdup(p))) {
warnx("can't save entry");
return (1);
}
diff --git a/usr.bin/chpass/pw_yp.c b/usr.bin/chpass/pw_yp.c
index 90fa9e0..30e2f77 100644
--- a/usr.bin/chpass/pw_yp.c
+++ b/usr.bin/chpass/pw_yp.c
@@ -81,7 +81,6 @@ static HASHINFO openinfo = {
static char passwdbyname[] = "passwd.byname";
static char localhost[] = "localhost";
-static char blank[] = "";
int force_old = 0;
int _use_yp = 0;
@@ -437,8 +436,8 @@ yp_submit(struct passwd *pw)
master_yppasswd.newpw.pw_shell = strdup(pw->pw_shell);
master_yppasswd.newpw.pw_class = pw->pw_class != NULL
? strdup(pw->pw_class)
- : blank;
- master_yppasswd.oldpass = blank; /* not really needed */
+ : strdup("");
+ master_yppasswd.oldpass = strdup(""); /* not really needed */
master_yppasswd.domain = yp_domain;
} else {
yppasswd.newpw.pw_passwd = strdup(pw->pw_passwd);
@@ -448,7 +447,7 @@ yp_submit(struct passwd *pw)
yppasswd.newpw.pw_gecos = strdup(pw->pw_gecos);
yppasswd.newpw.pw_dir = strdup(pw->pw_dir);
yppasswd.newpw.pw_shell = strdup(pw->pw_shell);
- yppasswd.oldpass = blank;
+ yppasswd.oldpass = strdup("");
}
/* Get the user's password for authentication purposes. */
OpenPOWER on IntegriCloud