提交 6e01c527 编写于 作者: H hjxilinx

supress some warnings from clang-tidy,valgrind etc.

上级 25ff54c9
......@@ -23,7 +23,7 @@ extern "C" {
#include "taosmsg.h"
#include "tsdb.h"
extern int sdbDebugFlag;
extern uint32_t sdbDebugFlag;
extern short sdbPeerPort;
extern short sdbSyncPort;
extern int sdbMaxNodes;
......
......@@ -146,19 +146,19 @@ extern char tsInternalPass[];
extern int tsMonitorInterval;
extern int tsNumOfLogLines;
extern int ddebugFlag;
extern int mdebugFlag;
extern int cdebugFlag;
extern int jnidebugFlag;
extern int tmrDebugFlag;
extern int sdbDebugFlag;
extern int httpDebugFlag;
extern int monitorDebugFlag;
extern int uDebugFlag;
extern int rpcDebugFlag;
extern int debugFlag;
extern int odbcdebugFlag;
extern int qdebugFlag;
extern uint32_t ddebugFlag;
extern uint32_t mdebugFlag;
extern uint32_t cdebugFlag;
extern uint32_t jnidebugFlag;
extern uint32_t tmrDebugFlag;
extern uint32_t sdbDebugFlag;
extern uint32_t httpDebugFlag;
extern uint32_t monitorDebugFlag;
extern uint32_t uDebugFlag;
extern uint32_t rpcDebugFlag;
extern uint32_t debugFlag;
extern uint32_t odbcdebugFlag;
extern uint32_t qdebugFlag;
extern int tsRpcTimer;
extern int tsRpcMaxTime;
......
......@@ -25,16 +25,14 @@ extern "C" {
#include <string.h>
#include "tglobalcfg.h"
#define DEBUG_ERROR 1
#define DEBUG_WARN 2
#define DEBUG_TRACE 4
#define DEBUG_DUMP 8
#define DEBUG_ERROR 1U
#define DEBUG_WARN 2U
#define DEBUG_TRACE 4U
#define DEBUG_DUMP 8U
#define DEBUG_FILE 0x80
#define DEBUG_SCREEN 0x40
extern int uDebugFlag;
extern void (*taosLogFp)(int level, const char *const format, ...);
extern void (*taosLogSqlFp)(char *sql);
......@@ -99,7 +97,7 @@ void taosResetLogFile();
{ tprintf("UTL ", tscEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }
// client log function
extern int cdebugFlag;
extern uint32_t cdebugFlag;
#define tscError(...) \
if (cdebugFlag & DEBUG_ERROR) { \
......@@ -132,7 +130,6 @@ extern int cdebugFlag;
{ tprintf("JNI ", 255, __VA_ARGS__); }
// rpc log function
extern int rpcDebugFlag;
#define tError(...) \
if (rpcDebugFlag & DEBUG_ERROR) { \
tprintf("ERROR RPC ", rpcDebugFlag, __VA_ARGS__); \
......
......@@ -73,7 +73,6 @@ typedef struct {
char * ckey; // ciphering key
} SRpcConnInit;
extern int rpcDebugFlag;
extern int tsRpcHeadSize;
void *taosOpenRpc(SRpcInit *pRpc);
......
......@@ -22,7 +22,7 @@ extern "C" {
typedef void *tmr_h;
extern int tmrDebugFlag;
extern uint32_t tmrDebugFlag;
extern int taosTmrThreads;
void *taosTmrInit(int maxTmr, int resoultion, int longest, char *label);
......
......@@ -39,10 +39,13 @@
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <sys/stat.h>
#include <stdint.h>
#include <pthread.h>
#include <stdbool.h>
#include <limits.h>
#include <linux/limits.h>
#include <strings.h>
#include <sys/sendfile.h>
bool taosCheckPthreadValid(pthread_t thread);
......@@ -65,4 +68,11 @@ void taosKillSystem();
bool taosIsRunningWSLv1();
int64_t str2int64(char *str);
#define BUILDIN_CLZL(val) __builtin_clzl(val)
#define BUILDIN_CLZ(val) __builtin_clz(val)
#define BUILDIN_CTZL(val) __builtin_ctzl(val)
#define BUILDIN_CTZ(val) __builtin_ctz(val)
#endif
\ No newline at end of file
......@@ -116,7 +116,7 @@ typedef struct rpc_server {
} STaosRpc;
// configurable
int rpcDebugFlag = 131;
uint32_t rpcDebugFlag = 131;
int tsRpcTimer = 300;
int tsRpcMaxTime = 600; // seconds;
int tsRpcProgressTime = 10; // milliseocnds
......
......@@ -136,7 +136,6 @@ typedef struct {
extern SSdbTable *tableList[];
extern int sdbMaxPeers;
extern int sdbDebugFlag;
extern int sdbNumOfTables;
extern int64_t sdbVersion;
......
......@@ -19,42 +19,31 @@
* To compress integers (including char, short, int, int64_t), the difference
* between two integers is calculated at first. Then the difference is
* transformed to positive by zig-zag encoding method
* (https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba). Then the value
* is
* (https://gist.github.com/mfuerstenau/ba870a29e16536fdbaba). Then the value is
* encoded using simple 8B method. For more information about simple 8B,
* refer to https://en.wikipedia.org/wiki/8b/10b_encoding.
*
* NOTE : For bigint, only 59 bits can be used, which means data from -(2**59)
* to (2**59)-1
* NOTE : For bigint, only 59 bits can be used, which means data from -(2**59) to (2**59)-1
* are allowed.
*
* BOOLEAN Compression Algorithm:
* We provide two methods for compress boolean types. Because boolean types in
* C
* code are char bytes with 0 and 1 values only, only one bit can used to
* discrimenate
* We provide two methods for compress boolean types. Because boolean types in C
* code are char bytes with 0 and 1 values only, only one bit can used to discrimenate
* the values.
* 1. The first method is using only 1 bit to represent the boolean value with
* 1 for
* 1. The first method is using only 1 bit to represent the boolean value with 1 for
* true and 0 for false. Then the compression rate is 1/8.
* 2. The second method is using run length encoding (RLE) methods. This
* methos works
* 2. The second method is using run length encoding (RLE) methods. This methos works
* better when there are a lot of consecutive true values or false values.
*
* STRING Compression Algorithm:
* We us LZ4 method to compress the string type.
*
* FLOAT Compression Algorithm:
* We use the same method with Akumuli to compress float and double types. The
* compression
* algorithm assumes the float/double values change slightly. So we take the
* XOR between two
* adjacent values. Then compare the number of leading zeros and trailing
* zeros. If the number
* of leading zeros are larger than the trailing zeros, then record the last
* serveral bytes
* of the XORed value with informations. If not, record the first
* corresponding bytes.
* We use the same method with Akumuli to compress float and double types. The compression
* algorithm assumes the float/double values change slightly. So we take the XOR between two
* adjacent values. Then compare the number of leading zeros and trailing zeros. If the number
* of leading zeros are larger than the trailing zeros, then record the last serveral bytes
* of the XORed value with informations. If not, record the first corresponding bytes.
*
*/
#include <assert.h>
......@@ -64,6 +53,7 @@
#include <stdlib.h>
#include <string.h>
#include "os.h"
#include "lz4.h"
#include "tscompression.h"
#include "tsdb.h"
......@@ -368,7 +358,7 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o
// Take care here, __builtin_clzl give wrong anser for value 0;
tmp_bit = 0;
} else {
tmp_bit = (LONG_BYTES * BITS_PER_BYTE) - __builtin_clzl(zigzag_value);
tmp_bit = (LONG_BYTES * BITS_PER_BYTE) - BUILDIN_CLZL(zigzag_value);
}
if (elems + 1 <= selector_to_elems[selector] && elems + 1 <= selector_to_elems[bit_to_selector[tmp_bit]]) {
......@@ -695,14 +685,14 @@ int tsCompressTimestampImp(const char *const input, const int nelements, char *c
if (dd1 == 0) {
flag1 = 0;
} else {
flag1 = LONG_BYTES - __builtin_clzl(dd1) / BITS_PER_BYTE;
flag1 = LONG_BYTES - BUILDIN_CLZL(dd1) / BITS_PER_BYTE;
}
} else {
dd2 = zigzag_value;
if (dd2 == 0) {
flag2 = 0;
} else {
flag2 = LONG_BYTES - __builtin_clzl(dd2) / BITS_PER_BYTE;
flag2 = LONG_BYTES - BUILDIN_CLZL(dd2) / BITS_PER_BYTE;
}
flags = flag1 | (flag2 << 4);
// Encode the flag.
......@@ -869,8 +859,8 @@ int tsCompressDoubleImp(const char *const input, const int nelements, char *cons
int trailing_zeros = leading_zeros;
if (diff) {
trailing_zeros = __builtin_ctzl(diff);
leading_zeros = __builtin_clzl(diff);
trailing_zeros = BUILDIN_CTZL(diff);
leading_zeros = BUILDIN_CLZL(diff);
}
uint8_t nbytes = 0;
......@@ -1016,8 +1006,8 @@ int tsCompressFloatImp(const char *const input, const int nelements, char *const
int trailing_zeros = leading_zeros;
if (diff) {
trailing_zeros = __builtin_ctz(diff);
leading_zeros = __builtin_clz(diff);
trailing_zeros = BUILDIN_CTZ(diff);
leading_zeros = BUILDIN_CLZ(diff);
}
uint8_t nbytes = 0;
......
......@@ -1178,7 +1178,9 @@ void tColDataQSort(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
while (right > end_same && left <= end_same) {
swap(pDescriptor, numOfRows, left++, data, right--);
}
rightx += (end - end_same); // (pivotal+1) + steps of number that are identical pivotal
// (pivotal+1) + steps of number that are identical pivotal
rightx += (end - end_same);
#ifdef _DEBUG_VIEW
tRowModelDisplay(pDescriptor, numOfRows, data, end - start + 1);
......@@ -1193,7 +1195,9 @@ void tColDataQSort(tOrderDescriptor *pDescriptor, int32_t numOfRows, int32_t sta
while (left < start_same && right >= start_same) {
swap(pDescriptor, numOfRows, left++, data, right--);
}
leftx -= (start_same - start); // (pivotal-1) - steps of number that are identical pivotal
// (pivotal-1) - steps of number that are identical pivotal
leftx -= (start_same - start);
#ifdef _DEBUG_VIEW
tRowModelDisplay(pDescriptor, numOfRows, data, end - start + 1);
......
......@@ -140,16 +140,16 @@ char tsLocale[TSDB_LOCALE_LEN] = {0};
char tsCharset[TSDB_LOCALE_LEN] = {0}; // default encode string
int tsNumOfLogLines = 10000000;
int ddebugFlag = 131;
int mdebugFlag = 135;
int sdbDebugFlag = 135;
int cdebugFlag = 131;
int jnidebugFlag = 131;
int httpDebugFlag = 131;
int monitorDebugFlag = 131;
int debugFlag = 131;
int odbcdebugFlag = 131;
int qdebugFlag = 131;
uint32_t ddebugFlag = 131;
uint32_t mdebugFlag = 135;
uint32_t sdbDebugFlag = 135;
uint32_t cdebugFlag = 131;
uint32_t jnidebugFlag = 131;
uint32_t httpDebugFlag = 131;
uint32_t monitorDebugFlag = 131;
uint32_t debugFlag = 131;
uint32_t odbcdebugFlag = 131;
uint32_t qdebugFlag = 131;
SGlobalConfig *tsGlobalConfig = NULL;
int tsGlobalConfigNum = 0;
......
......@@ -58,7 +58,7 @@ typedef struct {
sem_t buffNotEmpty;
} SLogBuff;
int uDebugFlag = 131; // all the messages
uint32_t uDebugFlag = 131; // all the messages
short tsAsyncLog = 1;
static SLogBuff *logHandle;
......
......@@ -242,7 +242,6 @@ tSkipList* tSkipListCreate(int16_t nMaxLevel, int16_t keyType, int16_t nMaxKeyLe
srand(time(NULL));
pSkipList->state.nTotalMemSize += sizeof(tSkipList);
return pSkipList;
}
......
......@@ -95,7 +95,7 @@ typedef struct _tmr_ctrl_t {
int tmrCtrlId;
} tmr_ctrl_t;
int tmrDebugFlag = DEBUG_ERROR | DEBUG_WARN | DEBUG_FILE;
uint32_t tmrDebugFlag = DEBUG_ERROR | DEBUG_WARN | DEBUG_FILE;
void taosTmrProcessList(tmr_ctrl_t *);
tmr_ctrl_t tmrCtrl[maxNumOfTmrCtrl];
......@@ -132,8 +132,8 @@ void *taosProcessAlarmSignal(void *tharg) {
sigaddset(&sigset, SIGALRM);
sigprocmask(SIG_BLOCK, &sigset, NULL);
timer_t timerId;
struct sigevent sevent;
timer_t timerId = {0};
struct sigevent sevent = {0};
sevent.sigev_notify = SIGEV_THREAD_ID;
sevent._sigev_un._tid = syscall(__NR_gettid);
sevent.sigev_signo = SIGALRM;
......
......@@ -218,6 +218,7 @@ static SKeyword keywordTable[] = {
{"STABLE", TK_STABLE}
};
/* This is the hash table */
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static const char isIdChar[] = {
......@@ -273,11 +274,11 @@ int tSQLKeywordCode(const char* z, int n) {
}
/*
** Return the length of the token that begins at z[0].
** Store the token type in *type before returning.
*/
* Return the length of the token that begins at z[0].
* Store the token type in *type before returning.
*/
uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
int i;
uint32_t i;
switch (*z) {
case ' ':
case '\t':
......
......@@ -25,6 +25,7 @@
#include "os.h"
#include "taos.h"
#include "tsdb.h"
#include "tsql.h"
#include "tsqldef.h"
#include "ttypes.h"
#include "tutil.h"
......@@ -43,7 +44,7 @@ tDataDescriptor tDataTypeDesc[11] = {
{TSDB_DATA_TYPE_NCHAR, 5, 8, "NCHAR"},
};
char tTokenTypeSwitcher[] = {
char tTokenTypeSwitcher[13] = {
TSDB_DATA_TYPE_NULL, // no type
TSDB_DATA_TYPE_BINARY, // TK_ID
TSDB_DATA_TYPE_BOOL, // TK_BOOL
......@@ -65,7 +66,7 @@ bool isValidDataType(int32_t type, int32_t length) {
}
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
return length >= 0 && length <= TSDB_MAX_BINARY_LEN;
// return length >= 0 && length <= TSDB_MAX_BINARY_LEN;
}
return true;
......@@ -105,8 +106,10 @@ void tVariantCreateN(tVariant *pVar, char *pz, uint32_t len, uint32_t type) {
pVar->nLen = strdequote(pVar->pz);
break;
}
default:
assert(false);
default: { // nType == 0 means the null value
type = TSDB_DATA_TYPE_NULL;
}
}
pVar->nType = type;
......@@ -123,56 +126,58 @@ void tVariantCreateB(tVariant *pVar, char *pz, uint32_t len, uint32_t type) {
switch (type) {
case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT: {
pVar->i64Key = *(int8_t *)pz;
pVar->i64Key = GET_INT8_VAL(pz);
break;
}
case TSDB_DATA_TYPE_SMALLINT: {
pVar->i64Key = *(int16_t *)pz;
pVar->i64Key = GET_INT16_VAL(pz);
break;
}
case TSDB_DATA_TYPE_INT: {
pVar->i64Key = *(int32_t *)pz;
pVar->i64Key = GET_INT32_VAL(pz);
break;
}
case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_TIMESTAMP: {
pVar->i64Key = *(int64_t *)pz;
pVar->i64Key = GET_INT64_VAL(pz);
break;
}
case TSDB_DATA_TYPE_DOUBLE: {
pVar->dKey = *(double *)pz;
pVar->dKey = GET_DOUBLE_VAL(pz);
break;
}
case TSDB_DATA_TYPE_FLOAT: {
pVar->dKey = *(float *)pz;
pVar->dKey = GET_FLOAT_VAL(pz);
break;
}
case TSDB_DATA_TYPE_NCHAR: {
/* here we get the nchar length from raw binary bits length */
int32_t wlen = len / TSDB_NCHAR_SIZE;
pVar->wpz = malloc((len + 1) * wlen);
pVar->nLen = len / TSDB_NCHAR_SIZE;
pVar->wpz = malloc((pVar->nLen + 1) * TSDB_NCHAR_SIZE);
wcsncpy(pVar->wpz, (wchar_t *)pz, wlen);
pVar->nLen = wlen;
pVar->wpz[wlen] = 0;
wcsncpy(pVar->wpz, (wchar_t *)pz, pVar->nLen);
pVar->wpz[pVar->nLen] = 0;
break;
}
case TSDB_DATA_TYPE_BINARY: {
pVar->pz = malloc(len + 1);
strncpy(pVar->pz, pz, len);
pVar->nLen = len;
pVar->pz[len] = 0;
strdequote(pVar->pz);
pVar->nLen = strlen(pVar->pz);
pVar->nLen = strdequote(pVar->pz);
break;
}
default:
pVar->i64Key = GET_INT32_VAL(pVar);
}
pVar->nType = type;
}
void tVariantDestroy(tVariant *pVar) {
if (pVar == NULL) return;
......@@ -780,29 +785,29 @@ void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems) {
void assignVal(char *val, char *src, int32_t len, int32_t type) {
switch (type) {
case TSDB_DATA_TYPE_INT: {
*((int32_t *)val) = *(int32_t *)src;
*((int32_t *)val) = GET_INT32_VAL(src);
break;
}
case TSDB_DATA_TYPE_FLOAT: {
*((float *)val) = *(float *)src;
*((float *)val) = GET_FLOAT_VAL(src);
break;
};
case TSDB_DATA_TYPE_DOUBLE: {
*((double *)val) = *(double *)src;
*((double *)val) = GET_DOUBLE_VAL(src);
break;
};
case TSDB_DATA_TYPE_TIMESTAMP:
case TSDB_DATA_TYPE_BIGINT: {
*((int64_t *)val) = *(int64_t *)src;
*((int64_t *)val) = GET_INT64_VAL(src);
break;
};
case TSDB_DATA_TYPE_SMALLINT: {
*((int16_t *)val) = *(int16_t *)src;
*((int16_t *)val) = GET_INT16_VAL(src);
break;
};
case TSDB_DATA_TYPE_BOOL:
case TSDB_DATA_TYPE_TINYINT: {
*((int8_t *)val) = *(int8_t *)src;
*((int8_t *)val) = GET_INT8_VAL(src);
break;
};
default: {
......
......@@ -498,4 +498,13 @@ bool taosGetVersionNumber(char *versionStr, int *versionNubmer) {
versionStr[versionNumberPos[3] - 1] = '.';
return true;
}
\ No newline at end of file
}
char *taosIpStr(int ipInt) {
static char ipStrArray[3][30];
static int ipStrIndex = 0;
char *ipStr = ipStrArray[(ipStrIndex++) % 3];
sprintf(ipStr, "0x%x:%d.%d.%d.%d", ipInt, ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, ipInt >> 24);
return ipStr;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册