From: Michael Wallner Date: Fri, 11 Dec 2020 09:28:50 +0000 (+0100) Subject: C++: double underscores are reserved X-Git-Tag: 1.1.0-beta1~68 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ac25aff8b62e8596e20f0fd2a2c3eda96bdb437e;p=m6w6%2Flibmemcached C++: double underscores are reserved --- diff --git a/CMake/_Include.cmake b/CMake/_Include.cmake index 29cdbf25..c75c741f 100644 --- a/CMake/_Include.cmake +++ b/CMake/_Include.cmake @@ -137,6 +137,7 @@ check_type(ssize_t sys/types.h) check_type("struct msghdr" sys/socket.h) check_cxx_symbol(abi::__cxa_demangle cxxabi.h) +check_symbol(ERESTART errno.h) check_symbol(fcntl fcntl.h) check_symbol(gettimeofday sys/time.h) check_symbol(htonll arpa/inet.h) diff --git a/libmemcached.cppcheck b/libmemcached.cppcheck index 2baa38df..4de77867 100644 --- a/libmemcached.cppcheck +++ b/libmemcached.cppcheck @@ -7,23 +7,14 @@ false 10 - + + HARD_MALLOC_TEST - + + - - - - - - - - - - - diff --git a/src/libmemcached/connect.cc b/src/libmemcached/connect.cc index a4b9b40a..84617133 100644 --- a/src/libmemcached/connect.cc +++ b/src/libmemcached/connect.cc @@ -40,7 +40,7 @@ static memcached_return_t connect_poll(memcached_instance_st *server, const int if ((number_of = poll(fds, 1, server->root->connect_timeout)) == SOCKET_ERROR) { int local_errno = get_socket_errno(); // We cache in case closesocket() modifies errno switch (local_errno) { -#ifdef __linux__ +#ifdef HAVE_ERESTART case ERESTART: #endif case EINTR: diff --git a/src/libmemcached/get.cc b/src/libmemcached/get.cc index d625adce..1afef22d 100644 --- a/src/libmemcached/get.cc +++ b/src/libmemcached/get.cc @@ -21,7 +21,7 @@ char *memcached_get(memcached_st *ptr, const char *key, size_t key_length, size_ return memcached_get_by_key(ptr, NULL, 0, key, key_length, value_length, flags, error); } -static memcached_return_t __mget_by_key_real(memcached_st *ptr, const char *group_key, +static memcached_return_t mget_by_key_real(memcached_st *ptr, const char *group_key, size_t group_key_length, const char *const *keys, const size_t *key_length, size_t number_of_keys, const bool mget_mode); @@ -40,8 +40,8 @@ char *memcached_get_by_key(memcached_st *shell, const char *group_key, size_t gr } /* Request the key */ - *error = __mget_by_key_real(ptr, group_key, group_key_length, (const char *const *) &key, - &key_length, 1, false); + *error = mget_by_key_real(ptr, group_key, group_key_length, (const char *const *) &key, + &key_length, 1, false); if (ptr) { assert_msg(ptr->query_id == query_id + 1, "Programmer error, the query_id was not incremented."); @@ -133,8 +133,8 @@ static memcached_return_t binary_mget_by_key(memcached_st *ptr, const uint32_t m const size_t *key_length, const size_t number_of_keys, const bool mget_mode); -static memcached_return_t __mget_by_key_real(memcached_st *ptr, const char *group_key, - const size_t group_key_length, const char *const *keys, +static memcached_return_t mget_by_key_real(memcached_st *ptr, const char *group_key, + size_t group_key_length, const char *const *keys, const size_t *key_length, size_t number_of_keys, const bool mget_mode) { bool failures_occured_in_sending = false; @@ -297,8 +297,7 @@ memcached_return_t memcached_mget_by_key(memcached_st *shell, const char *group_ size_t group_key_length, const char *const *keys, const size_t *key_length, size_t number_of_keys) { Memcached *ptr = memcached2Memcached(shell); - return __mget_by_key_real(ptr, group_key, group_key_length, keys, key_length, number_of_keys, - true); + return mget_by_key_real(ptr, group_key, group_key_length, keys, key_length, number_of_keys, true); } memcached_return_t memcached_mget_execute(memcached_st *ptr, const char *const *keys, diff --git a/src/libmemcached/hosts.cc b/src/libmemcached/hosts.cc index 8f121502..ad01decd 100644 --- a/src/libmemcached/hosts.cc +++ b/src/libmemcached/hosts.cc @@ -311,7 +311,7 @@ static memcached_return_t server_add(Memcached *memc, const memcached_string_t & memcached_instance_st *instance = memcached_instance_fetch(memc, memcached_server_count(memc) - 1); - if (__instance_create_with(memc, instance, hostname, port, weight, type) == NULL) { + if (instance_create_with(memc, instance, hostname, port, weight, type) == NULL) { return memcached_set_error(*memc, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } @@ -353,8 +353,7 @@ memcached_return_t memcached_server_push(memcached_st *shell, const memcached_se WATCHPOINT_ASSERT(instance); memcached_string_t hostname = {memcached_string_make_from_cstr(list[x].hostname)}; - if (__instance_create_with(ptr, instance, hostname, list[x].port, list[x].weight, - list[x].type) + if (instance_create_with(ptr, instance, hostname, list[x].port, list[x].weight, list[x].type) == NULL) { ptr->state.is_parsing = false; @@ -404,8 +403,7 @@ memcached_return_t memcached_instance_push(memcached_st *ptr, WATCHPOINT_ASSERT(instance); memcached_string_t hostname = {memcached_string_make_from_cstr(list[x]._hostname)}; - if (__instance_create_with(ptr, instance, hostname, list[x].port(), list[x].weight, - list[x].type) + if (instance_create_with(ptr, instance, hostname, list[x].port(), list[x].weight, list[x].type) == NULL) { ptr->state.is_parsing = false; diff --git a/src/libmemcached/instance.cc b/src/libmemcached/instance.cc index 266eccc7..a6725d18 100644 --- a/src/libmemcached/instance.cc +++ b/src/libmemcached/instance.cc @@ -97,11 +97,11 @@ void memcached_instance_st::revents(short arg) { _events &= short(~arg); } -memcached_instance_st *__instance_create_with(memcached_st *memc, memcached_instance_st *self, - const memcached_string_t &hostname, +memcached_instance_st *instance_create_with(memcached_st *memc, memcached_instance_st *self, + const memcached_string_t &_hostname, const in_port_t port, uint32_t weight, const memcached_connection_t type) { - if (memcached_is_valid_servername(hostname) == false) { + if (memcached_is_valid_servername(_hostname) == false) { memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid hostname provided")); return NULL; @@ -113,7 +113,7 @@ memcached_instance_st *__instance_create_with(memcached_st *memc, memcached_inst return NULL; } - _server_init(self, const_cast(memc), hostname, port, weight, type); + _server_init(self, const_cast(memc), _hostname, port, weight, type); if (memc and memcached_is_udp(memc)) { self->write_buffer_offset = UDP_DATAGRAM_HEADER_LENGTH; @@ -123,7 +123,7 @@ memcached_instance_st *__instance_create_with(memcached_st *memc, memcached_inst return self; } -void __instance_free(memcached_instance_st *self) { +void instance_free(memcached_instance_st *self) { memcached_quit_server(self, false); self->clear_addrinfo(); @@ -140,7 +140,7 @@ void __instance_free(memcached_instance_st *self) { void memcached_instance_free(memcached_instance_st *self) { if (self) { - __instance_free(self); + instance_free(self); } } @@ -226,8 +226,8 @@ static memcached_instance_st *memcached_instance_clone(memcached_instance_st *so } memcached_string_t hostname_ = {memcached_string_make_from_cstr(source->hostname())}; - return __instance_create_with(source->root, NULL, hostname_, source->port(), source->weight, - source->type); + return instance_create_with(source->root, NULL, hostname_, source->port(), source->weight, + source->type); } void set_last_disconnected_host(memcached_instance_st *self) { diff --git a/src/libmemcached/instance.hpp b/src/libmemcached/instance.hpp index 57f68786..de072536 100644 --- a/src/libmemcached/instance.hpp +++ b/src/libmemcached/instance.hpp @@ -135,7 +135,7 @@ struct memcached_instance_st { } }; -memcached_instance_st *__instance_create_with(memcached_st *memc, memcached_instance_st *self, +memcached_instance_st *instance_create_with(memcached_st *memc, memcached_instance_st *self, const memcached_string_t &_hostname, const in_port_t port, uint32_t weight, const memcached_connection_t type); @@ -143,4 +143,4 @@ memcached_instance_st *__instance_create_with(memcached_st *memc, memcached_inst memcached_return_t memcached_instance_push(memcached_st *ptr, const memcached_instance_st *, uint32_t); -void __instance_free(memcached_instance_st *); +void instance_free(memcached_instance_st *); diff --git a/src/libmemcached/io.cc b/src/libmemcached/io.cc index 0cf1931a..1cc62e47 100644 --- a/src/libmemcached/io.cc +++ b/src/libmemcached/io.cc @@ -60,7 +60,7 @@ static bool repack_input_buffer(memcached_instance_st *instance) { case EWOULDBLOCK: #endif case EAGAIN: -#ifdef __linux +#ifdef HAVE_ERESTART case ERESTART: #endif break; // No IO is fine, we can just move on @@ -209,7 +209,7 @@ static memcached_return_t io_wait(memcached_instance_st *instance, const short e int local_errno = get_socket_errno(); // We cache in case memcached_quit_server() modifies errno assert_msg(active_fd == -1, "poll() returned an unexpected value"); switch (local_errno) { -#ifdef __linux +#ifdef ERESTART case ERESTART: #endif case EINTR: @@ -367,7 +367,7 @@ static memcached_return_t _io_fill(memcached_instance_st *instance) { case EWOULDBLOCK: #endif case EAGAIN: -#ifdef __linux +#ifdef HAVE_ERESTART case ERESTART: #endif { @@ -496,7 +496,7 @@ memcached_return_t memcached_io_slurp(memcached_instance_st *instance) { case EWOULDBLOCK: #endif case EAGAIN: -#ifdef __linux +#ifdef ERESTART case ERESTART: #endif if (memcached_success(io_wait(instance, POLLIN))) { diff --git a/src/libmemcached/memcached.cc b/src/libmemcached/memcached.cc index 7c80e5ef..586744f0 100644 --- a/src/libmemcached/memcached.cc +++ b/src/libmemcached/memcached.cc @@ -104,7 +104,7 @@ static inline bool _memcached_init(Memcached *self) { return true; } -static void __memcached_free(Memcached *ptr, bool release_st) { +static void memcached_free_ex(Memcached *ptr, bool release_st) { /* If we have anything open, lets close it now */ send_quit(ptr); memcached_instance_list_free(memcached_instance_list(ptr), memcached_instance_list_count(ptr)); @@ -219,7 +219,7 @@ memcached_return_t memcached_reset(memcached_st *shell) { bool stored_is_allocated = memcached_is_allocated(ptr); uint64_t query_id = ptr->query_id; - __memcached_free(ptr, false); + memcached_free_ex(ptr, false); memcached_create(ptr); memcached_set_allocated(ptr, stored_is_allocated); ptr->query_id = query_id; @@ -256,7 +256,7 @@ void memcached_reset_last_disconnected_server(memcached_st *shell) { void memcached_free(memcached_st *ptr) { if (ptr) { - __memcached_free(ptr, true); + memcached_free_ex(ptr, true); } } diff --git a/src/libmemcached/purge.cc b/src/libmemcached/purge.cc index 4437d761..d6943701 100644 --- a/src/libmemcached/purge.cc +++ b/src/libmemcached/purge.cc @@ -15,7 +15,7 @@ #include "libmemcached/common.h" -#define memcached_set_purging(__object, __value) ((__object)->state.is_purging = (__value)) +#define memcached_set_purging(object_, value_) ((object_)->state.is_purging = (value_)) class Purge { public: diff --git a/src/libmemcached/server.cc b/src/libmemcached/server.cc index e038196a..6633da9c 100644 --- a/src/libmemcached/server.cc +++ b/src/libmemcached/server.cc @@ -72,7 +72,7 @@ static memcached_server_st *_server_create(memcached_server_st *self, const Memc return self; } -memcached_server_st *__server_create_with(Memcached *memc, memcached_server_st *allocated_instance, +memcached_server_st *server_create_with(Memcached *memc, memcached_server_st *self, const memcached_string_t &hostname, const in_port_t port, uint32_t weight, const memcached_connection_t type) { if (memcached_is_valid_servername(hostname) == false) { @@ -81,18 +81,18 @@ memcached_server_st *__server_create_with(Memcached *memc, memcached_server_st * return NULL; } - allocated_instance = _server_create(allocated_instance, memc); + self = _server_create(self, memc); - if (allocated_instance == NULL) { + if (self == NULL) { return NULL; } - _server_init(allocated_instance, const_cast(memc), hostname, port, weight, type); + _server_init(self, const_cast(memc), hostname, port, weight, type); - return allocated_instance; + return self; } -void __server_free(memcached_server_st *self) { +void server_free(memcached_server_st *self) { memcached_error_free(*self); if (memcached_is_allocated(self)) { @@ -112,7 +112,7 @@ void memcached_server_free(memcached_server_st *self) { return; } - __server_free(self); + server_free(self); } void memcached_server_error_reset(memcached_server_st *self) { diff --git a/src/libmemcached/server.hpp b/src/libmemcached/server.hpp index 86f6ffb9..d6fdd0da 100644 --- a/src/libmemcached/server.hpp +++ b/src/libmemcached/server.hpp @@ -19,7 +19,7 @@ #include -memcached_server_st *__server_create_with(memcached_st *memc, memcached_server_st *self, +memcached_server_st *server_create_with(memcached_st *memc, memcached_server_st *self, const memcached_string_t &hostname, const in_port_t port, uint32_t weight, const memcached_connection_t type); @@ -27,7 +27,7 @@ memcached_return_t memcached_server_add_parsed(memcached_st *ptr, const char *ho size_t hostname_length, in_port_t port, uint32_t weight); -void __server_free(memcached_server_st *); +void server_free(memcached_server_st *); static inline bool memcached_is_valid_servername(const memcached_string_t &arg) { return (arg.c_str != NULL or arg.size == 0) and arg.size < MEMCACHED_NI_MAXHOST; diff --git a/src/libmemcached/server_list.cc b/src/libmemcached/server_list.cc index 665b75dc..5fe0acd6 100644 --- a/src/libmemcached/server_list.cc +++ b/src/libmemcached/server_list.cc @@ -51,8 +51,8 @@ memcached_server_list_st memcached_server_list_append_with_weight(memcached_serv memcached_string_t _hostname = {memcached_string_make_from_cstr(hostname)}; /* @todo Check return type */ - if (__server_create_with(NULL, &new_host_list[count - 1], _hostname, port, weight, - port ? MEMCACHED_CONNECTION_TCP : MEMCACHED_CONNECTION_UNIX_SOCKET) + if (server_create_with(NULL, &new_host_list[count - 1], _hostname, port, weight, + port ? MEMCACHED_CONNECTION_TCP : MEMCACHED_CONNECTION_UNIX_SOCKET) == NULL) { #if 0 @@ -63,7 +63,7 @@ memcached_server_list_st memcached_server_list_append_with_weight(memcached_serv } #if 0 - // Handset allocated since + // Handset allocated since new_host_list->options.is_allocated= true; #endif @@ -101,7 +101,7 @@ void memcached_server_list_free(memcached_server_list_st self) { assert_msg(not memcached_is_allocated(&self[x]), "You have called memcached_server_list_free(), but you did not pass it a valid " "memcached_server_list_st"); - __server_free(&self[x]); + server_free(&self[x]); } libmemcached_free(self->root, self); @@ -114,7 +114,7 @@ void memcached_instance_list_free(memcached_instance_st *self, uint32_t instance assert_msg(memcached_is_allocated(&self[x]) == false, "You have called memcached_server_list_free(), but you did not pass it a valid " "memcached_server_list_st"); - __instance_free(&self[x]); + instance_free(&self[x]); } libmemcached_free(self->root, self); diff --git a/src/p9y/getopt.c b/src/p9y/getopt.c index 40434941..6d0fe62a 100644 --- a/src/p9y/getopt.c +++ b/src/p9y/getopt.c @@ -110,7 +110,7 @@ char *optarg; /* argument associated with option */ #define INORDER (int)1 #ifndef __CYGWIN__ -#define __progname __argv[0] +#define progname __argv[0] #else extern char __declspec(dllimport) *__progname; #endif @@ -145,7 +145,7 @@ static const char illoptstring[] = "unknown option -- %s"; static void _vwarnx(const char *fmt,va_list ap) { - (void)fprintf(stderr,"%s: ",__progname); + (void)fprintf(stderr,"%s: ", progname); if (fmt != NULL) (void)vfprintf(stderr,fmt,ap); (void)fprintf(stderr,"\n");