From ecdb23c9dbe7f69ae5b5c4c4957821799de3af75 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 20 Jan 2022 23:39:54 -0800 Subject: [PATCH] Remove warnings and adjust dependencies --- include/util/compare.h | 68 ++++++++++++++++++------------------- source/util/src/compare.c | 16 ++++----- source/util/src/tskiplist.c | 12 +++++-- tests/test/c/create_table.c | 4 +-- 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/include/util/compare.h b/include/util/compare.h index 461552ca7b..70a8134b35 100644 --- a/include/util/compare.h +++ b/include/util/compare.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_UTIL_COMPARE_H -#define _TD_UTIL_COMPARE_H +#ifndef _TD_UTIL_COMPARE_H_ +#define _TD_UTIL_COMPARE_H_ #ifdef __cplusplus extern "C" { @@ -35,67 +35,65 @@ extern "C" { #define FLT_GREATEREQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) > (_y))) #define FLT_LESSEQUAL(_x, _y) (FLT_EQUAL((_x), (_y)) || ((_x) < (_y))) -#define PATTERN_COMPARE_INFO_INITIALIZER { '%', '_' } +#define PATTERN_COMPARE_INFO_INITIALIZER \ + { '%', '_' } typedef struct SPatternCompareInfo { char matchAll; // symbol for match all wildcard, default: '%' char matchOne; // symbol for match one wildcard, default: '_' } SPatternCompareInfo; -int patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo); +int32_t patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo); -int WCSPatternMatch(const wchar_t *pattern, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo); +int32_t WCSPatternMatch(const wchar_t *pattern, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo); - -int32_t taosArrayCompareString(const void* a, const void* b); +int32_t taosArrayCompareString(const void *a, const void *b); int32_t setCompareBytes1(const void *pLeft, const void *pRight); - int32_t setCompareBytes2(const void *pLeft, const void *pRight); - int32_t setCompareBytes4(const void *pLeft, const void *pRight); int32_t setCompareBytes8(const void *pLeft, const void *pRight); +int32_t compareInt8Val(const void *pLeft, const void *pRight); +int32_t compareInt16Val(const void *pLeft, const void *pRight); int32_t compareInt32Val(const void *pLeft, const void *pRight); int32_t compareInt64Val(const void *pLeft, const void *pRight); -int32_t compareInt16Val(const void *pLeft, const void *pRight); - -int32_t compareInt8Val(const void *pLeft, const void *pRight); - +int32_t compareUint8Val(const void *pLeft, const void *pRight); +int32_t compareUint16Val(const void *pLeft, const void *pRight); int32_t compareUint32Val(const void *pLeft, const void *pRight); int32_t compareUint64Val(const void *pLeft, const void *pRight); -int32_t compareUint16Val(const void *pLeft, const void *pRight); - -int32_t compareUint8Val(const void* pLeft, const void* pRight); - int32_t compareFloatVal(const void *pLeft, const void *pRight); - int32_t compareDoubleVal(const void *pLeft, const void *pRight); int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight); - int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight); -int32_t compareStrRegexComp(const void* pLeft, const void* pRight); -int32_t compareStrRegexCompMatch(const void* pLeft, const void* pRight); -int32_t compareStrRegexCompNMatch(const void* pLeft, const void* pRight); -int32_t compareFindItemInSet(const void *pLeft, const void* pRight); + +int32_t compareStrRegexComp(const void *pLeft, const void *pRight); +int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight); +int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight); + +int32_t compareFindItemInSet(const void *pLeft, const void *pRight); + int32_t compareInt8ValDesc(const void *pLeft, const void *pRight); -int32_t compareInt16ValDesc(const void* pLeft, const void* pRight); -int32_t compareInt32ValDesc(const void* pLeft, const void* pRight); -int32_t compareInt64ValDesc(const void* pLeft, const void* pRight); -int32_t compareFloatValDesc(const void* pLeft, const void* pRight); -int32_t compareDoubleValDesc(const void* pLeft, const void* pRight); -int32_t compareUint8ValDesc(const void* pLeft, const void* pRight); -int32_t compareUint16ValDesc(const void* pLeft, const void* pRight); -int32_t compareUint32ValDesc(const void* pLeft, const void* pRight); -int32_t compareUint64ValDesc(const void* pLeft, const void* pRight); -int32_t compareLenPrefixedStrDesc(const void* pLeft, const void* pRight); -int32_t compareLenPrefixedWStrDesc(const void* pLeft, const void* pRight); +int32_t compareInt16ValDesc(const void *pLeft, const void *pRight); +int32_t compareInt32ValDesc(const void *pLeft, const void *pRight); +int32_t compareInt64ValDesc(const void *pLeft, const void *pRight); + +int32_t compareFloatValDesc(const void *pLeft, const void *pRight); +int32_t compareDoubleValDesc(const void *pLeft, const void *pRight); + +int32_t compareUint8ValDesc(const void *pLeft, const void *pRight); +int32_t compareUint16ValDesc(const void *pLeft, const void *pRight); +int32_t compareUint32ValDesc(const void *pLeft, const void *pRight); +int32_t compareUint64ValDesc(const void *pLeft, const void *pRight); + +int32_t compareLenPrefixedStrDesc(const void *pLeft, const void *pRight); +int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight); #ifdef __cplusplus } #endif -#endif /*_TD_UTIL_COMPARE_H*/ +#endif /*_TD_UTIL_COMPARE_H_*/ diff --git a/source/util/src/compare.c b/source/util/src/compare.c index f2d320fde0..a1c1625c34 100644 --- a/source/util/src/compare.c +++ b/source/util/src/compare.c @@ -16,13 +16,13 @@ #define _GNU_SOURCE #define _XOPEN_SOURCE #define _DEFAULT_SOURCE - #include "os.h" -#include "types.h" + #include "compare.h" -#include "ulog.h" -#include "thash.h" #include "regex.h" +#include "thash.h" +#include "types.h" +#include "ulog.h" int32_t setCompareBytes1(const void *pLeft, const void *pRight) { return NULL != taosHashGet((SHashObj *)pRight, pLeft, 1) ? 1 : 0; @@ -228,7 +228,7 @@ int32_t compareLenPrefixedWStrDesc(const void* pLeft, const void* pRight) { * '_': Matches one character * */ -int patternMatch(const char *patterStr, const char *str, size_t size, const SPatternCompareInfo *pInfo) { +int32_t patternMatch(const char *patterStr, const char *str, size_t size, const SPatternCompareInfo *pInfo) { char c, c1; int32_t i = 0; @@ -289,7 +289,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat return (str[j] == 0 || j >= size) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo) { +int32_t WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo) { wchar_t c, c1; wchar_t matchOne = L'_'; // "_" wchar_t matchAll = L'%'; // "%" @@ -360,11 +360,11 @@ int32_t compareStrRegexComp(const void* pLeft, const void* pRight) { memcpy(str, varDataVal(pLeft), sz); str[sz] = 0; - int errCode = 0; + int32_t errCode = 0; regex_t regex; char msgbuf[256] = {0}; - int cflags = REG_EXTENDED; + int32_t cflags = REG_EXTENDED; if ((errCode = regcomp(®ex, pattern, cflags)) != 0) { regerror(errCode, ®ex, msgbuf, sizeof(msgbuf)); uError("Failed to compile regex pattern %s. reason %s", pattern, msgbuf); diff --git a/source/util/src/tskiplist.c b/source/util/src/tskiplist.c index 00263d7bce..328d3da5a4 100644 --- a/source/util/src/tskiplist.c +++ b/source/util/src/tskiplist.c @@ -13,11 +13,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "tskiplist.h" + #include "os.h" + #include "compare.h" -#include "ulog.h" +#include "tskiplist.h" #include "tutil.h" +#include "ulog.h" static int initForwardBackwardPtr(SSkipList *pSkipList); static SSkipListNode * getPriorNode(SSkipList *pSkipList, const char *val, int32_t order, SSkipListNode **pCur); @@ -52,11 +54,17 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _ pSkipList->flags = flags; pSkipList->keyFn = fn; pSkipList->seed = rand(); + +#if 0 + // the function getkeycomparfunc is defined in common if (comparFn == NULL) { pSkipList->comparFn = getKeyComparFunc(keyType, TSDB_ORDER_ASC); } else { pSkipList->comparFn = comparFn; } +#else + pSkipList->comparFn = comparFn; +#endif if (initForwardBackwardPtr(pSkipList) < 0) { tSkipListDestroy(pSkipList); diff --git a/tests/test/c/create_table.c b/tests/test/c/create_table.c index b8d8123380..74dd3f4535 100644 --- a/tests/test/c/create_table.c +++ b/tests/test/c/create_table.c @@ -182,7 +182,7 @@ void *threadFunc(void *param) { exit(1); } - pError("====before thread:%d, table range: %"PRId64 " - %"PRId64 "\n", + pPrint("====before thread:%d, table range: %"PRId64 " - %"PRId64 "\n", pInfo->threadIndex, pInfo->tableBeginIndex, pInfo->tableEndIndex); @@ -190,7 +190,7 @@ void *threadFunc(void *param) { pInfo->tableBeginIndex += startOffset; pInfo->tableEndIndex += startOffset; - pError("====after thread:%d, table range: %"PRId64 " - %"PRId64 "\n", + pPrint("====after thread:%d, table range: %"PRId64 " - %"PRId64 "\n", pInfo->threadIndex, pInfo->tableBeginIndex, pInfo->tableEndIndex);