mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
r13736: Don't assume that printf can handle string arguments being NULL. Tidy
up typing and tighten error checking a little.
This commit is contained in:
parent
cde31d5957
commit
37e12a196b
@ -2152,14 +2152,17 @@ static param_opt_struct *get_parametrics(int snum, const char *type, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define MISSING_PARAMETER(name) \
|
||||||
|
DEBUG(0, ("%s(): value is NULL or empty!\n", #name))
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
convenience routine to return int parameters.
|
convenience routine to return int parameters.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int lp_int(const char *s)
|
static int lp_int(const char *s)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!s) {
|
if (!s || !*s) {
|
||||||
DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
|
MISSING_PARAMETER(lp_int);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2169,12 +2172,12 @@ static int lp_int(const char *s)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
convenience routine to return unsigned long parameters.
|
convenience routine to return unsigned long parameters.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int lp_ulong(const char *s)
|
static unsigned long lp_ulong(const char *s)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!s) {
|
if (!s || !*s) {
|
||||||
DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
|
MISSING_PARAMETER(lp_ulong);
|
||||||
return (-1);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return strtoul(s, NULL, 10);
|
return strtoul(s, NULL, 10);
|
||||||
@ -2187,8 +2190,8 @@ static BOOL lp_bool(const char *s)
|
|||||||
{
|
{
|
||||||
BOOL ret = False;
|
BOOL ret = False;
|
||||||
|
|
||||||
if (!s) {
|
if (!s || !*s) {
|
||||||
DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
|
MISSING_PARAMETER(lp_bool);
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2207,8 +2210,8 @@ static int lp_enum(const char *s,const struct enum_list *_enum)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!s || !_enum) {
|
if (!s || !*s || !_enum) {
|
||||||
DEBUG(0,("lp_enum(%s,enum): is called with NULL!\n",s));
|
MISSING_PARAMETER(lp_enum);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2221,6 +2224,7 @@ static int lp_enum(const char *s,const struct enum_list *_enum)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef MISSING_PARAMETER
|
||||||
|
|
||||||
/* DO NOT USE lp_parm_string ANYMORE!!!!
|
/* DO NOT USE lp_parm_string ANYMORE!!!!
|
||||||
* use lp_parm_const_string or lp_parm_talloc_string
|
* use lp_parm_const_string or lp_parm_talloc_string
|
||||||
@ -3485,16 +3489,15 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
|
|||||||
switch (parm_table[parmnum].type)
|
switch (parm_table[parmnum].type)
|
||||||
{
|
{
|
||||||
case P_BOOL:
|
case P_BOOL:
|
||||||
set_boolean((BOOL *)parm_ptr, pszParmValue);
|
*(BOOL *)parm_ptr = lp_bool(pszParmValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_BOOLREV:
|
case P_BOOLREV:
|
||||||
set_boolean((BOOL *)parm_ptr, pszParmValue);
|
*(BOOL *)parm_ptr = !lp_bool(pszParmValue);
|
||||||
*(BOOL *)parm_ptr = !*(BOOL *)parm_ptr;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_INTEGER:
|
case P_INTEGER:
|
||||||
*(int *)parm_ptr = atoi(pszParmValue);
|
*(int *)parm_ptr = lp_int(pszParmValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_CHAR:
|
case P_CHAR:
|
||||||
|
Loading…
Reference in New Issue
Block a user