[Pkg-shadow-commits] r2057 - in upstream/trunk: . lib
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Mon May 26 08:40:07 UTC 2008
Author: nekral-guest
Date: 2008-05-26 08:40:04 +0000 (Mon, 26 May 2008)
New Revision: 2057
Modified:
upstream/trunk/ChangeLog
upstream/trunk/lib/gshadow.c
Log:
* lib/gshadow.c: nis_used and nis_bound are booleans.
* lib/gshadow.c: Avoid implicit conversion of pointers / integers to booleans.
* lib/gshadow.c: Avoid assignments in comparisons.
* lib/gshadow.c: Add brackets.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-05-26 08:35:13 UTC (rev 2056)
+++ upstream/trunk/ChangeLog 2008-05-26 08:40:04 UTC (rev 2057)
@@ -1,13 +1,21 @@
2008-05-26 Nicolas François <nicolas.francois at centraliens.net>
+ * lib/gshadow.c: nis_used and nis_bound are booleans.
+ * lib/gshadow.c: Avoid implicit conversion of pointers / integers
+ to booleans.
+ * lib/gshadow.c: Avoid assignments in comparisons.
+ * lib/gshadow.c: Add brackets.
+
+2008-05-26 Nicolas François <nicolas.francois at centraliens.net>
+
* lib/groupio.c: The changed, isopen, locked, and readonly fields
of the db are booleans.
* lib/groupio.h: Add protection against multiple inclusion.
2008-05-26 Nicolas François <nicolas.francois at centraliens.net>
- * lib/sgetgrent.c: implicit conversion of pointers / chars to
- booleans.
+ * lib/sgetgrent.c: Avoid implicit conversion of pointers / chars
+ to booleans.
* lib/sgetgrent.c: Avoid assignments in comparisons.
* lib/sgetgrent.c: Add brackets.
Modified: upstream/trunk/lib/gshadow.c
===================================================================
--- upstream/trunk/lib/gshadow.c 2008-05-26 08:35:13 UTC (rev 2056)
+++ upstream/trunk/lib/gshadow.c 2008-05-26 08:40:04 UTC (rev 2057)
@@ -51,10 +51,10 @@
#define FIELDS 4
#ifdef USE_NIS
-static int nis_used;
+static bool nis_used;
static int nis_ignore;
static enum { native, start, middle, native2 } nis_state;
-static int nis_bound;
+static bool nis_bound;
static char *nis_domain;
static char *nis_key;
static int nis_keylen;
@@ -74,8 +74,9 @@
{
nis_ignore = !flag;
- if (nis_ignore)
- nis_used = 0;
+ if (nis_ignore) {
+ nis_used = false;
+ }
}
/*
@@ -87,7 +88,7 @@
if (yp_get_default_domain (&nis_domain))
return -1;
- nis_bound = 1;
+ nis_bound = true;
return 0;
}
#endif
@@ -120,16 +121,18 @@
#ifdef USE_NIS
nis_state = native;
#endif
- if (shadow)
+ if (NULL != shadow) {
rewind (shadow);
- else
+ } else {
shadow = fopen (SGROUP_FILE, "r");
+ }
}
void endsgent (void)
{
- if (shadow)
+ if (NULL != shadow) {
(void) fclose (shadow);
+ }
shadow = (FILE *) 0;
}
@@ -143,18 +146,22 @@
strncpy (sgrbuf, string, (int) sizeof sgrbuf - 1);
sgrbuf[sizeof sgrbuf - 1] = '\0';
- if ((cp = strrchr (sgrbuf, '\n')))
+ cp = strrchr (sgrbuf, '\n');
+ if (NULL != cp) {
*cp = '\0';
+ }
/*
* There should be exactly 4 colon separated fields. Find
* all 4 of them and save the starting addresses in fields[].
*/
- for (cp = sgrbuf, i = 0; i < FIELDS && cp; i++) {
+ for (cp = sgrbuf, i = 0; (i < FIELDS) && (NULL != cp); i++) {
fields[i] = cp;
- if ((cp = strchr (cp, ':')))
+ cp = strchr (cp, ':');
+ if (NULL != cp) {
*cp++ = '\0';
+ }
}
/*
@@ -162,24 +169,25 @@
* the line is invalid.
*/
- if (cp || i != FIELDS)
+ if ((NULL != cp) || (i != FIELDS))
#ifdef USE_NIS
- if (!IS_NISCHAR (fields[0][0]))
+ if (!IS_NISCHAR (fields[0][0])) {
return 0;
- else
- nis_used = 1;
+ } else {
+ nis_used = true;
+ }
#else
return 0;
#endif
sgroup.sg_name = fields[0];
sgroup.sg_passwd = fields[1];
- if (nadmins) {
+ if (0 != nadmins) {
nadmins = 0;
free (admins);
admins = NULL;
}
- if (nmembers) {
+ if (0 != nmembers) {
nmembers = 0;
free (members);
members = NULL;
@@ -202,8 +210,9 @@
char buf[sizeof sgrbuf];
char *cp;
- if (!fp)
+ if (NULL == fp) {
return (0);
+ }
#ifdef USE_NIS
while (fgetsx (buf, sizeof buf, fp) != (char *) 0)
@@ -211,11 +220,14 @@
if (fgetsx (buf, sizeof buf, fp) != (char *) 0)
#endif
{
- if ((cp = strchr (buf, '\n')))
+ cp = strchr (buf, '\n');
+ if (NULL != cp) {
*cp = '\0';
+ }
#ifdef USE_NIS
- if (nis_ignore && IS_NISCHAR (buf[0]))
+ if ((0 != nis_ignore) && IS_NISCHAR (buf[0])) {
continue;
+ }
#endif
return (sgetsgent (buf));
}
@@ -233,8 +245,9 @@
struct sgrp *val;
char buf[BUFSIZ];
#endif
- if (!shadow)
+ if (NULL == shadow) {
setsgent ();
+ }
#ifdef USE_NIS
again:
@@ -249,8 +262,10 @@
* NULL right away if there is none.
*/
- if (!(val = fgetsgent (shadow)))
+ val = fgetsgent (shadow);
+ if (NULL == val) {
return 0;
+ }
/*
* If this entry began with a NIS escape character, we have
@@ -259,10 +274,11 @@
*/
if (IS_NISCHAR (val->sg_name[0])) {
- if (val->sg_name[1])
+ if ('\0' != val->sg_name[1]) {
nis_1_group = 1;
- else
+ } else {
nis_state = start;
+ }
}
/*
@@ -287,7 +303,7 @@
return 0;
} else {
- if (nis_bound == 0) {
+ if (!nis_bound) {
if (bind_nis ()) {
nis_state = native2;
goto again;
@@ -339,8 +355,9 @@
* Search the gshadow.byname map for this group.
*/
- if (!nis_bound)
+ if (!nis_bound) {
bind_nis ();
+ }
if (nis_bound) {
char *cp;
@@ -348,11 +365,14 @@
if (yp_match (nis_domain, "gshadow.byname", name,
strlen (name), &nis_val,
&nis_vallen) == 0) {
- if (cp = strchr (nis_val, '\n'))
+ cp = strchr (nis_val, '\n');
+ if (NULL != cp) {
*cp = '\0';
+ }
nis_state = middle;
- if (sgrp = sgetsgent (nis_val)) {
+ sgrp = sgetsgent (nis_val);
+ if (NULL != sgrp) {
strcpy (save_name, sgrp->sg_name);
nis_key = save_name;
nis_keylen = strlen (save_name);
@@ -366,19 +386,18 @@
#ifdef USE_NIS
if (nis_used) {
nis_ignore++;
- nis_disabled++;
+ nis_disabled = true;
}
#endif
while ((sgrp = getsgent ()) != (struct sgrp *) 0) {
- if (strcmp (name, sgrp->sg_name) == 0)
+ if (strcmp (name, sgrp->sg_name) == 0) {
break;
+ }
}
#ifdef USE_NIS
nis_ignore--;
#endif
- if (sgrp)
- return sgrp;
- return (0);
+ return sgrp;
}
/*
@@ -395,19 +414,23 @@
int i;
size_t size;
- if (!fp || !sgrp)
+ if ((NULL == fp) || (NULL == sgrp)) {
return -1;
+ }
/* calculate the required buffer size */
size = strlen (sgrp->sg_name) + strlen (sgrp->sg_passwd) + 10;
- for (i = 0; sgrp->sg_adm && sgrp->sg_adm[i]; i++)
+ for (i = 0; (NULL != sgrp->sg_adm) && (NULL != sgrp->sg_adm[i]); i++) {
size += strlen (sgrp->sg_adm[i]) + 1;
- for (i = 0; sgrp->sg_mem && sgrp->sg_mem[i]; i++)
+ }
+ for (i = 0; (NULL != sgrp->sg_mem) && (NULL != sgrp->sg_mem[i]); i++) {
size += strlen (sgrp->sg_mem[i]) + 1;
+ }
buf = malloc (size);
- if (!buf)
+ if (NULL == buf) {
return -1;
+ }
cp = buf;
/*
@@ -427,9 +450,10 @@
* with a ",".
*/
- for (i = 0; sgrp->sg_adm[i]; i++) {
- if (i > 0)
+ for (i = 0; NULL != sgrp->sg_adm[i]; i++) {
+ if (i > 0) {
*cp++ = ',';
+ }
strcpy (cp, sgrp->sg_adm[i]);
cp += strlen (cp);
@@ -440,9 +464,10 @@
* Now do likewise with the group members.
*/
- for (i = 0; sgrp->sg_mem[i]; i++) {
- if (i > 0)
+ for (i = 0; NULL != sgrp->sg_mem[i]; i++) {
+ if (i > 0) {
*cp++ = ',';
+ }
strcpy (cp, sgrp->sg_mem[i]);
cp += strlen (cp);
More information about the Pkg-shadow-commits
mailing list