{
/* Find the space, and then move one past it to copy version */
char *response_ptr= index(buffer, ' ');
- response_ptr++;
- long int version= strtol(response_ptr, (char **)NULL, 10);
+ char *endptr;
+ long int version= strtol(response_ptr, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
}
instance->major_version= uint8_t(version);
- response_ptr= index(response_ptr, '.');
- response_ptr++;
-
- version= strtol(response_ptr, (char **)NULL, 10);
+ endptr++;
+ version= strtol(endptr, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
}
instance->minor_version= uint8_t(version);
- response_ptr= index(response_ptr, '.');
- response_ptr++;
-
- version= strtol(response_ptr, (char **)NULL, 10);
+ endptr++;
+ version= strtol(endptr, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
- char *p;
- long int version= strtol(version_buffer, &p, 10);
+ char *endptr;
+ long int version= strtol(version_buffer, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
}
instance->major_version= uint8_t(version);
- version= strtol(p +1, &p, 10);
+ endptr++;
+ version= strtol(endptr, &endptr, 10);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version"));
}
instance->minor_version= uint8_t(version);
- version= strtol(p + 1, NULL, 10);
- if (errno == ERANGE)
+ endptr++;
+ version= strtol(endptr, &endptr, 10);
+ if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));