some warnings
This commit is contained in:
parent
362fb3d36a
commit
d5c57b68ab
|
@ -81,7 +81,7 @@ static FORCE_INLINE void __lock_destroy(void *lock) {
|
||||||
static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
|
static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
|
||||||
int32_t len = MIN(length, HASH_MAX_CAPACITY);
|
int32_t len = MIN(length, HASH_MAX_CAPACITY);
|
||||||
|
|
||||||
uint32_t i = 4;
|
int32_t i = 4;
|
||||||
while (i < len) i = (i << 1u);
|
while (i < len) i = (i << 1u);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool threadsafe) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the max slots is not defined by user
|
// the max slots is not defined by user
|
||||||
pHashObj->capacity = taosHashCapacity(capacity);
|
pHashObj->capacity = taosHashCapacity((int32_t)capacity);
|
||||||
assert((pHashObj->capacity & (pHashObj->capacity - 1)) == 0);
|
assert((pHashObj->capacity & (pHashObj->capacity - 1)) == 0);
|
||||||
|
|
||||||
pHashObj->hashFp = fn;
|
pHashObj->hashFp = fn;
|
||||||
|
@ -219,7 +219,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
|
||||||
__wr_lock(pHashObj->lock);
|
__wr_lock(pHashObj->lock);
|
||||||
|
|
||||||
uint32_t hashVal = 0;
|
uint32_t hashVal = 0;
|
||||||
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &hashVal);
|
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (uint32_t)keyLen, &hashVal);
|
||||||
|
|
||||||
if (pNode == NULL) { // no data in hash table with the specified key, add it into hash table
|
if (pNode == NULL) { // no data in hash table with the specified key, add it into hash table
|
||||||
taosHashTableResize(pHashObj);
|
taosHashTableResize(pHashObj);
|
||||||
|
@ -261,7 +261,7 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) {
|
||||||
__rd_lock(pHashObj->lock);
|
__rd_lock(pHashObj->lock);
|
||||||
|
|
||||||
uint32_t hashVal = 0;
|
uint32_t hashVal = 0;
|
||||||
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &hashVal);
|
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (int32_t)keyLen, &hashVal);
|
||||||
|
|
||||||
__unlock(pHashObj->lock);
|
__unlock(pHashObj->lock);
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
|
||||||
__wr_lock(pHashObj->lock);
|
__wr_lock(pHashObj->lock);
|
||||||
|
|
||||||
uint32_t val = 0;
|
uint32_t val = 0;
|
||||||
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, keyLen, &val);
|
SHashNode *pNode = doGetNodeFromHashTable(pHashObj, key, (uint32_t)keyLen, &val);
|
||||||
if (pNode == NULL) {
|
if (pNode == NULL) {
|
||||||
__unlock(pHashObj->lock);
|
__unlock(pHashObj->lock);
|
||||||
return;
|
return;
|
||||||
|
@ -460,7 +460,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
|
||||||
SHashNode *pNode = NULL;
|
SHashNode *pNode = NULL;
|
||||||
SHashNode *pNext = NULL;
|
SHashNode *pNext = NULL;
|
||||||
|
|
||||||
int32_t newSize = pHashObj->capacity << 1u;
|
int32_t newSize = (int32_t)(pHashObj->capacity) << 1u;
|
||||||
if (newSize > HASH_MAX_CAPACITY) {
|
if (newSize > HASH_MAX_CAPACITY) {
|
||||||
// uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
|
// uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
|
||||||
// pHashObj->capacity, HASH_MAX_CAPACITY);
|
// pHashObj->capacity, HASH_MAX_CAPACITY);
|
||||||
|
@ -539,7 +539,7 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
|
||||||
|
|
||||||
pNewNode->key = pNewNode->data + dsize;
|
pNewNode->key = pNewNode->data + dsize;
|
||||||
memcpy(pNewNode->key, key, keyLen);
|
memcpy(pNewNode->key, key, keyLen);
|
||||||
pNewNode->keyLen = keyLen;
|
pNewNode->keyLen = (uint32_t)keyLen;
|
||||||
|
|
||||||
pNewNode->hashVal = hashVal;
|
pNewNode->hashVal = hashVal;
|
||||||
return pNewNode;
|
return pNewNode;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
static void median(void *src, size_t size, size_t s, size_t e, const void *param, __ext_compar_fn_t comparFn, void* buf) {
|
static void median(void *src, size_t size, size_t s, size_t e, const void *param, __ext_compar_fn_t comparFn, void* buf) {
|
||||||
int32_t mid = ((e - s) >> 1u) + s;
|
int32_t mid = ((int32_t)(e - s) >> 1u) + (int32_t)s;
|
||||||
|
|
||||||
if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) == 1) {
|
if (comparFn(elePtrAt(src, size, mid), elePtrAt(src, size, s), param) == 1) {
|
||||||
doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf);
|
doswap(elePtrAt(src, size, mid), elePtrAt(src, size, s), size, buf);
|
||||||
|
@ -152,14 +152,14 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const
|
||||||
|
|
||||||
void taosqsort(void *src, size_t numOfElem, size_t size, const void* param, __ext_compar_fn_t comparFn) {
|
void taosqsort(void *src, size_t numOfElem, size_t size, const void* param, __ext_compar_fn_t comparFn) {
|
||||||
char *buf = calloc(1, size); // prepare the swap buffer
|
char *buf = calloc(1, size); // prepare the swap buffer
|
||||||
tqsortImpl(src, 0, numOfElem - 1, size, param, comparFn, buf);
|
tqsortImpl(src, 0, (int32_t)numOfElem - 1, (int32_t)size, param, comparFn, buf);
|
||||||
taosTFree(buf);
|
taosTFree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, __compar_fn_t compar, int flags) {
|
void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, __compar_fn_t compar, int flags) {
|
||||||
// TODO: need to check the correctness of this function
|
// TODO: need to check the correctness of this function
|
||||||
int l = 0;
|
int l = 0;
|
||||||
int r = nmemb;
|
int r = (int)nmemb;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int comparison;
|
int comparison;
|
||||||
|
|
||||||
|
|
|
@ -120,8 +120,8 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
|
||||||
|
|
||||||
void* dst = TARRAY_GET_ELEM(pArray, index);
|
void* dst = TARRAY_GET_ELEM(pArray, index);
|
||||||
|
|
||||||
int32_t remain = pArray->size - index;
|
int32_t remain = (int32_t)(pArray->size - index);
|
||||||
memmove(dst + pArray->elemSize, dst, pArray->elemSize * remain);
|
memmove((char*)dst + pArray->elemSize, (char*)dst, pArray->elemSize * remain);
|
||||||
memcpy(dst, pData, pArray->elemSize);
|
memcpy(dst, pData, pArray->elemSize);
|
||||||
|
|
||||||
pArray->size += 1;
|
pArray->size += 1;
|
||||||
|
@ -138,7 +138,7 @@ void taosArrayRemove(SArray* pArray, size_t index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t remain = pArray->size - index - 1;
|
size_t remain = pArray->size - index - 1;
|
||||||
memmove(pArray->pData + index * pArray->elemSize, pArray->pData + (index + 1) * pArray->elemSize, remain * pArray->elemSize);
|
memmove((char*)pArray->pData + index * pArray->elemSize, (char*)pArray->pData + (index + 1) * pArray->elemSize, remain * pArray->elemSize);
|
||||||
pArray->size -= 1;
|
pArray->size -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include "tbuffer.h"
|
#include "tbuffer.h"
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include <taoserror.h>
|
#include <taoserror.h>
|
||||||
|
|
|
@ -292,7 +292,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
|
||||||
uError("cache:%s, key:%p, failed to added into cache, out of memory", pCacheObj->name, key);
|
uError("cache:%s, key:%p, failed to added into cache, out of memory", pCacheObj->name, key);
|
||||||
}
|
}
|
||||||
} else { // old data exists, update the node
|
} else { // old data exists, update the node
|
||||||
pNode = taosUpdateCacheImpl(pCacheObj, pOld, key, keyLen, pData, dataSize, duration * 1000L);
|
pNode = taosUpdateCacheImpl(pCacheObj, pOld, key, (int32_t)keyLen, pData, (uint32_t)dataSize, duration * 1000L);
|
||||||
uDebug("cache:%s, key:%p, %p exist in cache, updated old:%p", pCacheObj->name, key, pNode->data, pOld);
|
uDebug("cache:%s, key:%p, %p exist in cache, updated old:%p", pCacheObj->name, key, pNode->data, pOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ SCacheDataNode *taosCreateCacheNode(const char *key, size_t keyLen, const char *
|
||||||
memcpy(pNewNode->data, pData, size);
|
memcpy(pNewNode->data, pData, size);
|
||||||
|
|
||||||
pNewNode->key = (char *)pNewNode + sizeof(SCacheDataNode) + size;
|
pNewNode->key = (char *)pNewNode + sizeof(SCacheDataNode) + size;
|
||||||
pNewNode->keySize = keyLen;
|
pNewNode->keySize = (uint16_t)keyLen;
|
||||||
|
|
||||||
memcpy(pNewNode->key, key, keyLen);
|
memcpy(pNewNode->key, key, keyLen);
|
||||||
|
|
||||||
|
@ -645,7 +645,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
|
||||||
while (taosHashIterNext(pIter)) {
|
while (taosHashIterNext(pIter)) {
|
||||||
SCacheDataNode *pNode = *(SCacheDataNode **)taosHashIterGet(pIter);
|
SCacheDataNode *pNode = *(SCacheDataNode **)taosHashIterGet(pIter);
|
||||||
|
|
||||||
if (pNode->expireTime < time && T_REF_VAL_GET(pNode) <= 0) {
|
if (pNode->expireTime < (uint64_t)time && T_REF_VAL_GET(pNode) <= 0) {
|
||||||
taosCacheReleaseNode(pCacheObj, pNode);
|
taosCacheReleaseNode(pCacheObj, pNode);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue