diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 0de6351e9..ee328e558 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -144,7 +144,6 @@ static inline int defaultClientPort(void) { dictType clusterNodesDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -157,7 +156,6 @@ dictType clusterNodesDictType = { dictType clusterNodesBlackListDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -168,7 +166,6 @@ dictType clusterNodesBlackListDictType = { dictType clusterSdsToListType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictListDestructor, /* val destructor */ diff --git a/src/config.c b/src/config.c index 3cd0cc5de..e46d01cf6 100644 --- a/src/config.c +++ b/src/config.c @@ -986,7 +986,6 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state); dictType optionToLineDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictListDestructor, /* val destructor */ @@ -996,7 +995,6 @@ dictType optionToLineDictType = { dictType optionSetDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ diff --git a/src/dict.c b/src/dict.c index 119c60ab5..ab53b4922 100644 --- a/src/dict.c +++ b/src/dict.c @@ -48,6 +48,8 @@ #include "serverassert.h" #include "monotonic.h" +#define UNUSED(V) ((void)V) + /* Using dictSetResizeEnabled() we make possible to disable * resizing and rehashing of the hash table as needed. This is very important * for us, as we use copy-on-write and don't want to move too much memory @@ -800,8 +802,9 @@ void dictSetKey(dict *d, dictEntry *de, void *key) { } void dictSetVal(dict *d, dictEntry *de, void *val) { + UNUSED(d); assert(entryHasValue(de)); - de->v.val = d->type->valDup ? d->type->valDup(d, val) : val; + de->v.val = val; } void dictSetSignedIntegerVal(dictEntry *de, int64_t val) { diff --git a/src/dict.h b/src/dict.h index 7ba22edf1..723e5a54c 100644 --- a/src/dict.h +++ b/src/dict.h @@ -54,7 +54,6 @@ typedef struct dictType { /* Callbacks */ uint64_t (*hashFunction)(const void *key); void *(*keyDup)(dict *d, const void *key); - void *(*valDup)(dict *d, const void *obj); int (*keyCompare)(dict *d, const void *key1, const void *key2); void (*keyDestructor)(dict *d, void *key); void (*valDestructor)(dict *d, void *obj); diff --git a/src/eval.c b/src/eval.c index d9c2c183d..10372be32 100644 --- a/src/eval.c +++ b/src/eval.c @@ -71,7 +71,6 @@ static uint64_t dictStrCaseHash(const void *key) { dictType shaScriptObjectDictType = { dictStrCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictLuaScriptDestructor, /* val destructor */ diff --git a/src/expire.c b/src/expire.c index 8d8147320..9261fbee2 100644 --- a/src/expire.c +++ b/src/expire.c @@ -470,7 +470,6 @@ void rememberSlaveKeyWithExpire(serverDb *db, robj *key) { static dictType dt = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ diff --git a/src/functions.c b/src/functions.c index 3076f3b90..08d869f02 100644 --- a/src/functions.c +++ b/src/functions.c @@ -65,7 +65,6 @@ typedef struct functionsLibMetaData { dictType engineDictType = { dictSdsCaseHash, /* hash function */ dictSdsDup, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -75,7 +74,6 @@ dictType engineDictType = { dictType functionDictType = { dictSdsCaseHash, /* hash function */ dictSdsDup, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -85,7 +83,6 @@ dictType functionDictType = { dictType engineStatsDictType = { dictSdsCaseHash, /* hash function */ dictSdsDup, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ engineStatsDispose, /* val destructor */ @@ -95,7 +92,6 @@ dictType engineStatsDictType = { dictType libraryFunctionDictType = { dictSdsHash, /* hash function */ dictSdsDup, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ engineFunctionDispose, /* val destructor */ @@ -105,7 +101,6 @@ dictType libraryFunctionDictType = { dictType librariesDictType = { dictSdsHash, /* hash function */ dictSdsDup, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ engineLibraryDispose, /* val destructor */ diff --git a/src/kvstore.c b/src/kvstore.c index 70e204315..8de74c724 100644 --- a/src/kvstore.c +++ b/src/kvstore.c @@ -794,8 +794,9 @@ void kvstoreDictSetKey(kvstore *kvs, int didx, dictEntry *de, void *key) { } void kvstoreDictSetVal(kvstore *kvs, int didx, dictEntry *de, void *val) { - dict *d = kvstoreGetDict(kvs, didx); - dictSetVal(d, de, val); + UNUSED(kvs); + UNUSED(didx); + dictSetVal(NULL, de, val); } dictEntry * diff --git a/src/latency.c b/src/latency.c index 78f3cc3ed..f9ab4905d 100644 --- a/src/latency.c +++ b/src/latency.c @@ -51,7 +51,6 @@ void dictVanillaFree(dict *d, void *val); dictType latencyTimeSeriesDictType = { dictStringHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictStringKeyCompare, /* key compare */ dictVanillaFree, /* key destructor */ dictVanillaFree, /* val destructor */ diff --git a/src/module.c b/src/module.c index f82f30326..ebb3d0e6c 100644 --- a/src/module.c +++ b/src/module.c @@ -11780,7 +11780,6 @@ int dictCStringKeyCompare(dict *d, const void *key1, const void *key2) { dictType moduleAPIDictType = { dictCStringKeyHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictCStringKeyCompare, /* key compare */ NULL, /* key destructor */ NULL, /* val destructor */ @@ -11811,7 +11810,6 @@ void moduleInitModulesSystemLast(void) { dictType sdsKeyValueHashDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictSdsDestructor, /* val destructor */ diff --git a/src/sentinel.c b/src/sentinel.c index f4becdca2..e705b653d 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -430,7 +430,6 @@ void dictInstancesValDestructor(dict *d, void *obj) { dictType instancesDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* key destructor */ dictInstancesValDestructor, /* val destructor */ @@ -444,7 +443,6 @@ dictType instancesDictType = { dictType leaderVotesDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* key destructor */ NULL, /* val destructor */ @@ -455,7 +453,6 @@ dictType leaderVotesDictType = { dictType renamedCommandsDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictSdsDestructor, /* val destructor */ diff --git a/src/server.c b/src/server.c index bf4967c10..e01c125d9 100644 --- a/src/server.c +++ b/src/server.c @@ -424,7 +424,6 @@ int dictResizeAllowed(size_t moreMem, double usedRatio) { dictType objectKeyPointerValueDictType = { dictEncObjHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictEncObjKeyCompare, /* key compare */ dictObjectDestructor, /* key destructor */ NULL, /* val destructor */ @@ -436,7 +435,6 @@ dictType objectKeyPointerValueDictType = { dictType objectKeyHeapPointerValueDictType = { dictEncObjHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictEncObjKeyCompare, /* key compare */ dictObjectDestructor, /* key destructor */ dictVanillaFree, /* val destructor */ @@ -447,7 +445,6 @@ dictType objectKeyHeapPointerValueDictType = { dictType setDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -460,7 +457,6 @@ dictType setDictType = { dictType zsetDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* Note: SDS string shared & freed by skiplist */ NULL, /* val destructor */ @@ -471,7 +467,6 @@ dictType zsetDictType = { dictType dbDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictObjectDestructor, /* val destructor */ @@ -482,7 +477,6 @@ dictType dbDictType = { dictType dbExpiresDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* key destructor */ NULL, /* val destructor */ @@ -493,7 +487,6 @@ dictType dbExpiresDictType = { dictType commandTableDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -504,7 +497,6 @@ dictType commandTableDictType = { dictType hashDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictSdsDestructor, /* val destructor */ @@ -515,7 +507,6 @@ dictType hashDictType = { dictType sdsReplyDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* key destructor */ NULL, /* val destructor */ @@ -528,7 +519,6 @@ dictType sdsReplyDictType = { dictType keylistDictType = { dictObjHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictObjKeyCompare, /* key compare */ dictObjectDestructor, /* key destructor */ dictListDestructor, /* val destructor */ @@ -540,7 +530,6 @@ dictType keylistDictType = { dictType objToDictDictType = { dictObjHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictObjKeyCompare, /* key compare */ dictObjectDestructor, /* key destructor */ dictDictDestructor, /* val destructor */ @@ -552,7 +541,6 @@ dictType objToDictDictType = { dictType modulesDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -563,7 +551,6 @@ dictType modulesDictType = { dictType migrateCacheDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -575,7 +562,6 @@ dictType migrateCacheDictType = { dictType stringSetDictType = { dictCStrCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictCStrKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -587,7 +573,6 @@ dictType stringSetDictType = { dictType externalStringType = { dictCStrCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictCStrKeyCaseCompare, /* key compare */ NULL, /* key destructor */ NULL, /* val destructor */ @@ -599,7 +584,6 @@ dictType externalStringType = { dictType sdsHashDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCaseCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictVanillaFree, /* val destructor */ @@ -610,7 +594,6 @@ dictType sdsHashDictType = { dictType clientDictType = { dictClientHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictClientKeyCompare, /* key compare */ .no_value = 1 /* no values in this dict */ }; diff --git a/src/t_zset.c b/src/t_zset.c index 3ebc9b86d..216ed165d 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -2527,7 +2527,6 @@ static void zdiff(zsetopsrc *src, long setnum, zset *dstzset, size_t *maxelelen, dictType setAccumulatorDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* key destructor */ NULL, /* val destructor */ diff --git a/src/unit/test_kvstore.c b/src/unit/test_kvstore.c index f7c0b1a4f..abf620a4f 100644 --- a/src/unit/test_kvstore.c +++ b/src/unit/test_kvstore.c @@ -10,7 +10,7 @@ void freeTestCallback(dict *d, void *val) { zfree(val); } -dictType KvstoreDictTestType = {hashTestCallback, NULL, NULL, NULL, freeTestCallback, NULL, NULL}; +dictType KvstoreDictTestType = {hashTestCallback, NULL, NULL, freeTestCallback, NULL, NULL}; char *stringFromInt(int value) { char buf[32]; diff --git a/src/valkey-benchmark.c b/src/valkey-benchmark.c index cb944fac0..47d948347 100644 --- a/src/valkey-benchmark.c +++ b/src/valkey-benchmark.c @@ -1243,7 +1243,6 @@ static int fetchClusterSlotsConfiguration(client c) { static dictType dtype = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* key destructor */ NULL, /* val destructor */ diff --git a/src/valkey-cli.c b/src/valkey-cli.c index 5a3d66fc4..333a39752 100644 --- a/src/valkey-cli.c +++ b/src/valkey-cli.c @@ -882,7 +882,6 @@ static void cliInitHelp(void) { dictType groupsdt = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ NULL, /* val destructor */ @@ -3544,7 +3543,6 @@ typedef struct clusterManagerLink { static dictType clusterManagerDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* key destructor */ dictSdsDestructor, /* val destructor */ @@ -3554,7 +3552,6 @@ static dictType clusterManagerDictType = { static dictType clusterManagerLinkDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ dictSdsDestructor, /* key destructor */ dictListDestructor, /* val destructor */ @@ -8628,7 +8625,6 @@ void type_free(dict *d, void *val) { static dictType typeinfoDictType = { dictSdsHash, /* hash function */ NULL, /* key dup */ - NULL, /* val dup */ dictSdsKeyCompare, /* key compare */ NULL, /* key destructor (owned by the value)*/ type_free, /* val destructor */