Prevent ignoring return value error

When strtol[l] is used for verifying that a string represents a
number, we are not interested in the actual value.
This commit is contained in:
Johan Wikman
2017-03-09 09:44:48 +02:00
parent a925be4e2a
commit d82f4ad6dc

View File

@ -3306,15 +3306,24 @@ bool config_param_is_valid(const MXS_MODULE_PARAM *params, const char *key,
break;
case MXS_MODULE_PARAM_INT:
strtol(value, &endptr, 10);
if (endptr != value && *endptr == '\0')
{
errno = 0;
long int v = strtol(value, &endptr, 10);
(void)v; // error: ignoring return value of 'strtol'
if ((errno == 0) && (endptr != value) && (*endptr == '\0'))
{
valid = true;
}
}
break;
case MXS_MODULE_PARAM_SIZE:
strtoll(value, &endptr, 10);
{
errno = 0;
long long int v = strtoll(value, &endptr, 10);
(void)v; // error: ignoring return value of 'strtoll'
if (errno == 0)
{
if (endptr != value)
{
switch (*endptr)
@ -3342,6 +3351,8 @@ bool config_param_is_valid(const MXS_MODULE_PARAM *params, const char *key,
break;
}
}
}
}
break;
case MXS_MODULE_PARAM_BOOL: