* lib/groupmem.c, lib/pwmem.c, lib/shadowmem.c: Added brackets and

parenthesis.
	* lib/groupmem.c, lib/pwmem.c, lib/shadowmem.c: Avoid assignments
	in comparisons.
This commit is contained in:
nekral-guest 2008-08-30 18:32:19 +00:00
parent cf4aea18b4
commit 7109072b8f
4 changed files with 51 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2008-08-26 Nicolas François <nicolas.francois@centraliens.net>
* lib/groupmem.c, lib/pwmem.c, lib/shadowmem.c: Added brackets and
parenthesis.
* lib/groupmem.c, lib/pwmem.c, lib/shadowmem.c: Avoid assignments
in comparisons.
2008-08-26 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/mail.c: Added brackets and parenthesis.

View File

@ -44,24 +44,34 @@ struct group *__gr_dup (const struct group *grent)
struct group *gr;
int i;
if (!(gr = (struct group *) malloc (sizeof *gr)))
gr = (struct group *) malloc (sizeof *gr);
if (NULL == gr) {
return NULL;
}
*gr = *grent;
if (!(gr->gr_name = strdup (grent->gr_name)))
gr->gr_name = strdup (grent->gr_name);
if (NULL == gr->gr_name) {
return NULL;
if (!(gr->gr_passwd = strdup (grent->gr_passwd)))
}
gr->gr_passwd = strdup (grent->gr_passwd);
if (NULL == gr->gr_passwd) {
return NULL;
}
for (i = 0; grent->gr_mem[i]; i++);
gr->gr_mem = (char **) malloc ((i + 1) * sizeof (char *));
if (!gr->gr_mem)
if (NULL == gr->gr_mem) {
return NULL;
}
for (i = 0; grent->gr_mem[i]; i++) {
gr->gr_mem[i] = strdup (grent->gr_mem[i]);
if (!gr->gr_mem[i])
if (NULL == gr->gr_mem[i]) {
return NULL;
}
}
gr->gr_mem[i] = NULL;
return gr;
}

View File

@ -44,19 +44,32 @@ struct passwd *__pw_dup (const struct passwd *pwent)
{
struct passwd *pw;
if (!(pw = (struct passwd *) malloc (sizeof *pw)))
pw = (struct passwd *) malloc (sizeof *pw);
if (NULL == pw) {
return NULL;
}
*pw = *pwent;
if (!(pw->pw_name = strdup (pwent->pw_name)))
pw->pw_name = strdup (pwent->pw_name);
if (NULL == pw->pw_name) {
return NULL;
if (!(pw->pw_passwd = strdup (pwent->pw_passwd)))
}
pw->pw_passwd = strdup (pwent->pw_passwd);
if (NULL == pw->pw_passwd) {
return NULL;
if (!(pw->pw_gecos = strdup (pwent->pw_gecos)))
}
pw->pw_gecos = strdup (pwent->pw_gecos);
if (NULL == pw->pw_gecos) {
return NULL;
if (!(pw->pw_dir = strdup (pwent->pw_dir)))
}
pw->pw_dir = strdup (pwent->pw_dir);
if (NULL == pw->pw_dir) {
return NULL;
if (!(pw->pw_shell = strdup (pwent->pw_shell)))
}
pw->pw_shell = strdup (pwent->pw_shell);
if (NULL == pw->pw_shell) {
return NULL;
}
return pw;
}

View File

@ -45,13 +45,20 @@ struct spwd *__spw_dup (const struct spwd *spent)
{
struct spwd *sp;
if (!(sp = (struct spwd *) malloc (sizeof *sp)))
sp = (struct spwd *) malloc (sizeof *sp);
if (NULL == sp) {
return NULL;
}
*sp = *spent;
if (!(sp->sp_namp = strdup (spent->sp_namp)))
sp->sp_namp = strdup (spent->sp_namp);
if (NULL == sp->sp_namp) {
return NULL;
if (!(sp->sp_pwdp = strdup (spent->sp_pwdp)))
}
sp->sp_pwdp = strdup (spent->sp_pwdp);
if (NULL == sp->sp_pwdp) {
return NULL;
}
return sp;
}