diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index bb74bafbdde89f64e5531735fa271a6afd52146d..e3e52d46fff3cc25acea389a01e695159197011d 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -117,7 +117,7 @@ extern "C" { #define POW2(x) ((x) * (x)) -int taosRand(void); +uint32_t taosRand(void); int32_t strdequote(char *src); diff --git a/src/util/src/tkvstore.c b/src/util/src/tkvstore.c index 07da337bc1778f62798ffcaca05fce5616916a94..8e7b9b30f1550e0f3d8f1c9668a7417ed89e540e 100644 --- a/src/util/src/tkvstore.c +++ b/src/util/src/tkvstore.c @@ -445,10 +445,11 @@ static void *tdDecodeKVRecord(void *buf, SKVRecord *pRecord) { } static int tdRestoreKVStore(SKVStore *pStore) { - char tbuf[128] = "\0"; - void * buf = NULL; - int maxBufSize = 0; - SKVRecord rInfo = {0}; + char tbuf[128] = "\0"; + void * buf = NULL; + int maxBufSize = 0; + SKVRecord rInfo = {0}; + SHashMutableIterator *pIter = NULL; ASSERT(TD_KVSTORE_HEADER_SIZE == lseek(pStore->fd, 0, SEEK_CUR)); @@ -497,7 +498,7 @@ static int tdRestoreKVStore(SKVStore *pStore) { goto _err; } - SHashMutableIterator *pIter = taosHashCreateIter(pStore->map); + pIter = taosHashCreateIter(pStore->map); if (pIter == NULL) { uError("failed to create hash iter while opening KV store %s", pStore->fname); terrno = TSDB_CODE_COM_OUT_OF_MEMORY; diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index a2edce2387b53d6f8cd864d3495ae1cd31fd60b5..4469ad79b1395abd43b95d66a63e7c77ee8ff271 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -29,12 +29,12 @@ #ifdef WINDOWS -int taosRand(void) +uint32_t taosRand(void) { return rand(); } #else -int taosRand(void) +uint32_t taosRand(void) { int fd; int seed; @@ -50,7 +50,7 @@ int taosRand(void) close(fd); } - return seed; + return (uint32_t)seed; } #endif @@ -474,9 +474,9 @@ void getTmpfilePath(const char *fileNamePrefix, char *dstPath) { void taosRandStr(char* str, int32_t size) { const char* set = "abcdefghijklmnopqrstuvwxyz0123456789-_."; int32_t len = 39; - - for(int32_t i = 0; i < size; ++i) { - str[i] = set[taosRand()%len]; + + for (int32_t i = 0; i < size; ++i) { + str[i] = set[taosRand() % len]; } }