[Pkg-shadow-commits] r2071 - in upstream/trunk: . lib
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Mon May 26 09:39:30 UTC 2008
Author: nekral-guest
Date: 2008-05-26 09:39:29 +0000 (Mon, 26 May 2008)
New Revision: 2071
Modified:
upstream/trunk/ChangeLog
upstream/trunk/lib/sgetspent.c
Log:
* lib/sgetspent.c: Add brackets and parenthesis.
* lib/sgetspent.c: Avoid assignments in comparisons.
* lib/sgetspent.c: Avoid implicit conversion of pointers / chars to booleans.
* lib/sgetspent.c: Avoid multi-statements lines.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-05-26 09:22:44 UTC (rev 2070)
+++ upstream/trunk/ChangeLog 2008-05-26 09:39:29 UTC (rev 2071)
@@ -1,5 +1,13 @@
2008-05-26 Nicolas François <nicolas.francois at centraliens.net>
+ * lib/sgetspent.c: Add brackets and parenthesis.
+ * lib/sgetspent.c: Avoid assignments in comparisons.
+ * lib/sgetspent.c: Avoid implicit conversion of pointers / chars
+ to booleans.
+ * lib/sgetspent.c: Avoid multi-statements lines.
+
+2008-05-26 Nicolas François <nicolas.francois at centraliens.net>
+
* lib/sgetpwent.c: Avoid implicit conversion of pointers / chars to
booleans.
* lib/sgetpwent.c: Add brackets and parenthesis.
Modified: upstream/trunk/lib/sgetspent.c
===================================================================
--- upstream/trunk/lib/sgetspent.c 2008-05-26 09:22:44 UTC (rev 2070)
+++ upstream/trunk/lib/sgetspent.c 2008-05-26 09:39:29 UTC (rev 2071)
@@ -56,32 +56,41 @@
* have to do that to our private copy.
*/
- if (strlen (string) >= sizeof spwbuf)
+ if (strlen (string) >= sizeof spwbuf) {
return 0; /* fail if too long */
+ }
strcpy (spwbuf, string);
- if ((cp = strrchr (spwbuf, '\n')))
+ cp = strrchr (spwbuf, '\n');
+ if (NULL != cp) {
*cp = '\0';
+ }
/*
* Tokenize the string into colon separated fields. Allow up to
* FIELDS different fields.
*/
- for (cp = spwbuf, i = 0; *cp && i < FIELDS; i++) {
+ for (cp = spwbuf, i = 0; ('\0' != *cp) && (i < FIELDS); i++) {
fields[i] = cp;
- while (*cp && *cp != ':')
+ while (('\0' != *cp) && (':' != *cp)) {
cp++;
+ }
- if (*cp)
- *cp++ = '\0';
+ if ('\0' != *cp) {
+ *cp = '\0';
+ cp++;
+ }
}
- if (i == (FIELDS - 1))
+ if (i == (FIELDS - 1)) {
fields[i++] = cp;
+ }
- if ((cp && *cp) || (i != FIELDS && i != OFIELDS))
+ if ( ((NULL != cp) && ('\0' != *cp)) ||
+ ((i != FIELDS) && (i != OFIELDS)) ) {
return 0;
+ }
/*
* Start populating the structure. The fields are all in
@@ -97,28 +106,37 @@
* incorrectly formatted number.
*/
- if ((spwd.sp_lstchg = strtol (fields[2], &cpp, 10)) == 0 && *cpp) {
+ spwd.sp_lstchg = strtol (fields[2], &cpp, 10);
+ /* FIXME: (0 == spwd.sp_lstchg) does not look correct */
+ if ((0 == spwd.sp_lstchg) && ('\0' != *cpp)) {
return 0;
- } else if (fields[2][0] == '\0')
+ } else if (fields[2][0] == '\0') {
spwd.sp_lstchg = -1;
+ }
/*
* Get the minimum period between password changes.
*/
- if ((spwd.sp_min = strtol (fields[3], &cpp, 10)) == 0 && *cpp) {
+ spwd.sp_min = strtol (fields[3], &cpp, 10);
+ /* FIXME: (0 == spwd.sp_min) does not look correct */
+ if ((0 == spwd.sp_min) && ('\0' != *cpp)) {
return 0;
- } else if (fields[3][0] == '\0')
+ } else if (fields[3][0] == '\0') {
spwd.sp_min = -1;
+ }
/*
* Get the maximum number of days a password is valid.
*/
- if ((spwd.sp_max = strtol (fields[4], &cpp, 10)) == 0 && *cpp) {
+ spwd.sp_max = strtol (fields[4], &cpp, 10);
+ /* FIXME: (0 == spwd.sp_max) does not look correct */
+ if ((0 == spwd.sp_max) && ('\0' != *cpp)) {
return 0;
- } else if (fields[4][0] == '\0')
+ } else if (fields[4][0] == '\0') {
spwd.sp_max = -1;
+ }
/*
* If there are only OFIELDS fields (this is a SVR3.2 /etc/shadow
@@ -126,8 +144,10 @@
*/
if (i == OFIELDS) {
- spwd.sp_warn = spwd.sp_inact = spwd.sp_expire =
- spwd.sp_flag = -1;
+ spwd.sp_warn = -1;
+ spwd.sp_inact = -1;
+ spwd.sp_expire = -1;
+ spwd.sp_flag = -1;
return &spwd;
}
@@ -136,40 +156,53 @@
* Get the number of days of password expiry warning.
*/
- if ((spwd.sp_warn = strtol (fields[5], &cpp, 10)) == 0 && *cpp) {
+ spwd.sp_warn = strtol (fields[5], &cpp, 10);
+ /* FIXME: (0 == spwd.sp_warn) does not look correct */
+ if ((0 == spwd.sp_warn) && ('\0' != *cpp)) {
return 0;
- } else if (fields[5][0] == '\0')
+ } else if (fields[5][0] == '\0') {
spwd.sp_warn = -1;
+ }
/*
* Get the number of days of inactivity before an account is
* disabled.
*/
- if ((spwd.sp_inact = strtol (fields[6], &cpp, 10)) == 0 && *cpp) {
+ spwd.sp_inact = strtol (fields[6], &cpp, 10);
+ /* FIXME: (0 == spwd.sp_inact) does not look correct */
+ if ((0 == spwd.sp_inact) && ('\0' != *cpp)) {
return 0;
- } else if (fields[6][0] == '\0')
+ } else if (fields[6][0] == '\0') {
spwd.sp_inact = -1;
+ }
/*
* Get the number of days after the epoch before the account is
* set to expire.
*/
- if ((spwd.sp_expire = strtol (fields[7], &cpp, 10)) == 0 && *cpp) {
+ spwd.sp_expire = strtol (fields[7], &cpp, 10);
+ /* FIXME: (0 == spwd.sp_expire) does not look correct */
+ if ((0 == spwd.sp_expire) && ('\0' != *cpp)) {
return 0;
- } else if (fields[7][0] == '\0')
+ } else if (fields[7][0] == '\0') {
spwd.sp_expire = -1;
+ }
/*
* This field is reserved for future use. But it isn't supposed
* to have anything other than a valid integer in it.
*/
- if ((spwd.sp_flag = strtol (fields[8], &cpp, 10)) == 0 && *cpp) {
+ spwd.sp_flag = strtol (fields[8], &cpp, 10);
+ /* FIXME: (0 == spwd.sp_flag) does not look correct */
+ if ((0 == spwd.sp_flag) && ('\0' != *cpp)) {
return 0;
- } else if (fields[8][0] == '\0')
+ } else if (fields[8][0] == '\0') {
spwd.sp_flag = -1;
+ }
return (&spwd);
}
+
More information about the Pkg-shadow-commits
mailing list