* 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> 2008-08-26 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/mail.c: Added brackets and parenthesis. * libmisc/mail.c: Added brackets and parenthesis.

View File

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

View File

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

View File

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