From 69798dde6525784d06c67edb4907b42f5d7db2b1 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Thu, 11 Mar 2010 22:03:57 +0000 Subject: [PATCH] * lib/shadowio.c: Re-indent. * lib/shadowio.c: Added brackets and parenthesis. * lib/shadowio.c: Document the sections closed by #endif * lib/shadowio.c: Avoid negation of comparisons. * lib/shadowio.c: Avoid implicit conversion of integer to booleans and booleans to integers. --- ChangeLog | 9 ++++++++ lib/shadowio.c | 63 +++++++++++++++++++++++++++++--------------------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 737128df..e9ed8c35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-03-11 Nicolas François + + * lib/shadowio.c: Re-indent. + * lib/shadowio.c: Added brackets and parenthesis. + * lib/shadowio.c: Document the sections closed by #endif + * lib/shadowio.c: Avoid negation of comparisons. + * lib/shadowio.c: Avoid implicit conversion of integer to booleans + and booleans to integers. + 2010-03-11 Nicolas François * src/useradd.c: Re-indent. diff --git a/lib/shadowio.c b/lib/shadowio.c index cda02c2d..56d9a28f 100644 --- a/lib/shadowio.c +++ b/lib/shadowio.c @@ -44,7 +44,7 @@ #ifdef WITH_TCB #include #include "tcbfuncs.h" -#endif +#endif /* WITH_TCB */ static /*@null@*/ /*@only@*/void *shadow_dup (const void *ent) { @@ -97,7 +97,7 @@ static struct commonio_db shadow_db = { NULL, /* fp */ #ifdef WITH_SELINUX NULL, /* scontext */ -#endif +#endif /* WITH_SELINUX */ NULL, /* head */ NULL, /* tail */ NULL, /* cursor */ @@ -127,36 +127,41 @@ int spw_lock (void) #ifdef WITH_TCB int retval = 0; - if (!getdef_bool("USE_TCB")) -#endif + if (!getdef_bool ("USE_TCB")) { +#endif /* WITH_TCB */ return commonio_lock (&shadow_db); #ifdef WITH_TCB - if (!shadowtcb_drop_priv()) + } + if (shadowtcb_drop_priv () == 0) { return 0; - if (lckpwdf_tcb(shadow_db.filename) == 0) { + } + if (lckpwdf_tcb (shadow_db.filename) == 0) { shadow_db.locked = 1; retval = 1; } - if (!shadowtcb_gain_priv()) + if (shadowtcb_gain_priv () == 0) { return 0; + } return retval; -#endif +#endif /* WITH_TCB */ } int spw_open (int mode) { int retval = 0; #ifdef WITH_TCB - int use_tcb = getdef_bool("USE_TCB"); + bool use_tcb = getdef_bool ("USE_TCB"); - if (use_tcb && !shadowtcb_drop_priv() != 0) + if (use_tcb && (shadowtcb_drop_priv () == 0)) { return 0; -#endif + } +#endif /* WITH_TCB */ retval = commonio_open (&shadow_db, mode); #ifdef WITH_TCB - if (use_tcb && !shadowtcb_gain_priv() != 0) + if (use_tcb && (shadowtcb_gain_priv () == 0)) { return 0; -#endif + } +#endif /* WITH_TCB */ return retval; } @@ -189,16 +194,18 @@ int spw_close (void) { int retval = 0; #ifdef WITH_TCB - int use_tcb = getdef_bool("USE_TCB"); + bool use_tcb = getdef_bool ("USE_TCB"); - if (use_tcb && !shadowtcb_drop_priv() != 0) + if (use_tcb && (shadowtcb_drop_priv () == 0)) { return 0; -#endif + } +#endif /* WITH_TCB */ retval = commonio_close (&shadow_db); #ifdef WITH_TCB - if (use_tcb && !shadowtcb_gain_priv() != 0) + if (use_tcb && (shadowtcb_gain_priv () == 0)) { return 0; -#endif + } +#endif /* WITH_TCB */ return retval; } @@ -207,20 +214,23 @@ int spw_unlock (void) #ifdef WITH_TCB int retval = 0; - if (!getdef_bool("USE_TCB")) -#endif + if (!getdef_bool ("USE_TCB")) { +#endif /* WITH_TCB */ return commonio_unlock (&shadow_db); #ifdef WITH_TCB - if (!shadowtcb_drop_priv()) + } + if (shadowtcb_drop_priv () == 0) { return 0; - if (ulckpwdf_tcb() == 0) { + } + if (ulckpwdf_tcb () == 0) { shadow_db.locked = 0; retval = 1; } - if (!shadowtcb_gain_priv()) + if (shadowtcb_gain_priv () == 0) { return 0; + } return retval; -#endif +#endif /* WITH_TCB */ } struct commonio_entry *__spw_get_head (void) @@ -237,8 +247,9 @@ void __spw_del_entry (const struct commonio_entry *ent) int spw_sort () { #ifdef WITH_TCB - if (getdef_bool("USE_TCB")) + if (getdef_bool ("USE_TCB")) { return 0; -#endif + } +#endif /* WITH_TCB */ return commonio_sort_wrt (&shadow_db, __pw_get_db ()); } -- 2.40.0