Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/user Ensure that a consistent coding style is used.
details: https://anonhg.NetBSD.org/src/rev/77fa22d63826
branches: trunk
changeset: 584459:77fa22d63826
user: agc <agc%NetBSD.org@localhost>
date: Sun Sep 18 21:41:26 2005 +0000
description:
Ensure that a consistent coding style is used.
s/1/EXIT_FAILURE/
diffstat:
usr.sbin/user/user.c | 76 +++++++++++++++++++++++++++++----------------------
1 files changed, 43 insertions(+), 33 deletions(-)
diffs (210 lines):
diff -r 47fc9e9649e6 -r 77fa22d63826 usr.sbin/user/user.c
--- a/usr.sbin/user/user.c Sun Sep 18 19:47:28 2005 +0000
+++ b/usr.sbin/user/user.c Sun Sep 18 21:41:26 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.92 2005/09/18 14:15:53 christos Exp $ */
+/* $NetBSD: user.c,v 1.93 2005/09/18 21:41:26 agc Exp $ */
/*
* Copyright (c) 1999 Alistair G. Crooks. All rights reserved.
@@ -35,7 +35,7 @@
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1999 \
The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: user.c,v 1.92 2005/09/18 14:15:53 christos Exp $");
+__RCSID("$NetBSD: user.c,v 1.93 2005/09/18 21:41:26 agc Exp $");
#endif
#include <sys/types.h>
@@ -206,17 +206,18 @@
static char *
skipspace(char *s)
{
- for (; *s && isspace((unsigned char)*s) ; s++)
- continue;
+ for (; *s && isspace((unsigned char)*s) ; s++) {
+ }
return s;
}
static int
check_numeric(const char *val, const char *name)
{
- if (!is_number(val))
+ if (!is_number(val)) {
errx(EXIT_FAILURE, "When using [-%c %s], "
"the %s must be numeric", *name, name, name);
+ }
return atoi(val);
}
@@ -665,9 +666,10 @@
strncmp(groups[i], buf, (unsigned) entc) == 0) {
if ((nc = snprintf(&buf[cc - 1],
sizeof(buf) - cc + 1, "%s%s\n",
- (buf[cc - 2] == ':') ? "" : ",", user)) < 0)
+ (buf[cc - 2] == ':') ? "" : ",", user)) < 0) {
warnx("Warning: group `%s' "
"entry too long", groups[i]);
+ }
cc += nc - 1;
}
}
@@ -701,9 +703,9 @@
unsigned char *cp;
/* First character of a login name cannot be '-'. */
- if (*login_name == '-')
+ if (*login_name == '-') {
return 0;
-
+ }
if (strlen(login_name) >= LOGIN_NAME_MAX) {
return 0;
}
@@ -1001,8 +1003,9 @@
{
login_cap_t *lc;
- if (class == NULL || *class == '\0')
+ if (class == NULL || *class == '\0') {
return 1;
+ }
/*
* Check if /etc/login.conf exists. login_getclass() will
* return 1 due to it not existing, so not informing the
@@ -1036,14 +1039,10 @@
(void)memset(&tm, 0, sizeof(tm));
if (strptime(s, "%c", &tm) != NULL) {
*tp = mktime(&tm);
- if (*tp == -1)
- return 0;
- return 1;
+ return (*tp == -1) ? 0 : 1;
} else if (strptime(s, "%B %d %Y", &tm) != NULL) {
*tp = mktime(&tm);
- if (*tp == -1)
- return 0;
- return 1;
+ return (*tp == -1) ? 0 : 1;
} else {
errno = 0;
*tp = val = strtol(s, &ep, 10);
@@ -1051,8 +1050,9 @@
*tp = 0;
return 0;
}
- if (*tp != val)
+ if (*tp != val) {
return 0;
+ }
}
}
return 1;
@@ -1472,12 +1472,14 @@
* and just change the password.
*/
if (asprintf(&locked_pwd, "%s%s",
- LOCKED, up->u_password) == -1)
+ LOCKED, up->u_password) == -1) {
err(EXIT_FAILURE,
"asprintf failed");
+ }
pwp->pw_passwd = locked_pwd;
- } else
+ } else {
pwp->pw_passwd = up->u_password;
+ }
}
}
@@ -1485,20 +1487,22 @@
if (up->u_locked == LOCK) {
/* check to see account if already locked. */
if ((locked_pwd = strstr(pwp->pw_passwd, LOCKED))
- != NULL)
+ != NULL) {
warnx("Account is already locked");
- else {
+ } else {
if (asprintf(&locked_pwd, "%s%s", LOCKED,
- pwp->pw_passwd) == -1)
+ pwp->pw_passwd) == -1) {
err(EXIT_FAILURE, "asprintf failed");
+ }
pwp->pw_passwd = locked_pwd;
}
} else if (up->u_locked == UNLOCK) {
if ((locked_pwd = strstr(pwp->pw_passwd, LOCKED))
- == NULL)
+ == NULL) {
warnx("Account '%s' is not locked", login_name);
- else
+ } else {
pwp->pw_passwd = locked_pwd + strlen(LOCKED);
+ }
}
if (up->u_flags & F_UID) {
@@ -1552,12 +1556,15 @@
pwp->pw_expire = 0;
}
}
- if (up->u_flags & F_COMMENT)
+ if (up->u_flags & F_COMMENT) {
pwp->pw_gecos = up->u_comment;
- if (up->u_flags & F_HOMEDIR)
+ }
+ if (up->u_flags & F_HOMEDIR) {
pwp->pw_dir = up->u_home;
- if (up->u_flags & F_SHELL)
+ }
+ if (up->u_flags & F_SHELL) {
pwp->pw_shell = up->u_shell;
+ }
#ifdef EXTENSIONS
if (up->u_flags & F_CLASS) {
if (!valid_class(up->u_class)) {
@@ -1952,14 +1959,15 @@
u.u_flags |= F_COMMENT;
break;
case 'C':
- if (strcasecmp(optarg, "yes") == 0)
+ if (strcasecmp(optarg, "yes") == 0) {
u.u_locked = LOCK;
- else if (strcasecmp(optarg, "no") == 0)
+ } else if (strcasecmp(optarg, "no") == 0) {
u.u_locked = UNLOCK;
- else
+ } else {
/* No idea. */
- errx(1, "Please type 'yes' or 'no'");
-
+ errx(EXIT_FAILURE,
+ "Please type 'yes' or 'no'");
+ }
break;
case 'F':
memsave(&u.u_inactive, "-1", strlen("-1"));
@@ -2112,8 +2120,9 @@
warnx("No such user `%s'", *argv);
return EXIT_FAILURE;
}
- if (rmhome)
+ if (rmhome) {
(void)removehomedir(pwp->pw_name, pwp->pw_uid, pwp->pw_dir);
+ }
if (u.u_preserve) {
u.u_flags |= F_SHELL;
memsave(&u.u_shell, NOLOGIN, strlen(NOLOGIN));
@@ -2431,8 +2440,9 @@
(void)printf("members\t");
for (cpp = grp->gr_mem ; *cpp ; cpp++) {
(void)printf("%s", *cpp);
- if (*(cpp + 1))
+ if (*(cpp + 1)) {
(void) printf(", ");
+ }
}
(void)fputc('\n', stdout);
return EXIT_SUCCESS;
Home |
Main Index |
Thread Index |
Old Index