/*
+--------------------------------------------------------------------+
- | libmemcached - C/C++ Client Library for memcached |
+ | libmemcached-awesome - C/C++ Client Library for memcached |
+--------------------------------------------------------------------+
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted under the terms of the BSD license. |
| the terms online at: https://opensource.org/licenses/BSD-3-Clause |
+--------------------------------------------------------------------+
| Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
- | Copyright (c) 2020 Michael Wallner <mike@php.net> |
+ | Copyright (c) 2020-2021 Michael Wallner https://awesome.co/ |
+--------------------------------------------------------------------+
*/
errno = 0;
result->item_flags = (uint32_t) strtoul(next_ptr, &string_ptr, 10);
- if (errno != 0 or end_ptr == string_ptr) {
+ if (errno or end_ptr == string_ptr) {
goto read_error;
}
errno = 0;
value_length = (size_t) strtoull(next_ptr, &string_ptr, 10);
- if (errno != 0 or end_ptr == string_ptr) {
+ if (errno or end_ptr == string_ptr) {
goto read_error;
}
result->item_cas = strtoull(next_ptr, &string_ptr, 10);
}
- if (errno != 0 or end_ptr < string_ptr) {
+ if (errno or end_ptr < string_ptr) {
goto read_error;
}
and buffer[5] == 'O' and buffer[6] == 'N') /* VERSION */
{
/* Find the space, and then move one past it to copy version */
- char *response_ptr = index(buffer, ' ');
+ char *response_ptr = strchr(buffer, ' ');
char *endptr;
errno = 0;
long int version = strtol(response_ptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX
+ if (errno or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX
or version == 0) {
instance->major_version = instance->minor_version = instance->micro_version = UINT8_MAX;
return memcached_set_error(
endptr++;
errno = 0;
version = strtol(endptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
+ if (errno or version == LONG_MIN or version == LONG_MAX 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,
endptr++;
errno = 0;
version = strtol(endptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
+ if (errno or version == LONG_MIN or version == LONG_MAX 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,
result->numeric_value = UINT64_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
memcached_literal_param("Numeric response was out of range"));
- } else if (errno != 0) {
+ } else if (errno) {
result->numeric_value = UINT64_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
memcached_literal_param("Numeric response was out of range"));
} break;
case PROTOCOL_BINARY_CMD_SASL_LIST_MECHS: {
- if (header.response.keylen != 0 || bodylen + 1 > buffer_length) {
+ if (header.response.keylen || bodylen + 1 > buffer_length) {
return MEMCACHED_UNKNOWN_READ_FAILURE;
} else {
if ((rc = memcached_safe_read(instance, buffer, bodylen)) != MEMCACHED_SUCCESS) {
char *endptr;
errno = 0;
long int version = strtol(version_buffer, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX
+ if (errno or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX
or version == 0) {
instance->major_version = instance->minor_version = instance->micro_version = UINT8_MAX;
return memcached_set_error(
endptr++;
errno = 0;
version = strtol(endptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
+ if (errno or version == LONG_MIN or version == LONG_MAX 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,
endptr++;
errno = 0;
version = strtol(endptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
+ if (errno or version == LONG_MIN or version == LONG_MAX 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,
}
rc = MEMCACHED_SUCCESS;
- if (header.response.status != 0) {
+ if (header.response.status) {
switch (header.response.status) {
case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT:
rc = MEMCACHED_NOTFOUND;