From 7109072b8fe65acda2dcc72d99a441617fec0b4c Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sat, 30 Aug 2008 18:32:19 +0000 Subject: [PATCH] * 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. --- ChangeLog | 7 +++++++ lib/groupmem.c | 20 +++++++++++++++----- lib/pwmem.c | 25 +++++++++++++++++++------ lib/shadowmem.c | 13 ++++++++++--- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19fbcbc7..eb9c80a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-08-26 Nicolas François + + * 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 * libmisc/mail.c: Added brackets and parenthesis. diff --git a/lib/groupmem.c b/lib/groupmem.c index dd2add84..6bdcfd10 100644 --- a/lib/groupmem.c +++ b/lib/groupmem.c @@ -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; } diff --git a/lib/pwmem.c b/lib/pwmem.c index 84dee3d5..addd0fba 100644 --- a/lib/pwmem.c +++ b/lib/pwmem.c @@ -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; } diff --git a/lib/shadowmem.c b/lib/shadowmem.c index b3443bfc..d27fde74 100644 --- a/lib/shadowmem.c +++ b/lib/shadowmem.c @@ -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; }