From 005bf97da6b87d126d240a0537b0cbc2cfc14956 Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Fri, 21 Feb 2014 15:31:10 +1300 Subject: param: change lp_set_enum_parm to indicate whether or not it fails Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett Reviewed-by: Jeremy Allison --- source3/param/loadparm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source3/param') diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 4fbbdbe297..ad485c989e 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -2637,7 +2637,7 @@ const char *lp_ldap_idmap_suffix(TALLOC_CTX *ctx) set the value for a P_ENUM ***************************************************************************/ -static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue, +static bool lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue, int *ptr ) { int i; @@ -2645,11 +2645,12 @@ static void lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue for (i = 0; parm->enum_list[i].name; i++) { if ( strequal(pszParmValue, parm->enum_list[i].name)) { *ptr = parm->enum_list[i].value; - return; + return true; } } DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n", pszParmValue, parm->label)); + return false; } /*************************************************************************** @@ -2663,7 +2664,9 @@ static bool handle_printing(struct loadparm_context *unused, int snum, const cha if ( parm_num == -1 ) parm_num = lpcfg_map_parameter( "printing" ); - lp_set_enum_parm( &parm_table[parm_num], pszParmValue, (int*)ptr ); + if (!lp_set_enum_parm(&parm_table[parm_num], pszParmValue, (int*)ptr)) { + return false; + } if ( snum < 0 ) { s = &sDefault; @@ -2851,7 +2854,9 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue break; } case P_ENUM: - lp_set_enum_parm( &parm_table[parmnum], pszParmValue, (int*)parm_ptr ); + if (!lp_set_enum_parm(&parm_table[parmnum], pszParmValue, (int*)parm_ptr)) { + return false; + } break; case P_SEP: break; -- cgit