diff --git a/src/.clang-format b/src/.clang-format index 2f0548a93d..7255b18ac0 100644 --- a/src/.clang-format +++ b/src/.clang-format @@ -2,7 +2,7 @@ BasedOnStyle: LLVM IndentWidth: 4 TabWidth: 4 UseTab: Never -ColumnLimit: 120 +ColumnLimit: 0 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 100 diff --git a/src/acl.c b/src/acl.c index 87d91014cd..17632df0d4 100644 --- a/src/acl.c +++ b/src/acl.c @@ -3117,37 +3117,35 @@ void aclCommand(client *c) { addReply(c, shared.ok); } else if (c->argc == 2 && !strcasecmp(sub, "help")) { - /* clang-format off */ const char *help[] = { -"CAT []", -" List all commands that belong to , or all command categories", -" when no category is specified.", -"DELUSER [ ...]", -" Delete a list of users.", -"DRYRUN [ ...]", -" Returns whether the user can execute the given command without executing the command.", -"GETUSER ", -" Get the user's details.", -"GENPASS []", -" Generate a secure 256-bit user password. The optional `bits` argument can", -" be used to specify a different size.", -"LIST", -" Show users details in config file format.", -"LOAD", -" Reload users from the ACL file.", -"LOG [ | RESET]", -" Show the ACL log entries.", -"SAVE", -" Save the current config to the ACL file.", -"SETUSER [ ...]", -" Create or modify a user with the specified attributes.", -"USERS", -" List all the registered usernames.", -"WHOAMI", -" Return the current connection username.", -NULL + "CAT []", + " List all commands that belong to , or all command categories", + " when no category is specified.", + "DELUSER [ ...]", + " Delete a list of users.", + "DRYRUN [ ...]", + " Returns whether the user can execute the given command without executing the command.", + "GETUSER ", + " Get the user's details.", + "GENPASS []", + " Generate a secure 256-bit user password. The optional `bits` argument can", + " be used to specify a different size.", + "LIST", + " Show users details in config file format.", + "LOAD", + " Reload users from the ACL file.", + "LOG [ | RESET]", + " Show the ACL log entries.", + "SAVE", + " Save the current config to the ACL file.", + "SETUSER [ ...]", + " Create or modify a user with the specified attributes.", + "USERS", + " List all the registered usernames.", + "WHOAMI", + " Return the current connection username.", + NULL, }; - /* clang-format on */ addReplyHelp(c, help); } else { addReplySubcommandSyntaxError(c); diff --git a/src/ae.c b/src/ae.c index ef7ba7bd67..f91d0b7e8a 100644 --- a/src/ae.c +++ b/src/ae.c @@ -63,14 +63,14 @@ #endif #endif -#define AE_LOCK(eventLoop) \ - if ((eventLoop)->flags & AE_PROTECT_POLL) { \ - assert(pthread_mutex_lock(&(eventLoop)->poll_mutex) == 0); \ +#define AE_LOCK(eventLoop) \ + if ((eventLoop)->flags & AE_PROTECT_POLL) { \ + assert(pthread_mutex_lock(&(eventLoop)->poll_mutex) == 0); \ } -#define AE_UNLOCK(eventLoop) \ - if ((eventLoop)->flags & AE_PROTECT_POLL) { \ - assert(pthread_mutex_unlock(&(eventLoop)->poll_mutex) == 0); \ +#define AE_UNLOCK(eventLoop) \ + if ((eventLoop)->flags & AE_PROTECT_POLL) { \ + assert(pthread_mutex_unlock(&(eventLoop)->poll_mutex) == 0); \ } aeEventLoop *aeCreateEventLoop(int setsize) { diff --git a/src/ae.h b/src/ae.h index 1156819c9c..2c1ab2dd5f 100644 --- a/src/ae.h +++ b/src/ae.h @@ -42,12 +42,11 @@ #define AE_NONE 0 /* No events registered. */ #define AE_READABLE 1 /* Fire when descriptor is readable. */ #define AE_WRITABLE 2 /* Fire when descriptor is writable. */ -#define AE_BARRIER \ - 4 /* With WRITABLE, never fire the event if the \ - READABLE event already fired in the same event \ - loop iteration. Useful when you want to persist \ - things to disk before sending replies, and want \ - to do that in a group fashion. */ +#define AE_BARRIER 4 /* With WRITABLE, never fire the event if the \ + READABLE event already fired in the same event \ + loop iteration. Useful when you want to persist \ + things to disk before sending replies, and want \ + to do that in a group fashion. */ #define AE_FILE_EVENTS (1 << 0) #define AE_TIME_EVENTS (1 << 1) diff --git a/src/asciilogo.h b/src/asciilogo.h index 2b2b381758..d05466ba50 100644 --- a/src/asciilogo.h +++ b/src/asciilogo.h @@ -28,25 +28,23 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* clang-format off */ const char *ascii_logo = -" .+^+. \n" -" .+#########+. \n" -" .+########+########+. Valkey %s (%s/%d) %s bit\n" -" .+########+' '+########+. \n" -" .########+' .+. '+########. Running in %s mode\n" -" |####+' .+#######+. '+####| Port: %d\n" -" |###| .+###############+. |###| PID: %ld \n" -" |###| |#####*'' ''*#####| |###| \n" -" |###| |####' .-. '####| |###| \n" -" |###| |###( (@@@) )###| |###| https://valkey.io \n" -" |###| |####. '-' .####| |###| \n" -" |###| |#####*. .*#####| |###| \n" -" |###| '+#####| |#####+' |###| \n" -" |####+. +##| |#+' .+####| \n" -" '#######+ |##| .+########' \n" -" '+###| |##| .+########+' \n" -" '| |####+########+' \n" -" +#########+' \n" -" '+v+' \n\n"; -/* clang-format off */ + " .+^+. \n" + " .+#########+. \n" + " .+########+########+. Valkey %s (%s/%d) %s bit\n" + " .+########+' '+########+. \n" + " .########+' .+. '+########. Running in %s mode\n" + " |####+' .+#######+. '+####| Port: %d\n" + " |###| .+###############+. |###| PID: %ld \n" + " |###| |#####*'' ''*#####| |###| \n" + " |###| |####' .-. '####| |###| \n" + " |###| |###( (@@@) )###| |###| https://valkey.io \n" + " |###| |####. '-' .####| |###| \n" + " |###| |#####*. .*#####| |###| \n" + " |###| '+#####| |#####+' |###| \n" + " |####+. +##| |#+' .+####| \n" + " '#######+ |##| .+########' \n" + " '+###| |##| .+########+' \n" + " '| |####+########+' \n" + " +#########+' \n" + " '+v+' \n\n"; diff --git a/src/atomicvar.h b/src/atomicvar.h deleted file mode 100644 index 62235e24ae..0000000000 --- a/src/atomicvar.h +++ /dev/null @@ -1,197 +0,0 @@ -/* This file implements atomic counters using c11 _Atomic, __atomic or __sync - * macros if available, otherwise we will throw an error when compile. - * - * The exported interface is composed of the following macros: - * - * atomicIncr(var,count) -- Increment the atomic counter - * atomicGetIncr(var,oldvalue_var,count) -- Get and increment the atomic counter - * atomicIncrGet(var,newvalue_var,count) -- Increment and get the atomic counter new value - * atomicDecr(var,count) -- Decrement the atomic counter - * atomicGet(var,dstvar) -- Fetch the atomic counter value - * atomicSet(var,value) -- Set the atomic counter value - * atomicGetWithSync(var,value) -- 'atomicGet' with inter-thread synchronization - * atomicSetWithSync(var,value) -- 'atomicSet' with inter-thread synchronization - * - * Atomic operations on flags. - * Flag type can be int, long, long long or their unsigned counterparts. - * The value of the flag can be 1 or 0. - * - * atomicFlagGetSet(var,oldvalue_var) -- Get and set the atomic counter value - * - * NOTE1: __atomic* and _Atomic implementations can be actually elaborated to support any value by changing the - * hardcoded new value passed to __atomic_exchange* from 1 to @param count - * i.e oldvalue_var = atomic_exchange_explicit(&var, count). - * However, in order to be compatible with the __sync functions family, we can use only 0 and 1. - * The only exchange alternative suggested by __sync is __sync_lock_test_and_set, - * But as described by the gnu manual for __sync_lock_test_and_set(): - * https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html - * "A target may support reduced functionality here by which the only valid value to store is the immediate constant 1. - * The exact value actually stored in *ptr is implementation defined." Hence, we can't rely on it for a any value other - * than 1. We eventually chose to implement this method with __sync_val_compare_and_swap since it satisfies - * functionality needed for atomicFlagGetSet (if the flag was 0 -> set to 1, if it's already 1 -> do nothing, but the - * final result is that the flag is set), and also it has a full barrier (__sync_lock_test_and_set has acquire barrier). - * - * NOTE2: Unlike other atomic type, which aren't guaranteed to be lock free, c11 atomic_flag does. - * To check whether a type is lock free, atomic_is_lock_free() can be used. - * It can be considered to limit the flag type to atomic_flag to improve performance. - * - * Never use return value from the macros, instead use the AtomicGetIncr() - * if you need to get the current value and increment it atomically, like - * in the following example: - * - * long oldvalue; - * atomicGetIncr(myvar,oldvalue,1); - * doSomethingWith(oldvalue); - * - * ---------------------------------------------------------------------------- - * - * Copyright (c) 2015, Redis Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Redis nor the names of its contributors may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "config.h" - -#ifndef __ATOMIC_VAR_H -#define __ATOMIC_VAR_H - -/* Define serverAtomic for atomic variable. */ -#define serverAtomic - -/* To test the server with Helgrind (a Valgrind tool) it is useful to define - * the following macro, so that __sync macros are used: those can be detected - * by Helgrind (even if they are less efficient) so that no false positive - * is reported. */ -// #define __ATOMIC_VAR_FORCE_SYNC_MACROS - -/* There will be many false positives if we test the server with Helgrind, since - * Helgrind can't understand we have imposed ordering on the program, so - * we use macros in helgrind.h to tell Helgrind inter-thread happens-before - * relationship explicitly for avoiding false positives. - * - * For more details, please see: valgrind/helgrind.h and - * https://www.valgrind.org/docs/manual/hg-manual.html#hg-manual.effective-use - * - * These macros take effect only when 'make helgrind', and you must first - * install Valgrind in the default path configuration. */ -#ifdef __ATOMIC_VAR_FORCE_SYNC_MACROS -#include -#else -#define ANNOTATE_HAPPENS_BEFORE(v) ((void)v) -#define ANNOTATE_HAPPENS_AFTER(v) ((void)v) -#endif - -#if !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(__STDC_NO_ATOMICS__) -/* Use '_Atomic' keyword if the compiler supports. */ -#undef serverAtomic -#define serverAtomic _Atomic -/* Implementation using _Atomic in C11. */ - -#include -#define atomicIncr(var, count) atomic_fetch_add_explicit(&var, (count), memory_order_relaxed) -#define atomicGetIncr(var, oldvalue_var, count) \ - do { \ - oldvalue_var = atomic_fetch_add_explicit(&var, (count), memory_order_relaxed); \ - } while (0) -#define atomicIncrGet(var, newvalue_var, count) newvalue_var = atomicIncr(var, count) + count -#define atomicDecr(var, count) atomic_fetch_sub_explicit(&var, (count), memory_order_relaxed) -#define atomicGet(var, dstvar) \ - do { \ - dstvar = atomic_load_explicit(&var, memory_order_relaxed); \ - } while (0) -#define atomicSet(var, value) atomic_store_explicit(&var, value, memory_order_relaxed) -#define atomicGetWithSync(var, dstvar) \ - do { \ - dstvar = atomic_load_explicit(&var, memory_order_seq_cst); \ - } while (0) -#define atomicSetWithSync(var, value) atomic_store_explicit(&var, value, memory_order_seq_cst) -#define atomicFlagGetSet(var, oldvalue_var) oldvalue_var = atomic_exchange_explicit(&var, 1, memory_order_relaxed) -#define REDIS_ATOMIC_API "c11-builtin" - -#elif !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && \ - (!defined(__clang__) || !defined(__APPLE__) || __apple_build_version__ > 4210057) && defined(__ATOMIC_RELAXED) && \ - defined(__ATOMIC_SEQ_CST) -/* Implementation using __atomic macros. */ - -#define atomicIncr(var, count) __atomic_add_fetch(&var, (count), __ATOMIC_RELAXED) -#define atomicIncrGet(var, newvalue_var, count) newvalue_var = __atomic_add_fetch(&var, (count), __ATOMIC_RELAXED) -#define atomicGetIncr(var, oldvalue_var, count) \ - do { \ - oldvalue_var = __atomic_fetch_add(&var, (count), __ATOMIC_RELAXED); \ - } while (0) -#define atomicDecr(var, count) __atomic_sub_fetch(&var, (count), __ATOMIC_RELAXED) -#define atomicGet(var, dstvar) \ - do { \ - dstvar = __atomic_load_n(&var, __ATOMIC_RELAXED); \ - } while (0) -#define atomicSet(var, value) __atomic_store_n(&var, value, __ATOMIC_RELAXED) -#define atomicGetWithSync(var, dstvar) \ - do { \ - dstvar = __atomic_load_n(&var, __ATOMIC_SEQ_CST); \ - } while (0) -#define atomicSetWithSync(var, value) __atomic_store_n(&var, value, __ATOMIC_SEQ_CST) -#define atomicFlagGetSet(var, oldvalue_var) oldvalue_var = __atomic_exchange_n(&var, 1, __ATOMIC_RELAXED) -#define REDIS_ATOMIC_API "atomic-builtin" - -#elif defined(HAVE_ATOMIC) -/* Implementation using __sync macros. */ - -#define atomicIncr(var, count) __sync_add_and_fetch(&var, (count)) -#define atomicIncrGet(var, newvalue_var, count) newvalue_var = __sync_add_and_fetch(&var, (count)) -#define atomicGetIncr(var, oldvalue_var, count) \ - do { \ - oldvalue_var = __sync_fetch_and_add(&var, (count)); \ - } while (0) -#define atomicDecr(var, count) __sync_sub_and_fetch(&var, (count)) -#define atomicGet(var, dstvar) \ - do { \ - dstvar = __sync_sub_and_fetch(&var, 0); \ - } while (0) -#define atomicSet(var, value) \ - do { \ - while (!__sync_bool_compare_and_swap(&var, var, value)); \ - } while (0) -/* Actually the builtin issues a full memory barrier by default. */ -#define atomicGetWithSync(var, dstvar) \ - do { \ - dstvar = __sync_sub_and_fetch(&var, 0, __sync_synchronize); \ - ANNOTATE_HAPPENS_AFTER(&var); \ - } while (0) -#define atomicSetWithSync(var, value) \ - do { \ - ANNOTATE_HAPPENS_BEFORE(&var); \ - while (!__sync_bool_compare_and_swap(&var, var, value, __sync_synchronize)); \ - } while (0) -#define atomicFlagGetSet(var, oldvalue_var) oldvalue_var = __sync_val_compare_and_swap(&var, 0, 1) -#define REDIS_ATOMIC_API "sync-builtin" - -#else -#error "Unable to determine atomic operations for your platform" - -#endif -#endif /* __ATOMIC_VAR_H */ diff --git a/src/cli_commands.c b/src/cli_commands.c index 1a6ab545bc..943adafa41 100644 --- a/src/cli_commands.c +++ b/src/cli_commands.c @@ -2,11 +2,11 @@ #include "cli_commands.h" /* Definitions to configure commands.c to generate the above structs. */ -#define MAKE_CMD(name, summary, complexity, since, doc_flags, replaced, deprecated, group, group_enum, history, \ - num_history, tips, num_tips, function, arity, flags, acl, key_specs, key_specs_num, get_keys, \ - numargs) \ +#define MAKE_CMD(name, summary, complexity, since, doc_flags, replaced, deprecated, group, group_enum, history, \ + num_history, tips, num_tips, function, arity, flags, acl, key_specs, key_specs_num, get_keys, \ + numargs) \ name, summary, group, since, numargs -#define MAKE_ARG(name, type, key_spec_index, token, summary, since, flags, numsubargs, deprecated_since) \ +#define MAKE_ARG(name, type, key_spec_index, token, summary, since, flags, numsubargs, deprecated_since) \ name, type, token, since, flags, numsubargs #define COMMAND_ARG cliCommandArg #define COMMAND_STRUCT commandDocs diff --git a/src/cluster.h b/src/cluster.h index 9961710f9d..2e4f33a3c9 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -5,8 +5,8 @@ * Cluster exported API. *----------------------------------------------------------------------------*/ -#define CLUSTER_SLOT_MASK_BITS 14 /* Number of bits used for slot id. */ -#define CLUSTER_SLOTS (1 << CLUSTER_SLOT_MASK_BITS) /* Total number of slots in cluster mode, which is 16384. */ +#define CLUSTER_SLOT_MASK_BITS 14 /* Number of bits used for slot id. */ +#define CLUSTER_SLOTS (1 << CLUSTER_SLOT_MASK_BITS) /* Total number of slots in cluster mode, which is 16384. */ #define CLUSTER_SLOT_MASK ((unsigned long long)(CLUSTER_SLOTS - 1)) /* Bit mask for slot id stored in LSB. */ #define CLUSTER_OK 0 /* Everything looks ok */ #define CLUSTER_FAIL 1 /* The cluster can't work */ diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 994cc77844..0f87eaf621 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -144,7 +144,7 @@ static inline int defaultClientPort(void) { return server.tls_cluster ? server.tls_port : server.port; } -#define isSlotUnclaimed(slot) \ +#define isSlotUnclaimed(slot) \ (server.cluster->slots[slot] == NULL || bitmapTestBit(server.cluster->owner_not_claiming_slot, slot)) #define RCVBUF_INIT_LEN 1024 @@ -191,7 +191,10 @@ dictType clusterSdsToListType = { }; typedef struct { - enum { ITER_DICT, ITER_LIST } type; + enum { + ITER_DICT, + ITER_LIST + } type; union { dictIterator di; listIter li; @@ -4576,7 +4579,7 @@ void clusterHandleReplicaFailover(void) { * elapsed, we can setup a new one. */ if (auth_age > auth_retry_time) { server.cluster->failover_auth_time = mstime() + - 500 + /* Fixed delay of 500 milliseconds, let FAIL msg propagate. */ + 500 + /* Fixed delay of 500 milliseconds, let FAIL msg propagate. */ random() % 500; /* Random delay between 0 and 500 milliseconds. */ server.cluster->failover_auth_count = 0; server.cluster->failover_auth_sent = 0; @@ -5509,10 +5512,14 @@ struct clusterNodeFlags { }; static struct clusterNodeFlags clusterNodeFlagsTable[] = { - {CLUSTER_NODE_MYSELF, "myself,"}, {CLUSTER_NODE_PRIMARY, "master,"}, - {CLUSTER_NODE_REPLICA, "slave,"}, {CLUSTER_NODE_PFAIL, "fail?,"}, - {CLUSTER_NODE_FAIL, "fail,"}, {CLUSTER_NODE_HANDSHAKE, "handshake,"}, - {CLUSTER_NODE_NOADDR, "noaddr,"}, {CLUSTER_NODE_NOFAILOVER, "nofailover,"}}; + {CLUSTER_NODE_MYSELF, "myself,"}, + {CLUSTER_NODE_PRIMARY, "master,"}, + {CLUSTER_NODE_REPLICA, "slave,"}, + {CLUSTER_NODE_PFAIL, "fail?,"}, + {CLUSTER_NODE_FAIL, "fail,"}, + {CLUSTER_NODE_HANDSHAKE, "handshake,"}, + {CLUSTER_NODE_NOADDR, "noaddr,"}, + {CLUSTER_NODE_NOFAILOVER, "nofailover,"}}; /* Concatenate the comma separated list of node flags to the given SDS * string 'ci'. */ diff --git a/src/cluster_legacy.h b/src/cluster_legacy.h index 7184a2b204..5280644e6e 100644 --- a/src/cluster_legacy.h +++ b/src/cluster_legacy.h @@ -292,9 +292,8 @@ static_assert(offsetof(clusterMsg, data) == 2256, "unexpected field offset"); /* Message flags better specify the packet content or are used to * provide some information about the node state. */ -#define CLUSTERMSG_FLAG0_PAUSED (1 << 0) /* Primary paused for manual failover. */ -#define CLUSTERMSG_FLAG0_FORCEACK \ - (1 << 1) /* Give ACK to AUTH_REQUEST even if \ +#define CLUSTERMSG_FLAG0_PAUSED (1 << 0) /* Primary paused for manual failover. */ +#define CLUSTERMSG_FLAG0_FORCEACK (1 << 1) /* Give ACK to AUTH_REQUEST even if \ primary is up. */ #define CLUSTERMSG_FLAG0_EXT_DATA (1 << 2) /* Message contains extension data */ diff --git a/src/cluster_slot_stats.c b/src/cluster_slot_stats.c index 8df49bc5ee..284208af54 100644 --- a/src/cluster_slot_stats.c +++ b/src/cluster_slot_stats.c @@ -8,7 +8,14 @@ #define UNASSIGNED_SLOT 0 -typedef enum { KEY_COUNT, CPU_USEC, NETWORK_BYTES_IN, NETWORK_BYTES_OUT, SLOT_STAT_COUNT, INVALID } slotStatType; +typedef enum { + KEY_COUNT, + CPU_USEC, + NETWORK_BYTES_IN, + NETWORK_BYTES_OUT, + SLOT_STAT_COUNT, + INVALID +} slotStatType; /* ----------------------------------------------------------------------------- * CLUSTER SLOT-STATS command diff --git a/src/commands.c b/src/commands.c index 36a4930a29..2d1877bdea 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1,12 +1,12 @@ #include "commands.h" #include "server.h" -#define MAKE_CMD(name, summary, complexity, since, doc_flags, replaced, deprecated, group, group_enum, history, \ - num_history, tips, num_tips, function, arity, flags, acl, key_specs, key_specs_num, get_keys, \ - numargs) \ - name, summary, complexity, since, doc_flags, replaced, deprecated, group_enum, history, num_history, tips, \ +#define MAKE_CMD(name, summary, complexity, since, doc_flags, replaced, deprecated, group, group_enum, history, \ + num_history, tips, num_tips, function, arity, flags, acl, key_specs, key_specs_num, get_keys, \ + numargs) \ + name, summary, complexity, since, doc_flags, replaced, deprecated, group_enum, history, num_history, tips, \ num_tips, function, arity, flags, acl, key_specs, key_specs_num, get_keys, numargs -#define MAKE_ARG(name, type, key_spec_index, token, summary, since, flags, numsubargs, deprecated_since) \ +#define MAKE_ARG(name, type, key_spec_index, token, summary, since, flags, numsubargs, deprecated_since) \ name, type, key_spec_index, token, summary, since, flags, deprecated_since, numsubargs #define COMMAND_STRUCT serverCommand #define COMMAND_ARG serverCommandArg diff --git a/src/config.c b/src/config.c index 2d4e703d95..6c03cbb476 100644 --- a/src/config.c +++ b/src/config.c @@ -51,76 +51,105 @@ typedef struct deprecatedConfig { const int argc_max; } deprecatedConfig; -configEnum maxmemory_policy_enum[] = {{"volatile-lru", MAXMEMORY_VOLATILE_LRU}, - {"volatile-lfu", MAXMEMORY_VOLATILE_LFU}, - {"volatile-random", MAXMEMORY_VOLATILE_RANDOM}, - {"volatile-ttl", MAXMEMORY_VOLATILE_TTL}, - {"allkeys-lru", MAXMEMORY_ALLKEYS_LRU}, - {"allkeys-lfu", MAXMEMORY_ALLKEYS_LFU}, - {"allkeys-random", MAXMEMORY_ALLKEYS_RANDOM}, - {"noeviction", MAXMEMORY_NO_EVICTION}, - {NULL, 0}}; - -configEnum syslog_facility_enum[] = {{"user", LOG_USER}, {"local0", LOG_LOCAL0}, - {"local1", LOG_LOCAL1}, {"local2", LOG_LOCAL2}, - {"local3", LOG_LOCAL3}, {"local4", LOG_LOCAL4}, - {"local5", LOG_LOCAL5}, {"local6", LOG_LOCAL6}, - {"local7", LOG_LOCAL7}, {NULL, 0}}; - -configEnum loglevel_enum[] = {{"debug", LL_DEBUG}, {"verbose", LL_VERBOSE}, {"notice", LL_NOTICE}, - {"warning", LL_WARNING}, {"nothing", LL_NOTHING}, {NULL, 0}}; - -configEnum supervised_mode_enum[] = {{"upstart", SUPERVISED_UPSTART}, - {"systemd", SUPERVISED_SYSTEMD}, - {"auto", SUPERVISED_AUTODETECT}, - {"no", SUPERVISED_NONE}, - {NULL, 0}}; - -configEnum aof_fsync_enum[] = {{"everysec", AOF_FSYNC_EVERYSEC}, - {"always", AOF_FSYNC_ALWAYS}, - {"no", AOF_FSYNC_NO}, - {NULL, 0}}; - -configEnum shutdown_on_sig_enum[] = {{"default", 0}, {"save", SHUTDOWN_SAVE}, {"nosave", SHUTDOWN_NOSAVE}, - {"now", SHUTDOWN_NOW}, {"force", SHUTDOWN_FORCE}, {NULL, 0}}; - -configEnum repl_diskless_load_enum[] = {{"disabled", REPL_DISKLESS_LOAD_DISABLED}, - {"on-empty-db", REPL_DISKLESS_LOAD_WHEN_DB_EMPTY}, - {"swapdb", REPL_DISKLESS_LOAD_SWAPDB}, - {NULL, 0}}; - -configEnum tls_auth_clients_enum[] = {{"no", TLS_CLIENT_AUTH_NO}, - {"yes", TLS_CLIENT_AUTH_YES}, - {"optional", TLS_CLIENT_AUTH_OPTIONAL}, - {NULL, 0}}; - -configEnum oom_score_adj_enum[] = {{"no", OOM_SCORE_ADJ_NO}, - {"yes", OOM_SCORE_RELATIVE}, - {"relative", OOM_SCORE_RELATIVE}, - {"absolute", OOM_SCORE_ADJ_ABSOLUTE}, - {NULL, 0}}; - -configEnum acl_pubsub_default_enum[] = {{"allchannels", SELECTOR_FLAG_ALLCHANNELS}, {"resetchannels", 0}, {NULL, 0}}; - -configEnum sanitize_dump_payload_enum[] = {{"no", SANITIZE_DUMP_NO}, - {"yes", SANITIZE_DUMP_YES}, - {"clients", SANITIZE_DUMP_CLIENTS}, - {NULL, 0}}; - -configEnum protected_action_enum[] = {{"no", PROTECTED_ACTION_ALLOWED_NO}, - {"yes", PROTECTED_ACTION_ALLOWED_YES}, - {"local", PROTECTED_ACTION_ALLOWED_LOCAL}, - {NULL, 0}}; - -configEnum cluster_preferred_endpoint_type_enum[] = {{"ip", CLUSTER_ENDPOINT_TYPE_IP}, - {"hostname", CLUSTER_ENDPOINT_TYPE_HOSTNAME}, - {"unknown-endpoint", CLUSTER_ENDPOINT_TYPE_UNKNOWN_ENDPOINT}, - {NULL, 0}}; - -configEnum propagation_error_behavior_enum[] = {{"ignore", PROPAGATION_ERR_BEHAVIOR_IGNORE}, - {"panic", PROPAGATION_ERR_BEHAVIOR_PANIC}, - {"panic-on-replicas", PROPAGATION_ERR_BEHAVIOR_PANIC_ON_REPLICAS}, - {NULL, 0}}; +configEnum maxmemory_policy_enum[] = { + {"volatile-lru", MAXMEMORY_VOLATILE_LRU}, + {"volatile-lfu", MAXMEMORY_VOLATILE_LFU}, + {"volatile-random", MAXMEMORY_VOLATILE_RANDOM}, + {"volatile-ttl", MAXMEMORY_VOLATILE_TTL}, + {"allkeys-lru", MAXMEMORY_ALLKEYS_LRU}, + {"allkeys-lfu", MAXMEMORY_ALLKEYS_LFU}, + {"allkeys-random", MAXMEMORY_ALLKEYS_RANDOM}, + {"noeviction", MAXMEMORY_NO_EVICTION}, + {NULL, 0}}; + +configEnum syslog_facility_enum[] = { + {"user", LOG_USER}, + {"local0", LOG_LOCAL0}, + {"local1", LOG_LOCAL1}, + {"local2", LOG_LOCAL2}, + {"local3", LOG_LOCAL3}, + {"local4", LOG_LOCAL4}, + {"local5", LOG_LOCAL5}, + {"local6", LOG_LOCAL6}, + {"local7", LOG_LOCAL7}, + {NULL, 0}}; + +configEnum loglevel_enum[] = { + {"debug", LL_DEBUG}, + {"verbose", LL_VERBOSE}, + {"notice", LL_NOTICE}, + {"warning", LL_WARNING}, + {"nothing", LL_NOTHING}, + {NULL, 0}}; + +configEnum supervised_mode_enum[] = { + {"upstart", SUPERVISED_UPSTART}, + {"systemd", SUPERVISED_SYSTEMD}, + {"auto", SUPERVISED_AUTODETECT}, + {"no", SUPERVISED_NONE}, + {NULL, 0}}; + +configEnum aof_fsync_enum[] = { + {"everysec", AOF_FSYNC_EVERYSEC}, + {"always", AOF_FSYNC_ALWAYS}, + {"no", AOF_FSYNC_NO}, + {NULL, 0}}; + +configEnum shutdown_on_sig_enum[] = { + {"default", 0}, + {"save", SHUTDOWN_SAVE}, + {"nosave", SHUTDOWN_NOSAVE}, + {"now", SHUTDOWN_NOW}, + {"force", SHUTDOWN_FORCE}, + {NULL, 0}}; + +configEnum repl_diskless_load_enum[] = { + {"disabled", REPL_DISKLESS_LOAD_DISABLED}, + {"on-empty-db", REPL_DISKLESS_LOAD_WHEN_DB_EMPTY}, + {"swapdb", REPL_DISKLESS_LOAD_SWAPDB}, + {NULL, 0}}; + +configEnum tls_auth_clients_enum[] = { + {"no", TLS_CLIENT_AUTH_NO}, + {"yes", TLS_CLIENT_AUTH_YES}, + {"optional", TLS_CLIENT_AUTH_OPTIONAL}, + {NULL, 0}}; + +configEnum oom_score_adj_enum[] = { + {"no", OOM_SCORE_ADJ_NO}, + {"yes", OOM_SCORE_RELATIVE}, + {"relative", OOM_SCORE_RELATIVE}, + {"absolute", OOM_SCORE_ADJ_ABSOLUTE}, + {NULL, 0}}; + +configEnum acl_pubsub_default_enum[] = { + {"allchannels", SELECTOR_FLAG_ALLCHANNELS}, + {"resetchannels", 0}, + {NULL, 0}}; + +configEnum sanitize_dump_payload_enum[] = { + {"no", SANITIZE_DUMP_NO}, + {"yes", SANITIZE_DUMP_YES}, + {"clients", SANITIZE_DUMP_CLIENTS}, + {NULL, 0}}; + +configEnum protected_action_enum[] = { + {"no", PROTECTED_ACTION_ALLOWED_NO}, + {"yes", PROTECTED_ACTION_ALLOWED_YES}, + {"local", PROTECTED_ACTION_ALLOWED_LOCAL}, + {NULL, 0}}; + +configEnum cluster_preferred_endpoint_type_enum[] = { + {"ip", CLUSTER_ENDPOINT_TYPE_IP}, + {"hostname", CLUSTER_ENDPOINT_TYPE_HOSTNAME}, + {"unknown-endpoint", CLUSTER_ENDPOINT_TYPE_UNKNOWN_ENDPOINT}, + {NULL, 0}}; + +configEnum propagation_error_behavior_enum[] = { + {"ignore", PROPAGATION_ERR_BEHAVIOR_IGNORE}, + {"panic", PROPAGATION_ERR_BEHAVIOR_PANIC}, + {"panic-on-replicas", PROPAGATION_ERR_BEHAVIOR_PANIC_ON_REPLICAS}, + {NULL, 0}}; /* Output buffer limits presets. */ clientBufferLimitsConfig clientBufferLimitsDefaults[CLIENT_TYPE_OBUF_COUNT] = { @@ -1760,10 +1789,10 @@ int rewriteConfig(char *path, int force_write) { #define LOADBUF_SIZE 256 static char loadbuf[LOADBUF_SIZE]; -#define embedCommonConfig(config_name, config_alias, config_flags) \ +#define embedCommonConfig(config_name, config_alias, config_flags) \ .name = (config_name), .alias = (config_alias), .flags = (config_flags), -#define embedConfigInterface(initfn, setfn, getfn, rewritefn, applyfn) \ +#define embedConfigInterface(initfn, setfn, getfn, rewritefn, applyfn) \ .interface = {.init = (initfn), .set = (setfn), .get = (getfn), .rewrite = (rewritefn), .apply = (applyfn)}, /* What follows is the generic config types that are supported. To add a new @@ -1814,16 +1843,16 @@ static void boolConfigRewrite(standardConfig *config, const char *name, struct r rewriteConfigYesNoOption(state, name, val, config->data.yesno.default_value); } -#define createBoolConfig(name, alias, flags, config_addr, default, is_valid, apply) \ - { \ - embedCommonConfig(name, alias, flags) \ - embedConfigInterface(boolConfigInit, boolConfigSet, boolConfigGet, boolConfigRewrite, apply) \ - .type = BOOL_CONFIG, \ - .data.yesno = { \ - .config = &(config_addr), \ - .default_value = (default), \ - .is_valid_fn = (is_valid), \ - } \ +#define createBoolConfig(name, alias, flags, config_addr, default, is_valid, apply) \ + { \ + embedCommonConfig(name, alias, flags) \ + embedConfigInterface(boolConfigInit, boolConfigSet, boolConfigGet, boolConfigRewrite, apply) \ + .type = BOOL_CONFIG, \ + .data.yesno = { \ + .config = &(config_addr), \ + .default_value = (default), \ + .is_valid_fn = (is_valid), \ + } \ } /* String Configs */ @@ -1904,30 +1933,30 @@ static void sdsConfigRewrite(standardConfig *config, const char *name, struct re #define ALLOW_EMPTY_STRING 0 #define EMPTY_STRING_IS_NULL 1 -#define createStringConfig(name, alias, flags, empty_to_null, config_addr, default, is_valid, apply) \ - { \ - embedCommonConfig(name, alias, flags) \ - embedConfigInterface(stringConfigInit, stringConfigSet, stringConfigGet, stringConfigRewrite, apply) \ - .type = STRING_CONFIG, \ - .data.string = { \ - .config = &(config_addr), \ - .default_value = (default), \ - .is_valid_fn = (is_valid), \ - .convert_empty_to_null = (empty_to_null), \ - } \ - } - -#define createSDSConfig(name, alias, flags, empty_to_null, config_addr, default, is_valid, apply) \ - { \ - embedCommonConfig(name, alias, flags) \ - embedConfigInterface(sdsConfigInit, sdsConfigSet, sdsConfigGet, sdsConfigRewrite, apply) \ - .type = SDS_CONFIG, \ - .data.sds = { \ - .config = &(config_addr), \ - .default_value = (default), \ - .is_valid_fn = (is_valid), \ - .convert_empty_to_null = (empty_to_null), \ - } \ +#define createStringConfig(name, alias, flags, empty_to_null, config_addr, default, is_valid, apply) \ + { \ + embedCommonConfig(name, alias, flags) \ + embedConfigInterface(stringConfigInit, stringConfigSet, stringConfigGet, stringConfigRewrite, apply) \ + .type = STRING_CONFIG, \ + .data.string = { \ + .config = &(config_addr), \ + .default_value = (default), \ + .is_valid_fn = (is_valid), \ + .convert_empty_to_null = (empty_to_null), \ + } \ + } + +#define createSDSConfig(name, alias, flags, empty_to_null, config_addr, default, is_valid, apply) \ + { \ + embedCommonConfig(name, alias, flags) \ + embedConfigInterface(sdsConfigInit, sdsConfigSet, sdsConfigGet, sdsConfigRewrite, apply) \ + .type = SDS_CONFIG, \ + .data.sds = { \ + .config = &(config_addr), \ + .default_value = (default), \ + .is_valid_fn = (is_valid), \ + .convert_empty_to_null = (empty_to_null), \ + } \ } /* Enum configs */ @@ -1977,17 +2006,17 @@ static void enumConfigRewrite(standardConfig *config, const char *name, struct r rewriteConfigEnumOption(state, name, val, config); } -#define createEnumConfig(name, alias, flags, enum, config_addr, default, is_valid, apply) \ - { \ - embedCommonConfig(name, alias, flags) \ - embedConfigInterface(enumConfigInit, enumConfigSet, enumConfigGet, enumConfigRewrite, apply) \ - .type = ENUM_CONFIG, \ - .data.enumd = { \ - .config = &(config_addr), \ - .default_value = (default), \ - .is_valid_fn = (is_valid), \ - .enum_value = (enum), \ - } \ +#define createEnumConfig(name, alias, flags, enum, config_addr, default, is_valid, apply) \ + { \ + embedCommonConfig(name, alias, flags) \ + embedConfigInterface(enumConfigInit, enumConfigSet, enumConfigGet, enumConfigRewrite, apply) \ + .type = ENUM_CONFIG, \ + .data.enumd = { \ + .config = &(config_addr), \ + .default_value = (default), \ + .is_valid_fn = (is_valid), \ + .enum_value = (enum), \ + } \ } /* Gets a 'long long val' and sets it into the union, using a macro to get @@ -2022,30 +2051,30 @@ int setNumericType(standardConfig *config, long long val, const char **err) { /* Gets a 'long long val' and sets it with the value from the union, using a * macro to get compile time type check. */ -#define GET_NUMERIC_TYPE(val) \ - if (config->data.numeric.numeric_type == NUMERIC_TYPE_INT) { \ - val = *(config->data.numeric.config.i); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_UINT) { \ - val = *(config->data.numeric.config.ui); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_LONG) { \ - val = *(config->data.numeric.config.l); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_ULONG) { \ - val = *(config->data.numeric.config.ul); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_LONG_LONG) { \ - if (config->flags & MODULE_CONFIG) \ - val = getModuleNumericConfig(config->privdata); \ - else \ - val = *(config->data.numeric.config.ll); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_ULONG_LONG) { \ - val = *(config->data.numeric.config.ull); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_SIZE_T) { \ - val = *(config->data.numeric.config.st); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_SSIZE_T) { \ - val = *(config->data.numeric.config.sst); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_OFF_T) { \ - val = *(config->data.numeric.config.ot); \ - } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_TIME_T) { \ - val = *(config->data.numeric.config.tt); \ +#define GET_NUMERIC_TYPE(val) \ + if (config->data.numeric.numeric_type == NUMERIC_TYPE_INT) { \ + val = *(config->data.numeric.config.i); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_UINT) { \ + val = *(config->data.numeric.config.ui); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_LONG) { \ + val = *(config->data.numeric.config.l); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_ULONG) { \ + val = *(config->data.numeric.config.ul); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_LONG_LONG) { \ + if (config->flags & MODULE_CONFIG) \ + val = getModuleNumericConfig(config->privdata); \ + else \ + val = *(config->data.numeric.config.ll); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_ULONG_LONG) { \ + val = *(config->data.numeric.config.ull); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_SIZE_T) { \ + val = *(config->data.numeric.config.st); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_SSIZE_T) { \ + val = *(config->data.numeric.config.sst); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_OFF_T) { \ + val = *(config->data.numeric.config.ot); \ + } else if (config->data.numeric.numeric_type == NUMERIC_TYPE_TIME_T) { \ + val = *(config->data.numeric.config.tt); \ } /* Numeric configs */ @@ -2187,57 +2216,57 @@ static void numericConfigRewrite(standardConfig *config, const char *name, struc } } -#define embedCommonNumericalConfig(name, alias, _flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - { \ - embedCommonConfig(name, alias, _flags) \ - embedConfigInterface(numericConfigInit, numericConfigSet, numericConfigGet, numericConfigRewrite, apply) \ - .type = NUMERIC_CONFIG, \ - .data.numeric = { \ - .lower_bound = (lower), \ - .upper_bound = (upper), \ - .default_value = (default), \ - .is_valid_fn = (is_valid), \ +#define embedCommonNumericalConfig(name, alias, _flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + { \ + embedCommonConfig(name, alias, _flags) \ + embedConfigInterface(numericConfigInit, numericConfigSet, numericConfigGet, numericConfigRewrite, apply) \ + .type = NUMERIC_CONFIG, \ + .data.numeric = { \ + .lower_bound = (lower), \ + .upper_bound = (upper), \ + .default_value = (default), \ + .is_valid_fn = (is_valid), \ .flags = (num_conf_flags), -#define createIntConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_INT, \ - .config.i = &(config_addr) \ - } \ +#define createIntConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_INT, \ + .config.i = &(config_addr) \ + } \ } -#define createUIntConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_UINT, \ - .config.ui = &(config_addr) \ - } \ +#define createUIntConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_UINT, \ + .config.ui = &(config_addr) \ + } \ } -#define createLongConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_LONG, \ - .config.l = &(config_addr) \ - } \ +#define createLongConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_LONG, \ + .config.l = &(config_addr) \ + } \ } -#define createULongConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_ULONG, \ - .config.ul = &(config_addr) \ - } \ +#define createULongConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_ULONG, \ + .config.ul = &(config_addr) \ + } \ } -#define createLongLongConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_LONG_LONG, \ - .config.ll = &(config_addr) \ - } \ +#define createLongLongConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_LONG_LONG, \ + .config.ll = &(config_addr) \ + } \ } #define createULongLongConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ @@ -2248,40 +2277,40 @@ static void numericConfigRewrite(standardConfig *config, const char *name, struc } \ } -#define createSizeTConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_SIZE_T, \ - .config.st = &(config_addr) \ - } \ +#define createSizeTConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_SIZE_T, \ + .config.st = &(config_addr) \ + } \ } -#define createSSizeTConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_SSIZE_T, \ - .config.sst = &(config_addr) \ - } \ +#define createSSizeTConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_SSIZE_T, \ + .config.sst = &(config_addr) \ + } \ } -#define createTimeTConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_TIME_T, \ - .config.tt = &(config_addr) \ - } \ +#define createTimeTConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_TIME_T, \ + .config.tt = &(config_addr) \ + } \ } -#define createOffTConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ - embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ - apply) \ - .numeric_type = NUMERIC_TYPE_OFF_T, \ - .config.ot = &(config_addr) \ - } \ +#define createOffTConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, apply) \ + embedCommonNumericalConfig(name, alias, flags, lower, upper, config_addr, default, num_conf_flags, is_valid, \ + apply) \ + .numeric_type = NUMERIC_TYPE_OFF_T, \ + .config.ot = &(config_addr) \ + } \ } -#define createSpecialConfig(name, alias, modifiable, setfn, getfn, rewritefn, applyfn) \ - {.type = SPECIAL_CONFIG, \ +#define createSpecialConfig(name, alias, modifiable, setfn, getfn, rewritefn, applyfn) \ + {.type = SPECIAL_CONFIG, \ embedCommonConfig(name, alias, modifiable) embedConfigInterface(NULL, setfn, getfn, rewritefn, applyfn)} static int isValidActiveDefrag(int val, const char **err) { @@ -3054,7 +3083,6 @@ static int applyClientMaxMemoryUsage(const char **err) { } standardConfig static_configs[] = { - /* clang-format off */ /* Bool configs */ createBoolConfig("rdbchecksum", NULL, IMMUTABLE_CONFIG, server.rdb_checksum, 1, NULL, NULL), createBoolConfig("daemonize", NULL, IMMUTABLE_CONFIG, server.daemonize, 0, NULL, NULL), @@ -3066,7 +3094,7 @@ standardConfig static_configs[] = { createBoolConfig("activerehashing", NULL, MODIFIABLE_CONFIG, server.activerehashing, 1, NULL, NULL), createBoolConfig("stop-writes-on-bgsave-error", NULL, MODIFIABLE_CONFIG, server.stop_writes_on_bgsave_err, 1, NULL, NULL), createBoolConfig("set-proc-title", NULL, IMMUTABLE_CONFIG, server.set_proc_title, 1, NULL, NULL), /* Should setproctitle be used? */ - createBoolConfig("dynamic-hz", NULL, MODIFIABLE_CONFIG, server.dynamic_hz, 1, NULL, NULL), /* Adapt hz to # of clients.*/ + createBoolConfig("dynamic-hz", NULL, MODIFIABLE_CONFIG, server.dynamic_hz, 1, NULL, NULL), /* Adapt hz to # of clients.*/ createBoolConfig("lazyfree-lazy-eviction", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_eviction, 1, NULL, NULL), createBoolConfig("lazyfree-lazy-expire", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_expire, 1, NULL, NULL), createBoolConfig("lazyfree-lazy-server-del", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.lazyfree_lazy_server_del, 1, NULL, NULL), @@ -3164,7 +3192,7 @@ standardConfig static_configs[] = { /* Integer configs */ createIntConfig("databases", NULL, IMMUTABLE_CONFIG, 1, INT_MAX, server.dbnum, 16, INTEGER_CONFIG, NULL, NULL), - createIntConfig("port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.port, 6379, INTEGER_CONFIG, NULL, updatePort), /* TCP port. */ + createIntConfig("port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.port, 6379, INTEGER_CONFIG, NULL, updatePort), /* TCP port. */ createIntConfig("io-threads", NULL, DEBUG_CONFIG | IMMUTABLE_CONFIG, 1, 128, server.io_threads_num, 1, INTEGER_CONFIG, NULL, NULL), /* Single threaded by default */ createIntConfig("events-per-io-thread", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.events_per_io_thread, 2, INTEGER_CONFIG, NULL, NULL), createIntConfig("prefetch-batch-max-size", NULL, MODIFIABLE_CONFIG, 0, 128, server.prefetch_batch_max_size, 16, INTEGER_CONFIG, NULL, NULL), @@ -3173,9 +3201,9 @@ standardConfig static_configs[] = { createIntConfig("list-max-listpack-size", "list-max-ziplist-size", MODIFIABLE_CONFIG, INT_MIN, INT_MAX, server.list_max_listpack_size, -2, INTEGER_CONFIG, NULL, NULL), createIntConfig("tcp-keepalive", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.tcpkeepalive, 300, INTEGER_CONFIG, NULL, NULL), createIntConfig("cluster-migration-barrier", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.cluster_migration_barrier, 1, INTEGER_CONFIG, NULL, NULL), - createIntConfig("active-defrag-cycle-min", NULL, MODIFIABLE_CONFIG, 1, 99, server.active_defrag_cycle_min, 1, INTEGER_CONFIG, NULL, updateDefragConfiguration), /* Default: 1% CPU min (at lower threshold) */ - createIntConfig("active-defrag-cycle-max", NULL, MODIFIABLE_CONFIG, 1, 99, server.active_defrag_cycle_max, 25, INTEGER_CONFIG, NULL, updateDefragConfiguration), /* Default: 25% CPU max (at upper threshold) */ - createIntConfig("active-defrag-threshold-lower", NULL, MODIFIABLE_CONFIG, 0, 1000, server.active_defrag_threshold_lower, 10, INTEGER_CONFIG, NULL, NULL), /* Default: don't defrag when fragmentation is below 10% */ + createIntConfig("active-defrag-cycle-min", NULL, MODIFIABLE_CONFIG, 1, 99, server.active_defrag_cycle_min, 1, INTEGER_CONFIG, NULL, updateDefragConfiguration), /* Default: 1% CPU min (at lower threshold) */ + createIntConfig("active-defrag-cycle-max", NULL, MODIFIABLE_CONFIG, 1, 99, server.active_defrag_cycle_max, 25, INTEGER_CONFIG, NULL, updateDefragConfiguration), /* Default: 25% CPU max (at upper threshold) */ + createIntConfig("active-defrag-threshold-lower", NULL, MODIFIABLE_CONFIG, 0, 1000, server.active_defrag_threshold_lower, 10, INTEGER_CONFIG, NULL, NULL), /* Default: don't defrag when fragmentation is below 10% */ createIntConfig("active-defrag-threshold-upper", NULL, MODIFIABLE_CONFIG, 0, 1000, server.active_defrag_threshold_upper, 100, INTEGER_CONFIG, NULL, updateDefragConfiguration), /* Default: maximum defrag force at 100% fragmentation */ createIntConfig("lfu-log-factor", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.lfu_log_factor, 10, INTEGER_CONFIG, NULL, NULL), createIntConfig("lfu-decay-time", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.lfu_decay_time, 1, INTEGER_CONFIG, NULL, NULL), @@ -3188,7 +3216,7 @@ standardConfig static_configs[] = { createIntConfig("tcp-backlog", NULL, IMMUTABLE_CONFIG, 0, INT_MAX, server.tcp_backlog, 511, INTEGER_CONFIG, NULL, NULL), /* TCP listen backlog. */ createIntConfig("cluster-port", NULL, IMMUTABLE_CONFIG, 0, 65535, server.cluster_port, 0, INTEGER_CONFIG, NULL, NULL), createIntConfig("cluster-announce-bus-port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.cluster_announce_bus_port, 0, INTEGER_CONFIG, NULL, updateClusterAnnouncedPort), /* Default: Use +10000 offset. */ - createIntConfig("cluster-announce-port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.cluster_announce_port, 0, INTEGER_CONFIG, NULL, updateClusterAnnouncedPort), /* Use server.port */ + createIntConfig("cluster-announce-port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.cluster_announce_port, 0, INTEGER_CONFIG, NULL, updateClusterAnnouncedPort), /* Use server.port */ createIntConfig("cluster-announce-tls-port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.cluster_announce_tls_port, 0, INTEGER_CONFIG, NULL, updateClusterAnnouncedPort), /* Use server.tls_port */ createIntConfig("repl-timeout", NULL, MODIFIABLE_CONFIG, 1, INT_MAX, server.repl_timeout, 60, INTEGER_CONFIG, NULL, NULL), createIntConfig("repl-ping-replica-period", "repl-ping-slave-period", MODIFIABLE_CONFIG, 1, INT_MAX, server.repl_ping_replica_period, 10, INTEGER_CONFIG, NULL, NULL), @@ -3244,7 +3272,7 @@ standardConfig static_configs[] = { createSizeTConfig("stream-node-max-bytes", NULL, MODIFIABLE_CONFIG, 0, LONG_MAX, server.stream_node_max_bytes, 4096, MEMORY_CONFIG, NULL, NULL), createSizeTConfig("zset-max-listpack-value", "zset-max-ziplist-value", MODIFIABLE_CONFIG, 0, LONG_MAX, server.zset_max_listpack_value, 64, MEMORY_CONFIG, NULL, NULL), createSizeTConfig("hll-sparse-max-bytes", NULL, MODIFIABLE_CONFIG, 0, LONG_MAX, server.hll_sparse_max_bytes, 3000, MEMORY_CONFIG, NULL, NULL), - createSizeTConfig("tracking-table-max-keys", NULL, MODIFIABLE_CONFIG, 0, LONG_MAX, server.tracking_table_max_keys, 1000000, INTEGER_CONFIG, NULL, NULL), /* Default: 1 million keys max. */ + createSizeTConfig("tracking-table-max-keys", NULL, MODIFIABLE_CONFIG, 0, LONG_MAX, server.tracking_table_max_keys, 1000000, INTEGER_CONFIG, NULL, NULL), /* Default: 1 million keys max. */ createSizeTConfig("client-query-buffer-limit", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, 1024 * 1024, LONG_MAX, server.client_max_querybuf_len, 1024 * 1024 * 1024, MEMORY_CONFIG, NULL, NULL), /* Default: 1GB max query buffer. */ createSSizeTConfig("maxmemory-clients", NULL, MODIFIABLE_CONFIG, -100, SSIZE_MAX, server.maxmemory_clients, 0, MEMORY_CONFIG | PERCENT_CONFIG, NULL, applyClientMaxMemoryUsage), @@ -3286,8 +3314,7 @@ standardConfig static_configs[] = { createSpecialConfig("latency-tracking-info-percentiles", NULL, MODIFIABLE_CONFIG | MULTI_ARG_CONFIG, setConfigLatencyTrackingInfoPercentilesOutputOption, getConfigLatencyTrackingInfoPercentilesOutputOption, rewriteConfigLatencyTrackingInfoPercentilesOutputOption, NULL), /* NULL Terminator, this is dropped when we convert to the runtime array. */ - {NULL} - /* clang-format on */ + {NULL}, }; /* Create a new config by copying the passed in config. Returns 1 on success diff --git a/src/config.h b/src/config.h index 7ae69da46f..558b974f7d 100644 --- a/src/config.h +++ b/src/config.h @@ -77,8 +77,8 @@ #endif /* Test for backtrace() */ -#if defined(__APPLE__) || (defined(__linux__) && defined(__GLIBC__)) || defined(__FreeBSD__) || \ - ((defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun)) && defined(USE_BACKTRACE)) || \ +#if defined(__APPLE__) || (defined(__linux__) && defined(__GLIBC__)) || defined(__FreeBSD__) || \ + ((defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun)) && defined(USE_BACKTRACE)) || \ defined(__DragonFly__) || (defined(__UCLIBC__) && defined(__UCLIBC_HAS_BACKTRACE__)) #define HAVE_BACKTRACE 1 #endif @@ -98,21 +98,21 @@ #endif /* Test for accept4() */ -#if defined(__linux__) || defined(__FreeBSD__) || defined(OpenBSD5_7) || \ - (defined(__DragonFly__) && __DragonFly_version >= 400305) || \ +#if defined(__linux__) || defined(__FreeBSD__) || defined(OpenBSD5_7) || \ + (defined(__DragonFly__) && __DragonFly_version >= 400305) || \ (defined(__NetBSD__) && (defined(NetBSD8_0) || __NetBSD_Version__ >= 800000000)) #define HAVE_ACCEPT4 1 #endif /* Detect for pipe2() */ -#if defined(__linux__) || defined(__FreeBSD__) || defined(OpenBSD5_7) || \ - (defined(__DragonFly__) && __DragonFly_version >= 400106) || \ +#if defined(__linux__) || defined(__FreeBSD__) || defined(OpenBSD5_7) || \ + (defined(__DragonFly__) && __DragonFly_version >= 400106) || \ (defined(__NetBSD__) && (defined(NetBSD6_0) || __NetBSD_Version__ >= 600000000)) #define HAVE_PIPE2 1 #endif /* Detect for kqueue */ -#if (defined(__APPLE__) && defined(MAC_OS_10_6_DETECTED)) || defined(__DragonFly__) || defined(__FreeBSD__) || \ +#if (defined(__APPLE__) && defined(MAC_OS_10_6_DETECTED)) || defined(__DragonFly__) || defined(__FreeBSD__) || \ defined(__OpenBSD__) || defined(__NetBSD__) #define HAVE_KQUEUE 1 #endif @@ -176,7 +176,7 @@ * the plain fsync() call. */ #if (defined(__linux__) && defined(SYNC_FILE_RANGE_WAIT_BEFORE)) #define HAVE_SYNC_FILE_RANGE 1 -#define rdb_fsync_range(fd, off, size) \ +#define rdb_fsync_range(fd, off, size) \ sync_file_range(fd, off, size, SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE) #elif defined(__APPLE__) #define rdb_fsync_range(fd, off, size) fcntl(fd, F_FULLFSYNC) @@ -216,16 +216,16 @@ void setproctitle(const char *fmt, ...); #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/ -#if defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || defined(vax) || defined(ns32000) || \ - defined(sun386) || defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || defined(__alpha__) || \ +#if defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || defined(vax) || defined(ns32000) || \ + defined(sun386) || defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || defined(__alpha__) || \ defined(__alpha) #define BYTE_ORDER LITTLE_ENDIAN #endif -#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || defined(is68k) || defined(tahoe) || \ - defined(ibm032) || defined(ibm370) || defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) || \ - defined(apollo) || defined(__convex__) || defined(_CRAY) || defined(__hppa) || defined(__hp9000) || \ - defined(__hp9000s300) || defined(__hp9000s700) || defined(BIT_ZERO_ON_LEFT) || defined(m68k) || \ +#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || defined(is68k) || defined(tahoe) || \ + defined(ibm032) || defined(ibm370) || defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) || \ + defined(apollo) || defined(__convex__) || defined(_CRAY) || defined(__hppa) || defined(__hp9000) || \ + defined(__hp9000s300) || defined(__hp9000s700) || defined(BIT_ZERO_ON_LEFT) || defined(m68k) || \ defined(__sparc) || (defined(__APPLE__) && defined(__POWERPC__)) #define BYTE_ORDER BIG_ENDIAN #endif diff --git a/src/debug.c b/src/debug.c index 7314faa2eb..be1abf46b4 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1169,20 +1169,20 @@ int bugReportStart(void) { /* Returns the current eip and set it to the given new value (if its not NULL) */ static void *getAndSetMcontextEip(ucontext_t *uc, void *eip) { -#define NOT_SUPPORTED() \ - do { \ - UNUSED(uc); \ - UNUSED(eip); \ - return NULL; \ +#define NOT_SUPPORTED() \ + do { \ + UNUSED(uc); \ + UNUSED(eip); \ + return NULL; \ } while (0) -#define GET_SET_RETURN(target_var, new_val) \ - do { \ - void *old_val = (void *)target_var; \ - if (new_val) { \ - void **temp = (void **)&target_var; \ - *temp = new_val; \ - } \ - return old_val; \ +#define GET_SET_RETURN(target_var, new_val) \ + do { \ + void *old_val = (void *)target_var; \ + if (new_val) { \ + void **temp = (void **)&target_var; \ + *temp = new_val; \ + } \ + return old_val; \ } while (0) #if defined(__APPLE__) && !defined(MAC_OS_10_6_DETECTED) /* OSX < 10.6 */ @@ -1284,10 +1284,10 @@ void logStackContent(void **sp) { /* Log dump of processor registers */ void logRegisters(ucontext_t *uc) { serverLog(LL_WARNING | LL_RAW, "\n------ REGISTERS ------\n"); -#define NOT_SUPPORTED() \ - do { \ - UNUSED(uc); \ - serverLog(LL_WARNING, " Dumping of registers not supported for this OS/arch"); \ +#define NOT_SUPPORTED() \ + do { \ + UNUSED(uc); \ + serverLog(LL_WARNING, " Dumping of registers not supported for this OS/arch"); \ } while (0) /* OSX */ diff --git a/src/debugmacro.h b/src/debugmacro.h index 7113367cef..fa7b9da117 100644 --- a/src/debugmacro.h +++ b/src/debugmacro.h @@ -34,13 +34,13 @@ #define _REDIS_DEBUGMACRO_H_ #include -#define D(...) \ - do { \ - FILE *fp = fopen("/tmp/log.txt", "a"); \ - fprintf(fp, "%s:%s:%d:\t", __FILE__, __func__, __LINE__); \ - fprintf(fp, __VA_ARGS__); \ - fprintf(fp, "\n"); \ - fclose(fp); \ +#define D(...) \ + do { \ + FILE *fp = fopen("/tmp/log.txt", "a"); \ + fprintf(fp, "%s:%s:%d:\t", __FILE__, __func__, __LINE__); \ + fprintf(fp, __VA_ARGS__); \ + fprintf(fp, "\n"); \ + fclose(fp); \ } while (0) #endif /* _REDIS_DEBUGMACRO_H_ */ diff --git a/src/dict.c b/src/dict.c index 3b9ffb91d8..f164820584 100644 --- a/src/dict.c +++ b/src/dict.c @@ -885,37 +885,37 @@ void dictTwoPhaseUnlinkFree(dict *d, dictEntry *he, dictEntry **plink, int table } /* In the macros below, `de` stands for dict entry. */ -#define DICT_SET_VALUE(de, field, val) \ - { \ - if (entryIsNormal(de)) { \ - dictEntryNormal *_de = decodeEntryNormal(de); \ - _de->field = val; \ - } else if (entryIsEmbedded(de)) { \ - dictEntryEmbedded *_de = decodeEntryEmbedded(de); \ - _de->field = val; \ - } else { \ - panic("Entry type not supported"); \ - } \ +#define DICT_SET_VALUE(de, field, val) \ + { \ + if (entryIsNormal(de)) { \ + dictEntryNormal *_de = decodeEntryNormal(de); \ + _de->field = val; \ + } else if (entryIsEmbedded(de)) { \ + dictEntryEmbedded *_de = decodeEntryEmbedded(de); \ + _de->field = val; \ + } else { \ + panic("Entry type not supported"); \ + } \ } -#define DICT_INCR_VALUE(de, field, val) \ - { \ - if (entryIsNormal(de)) { \ - dictEntryNormal *_de = decodeEntryNormal(de); \ - _de->field += val; \ - } else if (entryIsEmbedded(de)) { \ - dictEntryEmbedded *_de = decodeEntryEmbedded(de); \ - _de->field += val; \ - } else { \ - panic("Entry type not supported"); \ - } \ +#define DICT_INCR_VALUE(de, field, val) \ + { \ + if (entryIsNormal(de)) { \ + dictEntryNormal *_de = decodeEntryNormal(de); \ + _de->field += val; \ + } else if (entryIsEmbedded(de)) { \ + dictEntryEmbedded *_de = decodeEntryEmbedded(de); \ + _de->field += val; \ + } else { \ + panic("Entry type not supported"); \ + } \ } -#define DICT_GET_VALUE(de, field) \ - (entryIsNormal(de) ? decodeEntryNormal(de)->field \ - : (entryIsEmbedded(de) ? decodeEntryEmbedded(de)->field \ +#define DICT_GET_VALUE(de, field) \ + (entryIsNormal(de) ? decodeEntryNormal(de)->field \ + : (entryIsEmbedded(de) ? decodeEntryEmbedded(de)->field \ : (panic("Entry type not supported"), ((dictEntryNormal *)de)->field))) -#define DICT_GET_VALUE_PTR(de, field) \ - (entryIsNormal(de) \ - ? &decodeEntryNormal(de)->field \ +#define DICT_GET_VALUE_PTR(de, field) \ + (entryIsNormal(de) \ + ? &decodeEntryNormal(de)->field \ : (entryIsEmbedded(de) ? &decodeEntryEmbedded(de)->field : (panic("Entry type not supported"), NULL))) void dictSetKey(dict *d, dictEntry *de, void *key) { diff --git a/src/dict.h b/src/dict.h index 322b009c43..1c9e059baa 100644 --- a/src/dict.h +++ b/src/dict.h @@ -144,15 +144,15 @@ typedef struct { #define DICT_HT_INITIAL_SIZE (1 << (DICT_HT_INITIAL_EXP)) /* ------------------------------- Macros ------------------------------------*/ -#define dictFreeVal(d, entry) \ - do { \ - if ((d)->type->valDestructor) (d)->type->valDestructor((d), dictGetVal(entry)); \ +#define dictFreeVal(d, entry) \ + do { \ + if ((d)->type->valDestructor) (d)->type->valDestructor((d), dictGetVal(entry)); \ } while (0) -#define dictFreeKey(d, entry) \ +#define dictFreeKey(d, entry) \ if ((d)->type->keyDestructor) (d)->type->keyDestructor((d), dictGetKey(entry)) -#define dictCompareKeys(d, key1, key2) \ +#define dictCompareKeys(d, key1, key2) \ (((d)->type->keyCompare) ? (d)->type->keyCompare((d), key1, key2) : (key1) == (key2)) #define dictMetadata(d) (&(d)->metadata) diff --git a/src/eval.c b/src/eval.c index 580c35bdcc..048ff5c4e3 100644 --- a/src/eval.c +++ b/src/eval.c @@ -667,27 +667,25 @@ void evalShaRoCommand(client *c) { void scriptCommand(client *c) { if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr, "help")) { - /* clang-format off */ const char *help[] = { -"DEBUG (YES|SYNC|NO)", -" Set the debug mode for subsequent scripts executed.", -"EXISTS [ ...]", -" Return information about the existence of the scripts in the script cache.", -"FLUSH [ASYNC|SYNC]", -" Flush the Lua scripts cache. Very dangerous on replicas.", -" When called without the optional mode argument, the behavior is determined", -" by the lazyfree-lazy-user-flush configuration directive. Valid modes are:", -" * ASYNC: Asynchronously flush the scripts cache.", -" * SYNC: Synchronously flush the scripts cache.", -"KILL", -" Kill the currently executing Lua script.", -"LOAD