diff --git a/src/util/src/tcrc32c.c b/src/util/src/tcrc32c.c index 705ca5872a..c67773f1ca 100644 --- a/src/util/src/tcrc32c.c +++ b/src/util/src/tcrc32c.c @@ -26,7 +26,7 @@ #include "tcrc32c.h" //todo : use the original source code -#pragma GCC diagnostic ignored "-Wunused-function" +//#pragma GCC diagnostic ignored "-Wunused-function" #define POLY 0x82f63b78 #define LONG_SHIFT 8192 @@ -1093,6 +1093,7 @@ static uint32_t short_shifts[4][256] = { 0xe1a734e7, 0xc41cc13c, 0x140cd014, 0x31b725cf, 0x5f7b3ba2, 0x7ac0ce79, 0x82e30778, 0xa758f2a3, 0xc994ecce, 0xec2f1915}}; +#if 0 static uint32_t append_trivial(uint32_t crc, crc_stream input, size_t length) { for (size_t i = 0; i < length; ++i) { crc = crc ^ input[i]; @@ -1130,6 +1131,7 @@ static uint32_t append_adler_table(uint32_t crci, crc_stream input, } return (uint32_t)(crc ^ 0xffffffff); } +#endif /* Table-driven software version as a fall-back. This is about 15 times slower than using the hardware instructions. This assumes little-endian integers, diff --git a/src/util/src/textbuffer.c b/src/util/src/textbuffer.c index ef55368081..42c2cc1ed0 100644 --- a/src/util/src/textbuffer.c +++ b/src/util/src/textbuffer.c @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - +#include #include "os.h" #include "taos.h" #include "taosmsg.h" @@ -23,7 +23,7 @@ #include "ttypes.h" #include "tutil.h" -#pragma GCC diagnostic ignored "-Wformat" +//#pragma GCC diagnostic ignored "-Wformat" #define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \ (data + (schema)->colOffset[colId] * (allrow) + (rowId) * (schema)->pFields[colId].bytes) @@ -1017,7 +1017,7 @@ static void UNUSED_FUNC tSortDataPrint(int32_t type, char *prefix, char *startx, break; case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_BIGINT: - printf("%s:(%lld, %lld, %lld)\n", prefix, *(int64_t *)startx, *(int64_t *)midx, *(int64_t *)endx); + printf("%s:(%" PRId64 ", %" PRId64 ", %" PRId64 ")\n", prefix, *(int64_t *)startx, *(int64_t *)midx, *(int64_t *)endx); break; case TSDB_DATA_TYPE_FLOAT: printf("%s:(%f, %f, %f)\n", prefix, *(float *)startx, *(float *)midx, *(float *)endx); @@ -1093,7 +1093,7 @@ static UNUSED_FUNC void tRowModelDisplay(tOrderDescriptor *pDescriptor, int32_t break; case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_BIGINT: - printf("%lld\t", *(int64_t *)startx); + printf("%" PRId64 "\t", *(int64_t *)startx); break; case TSDB_DATA_TYPE_BINARY: printf("%s\t", startx); @@ -1264,7 +1264,7 @@ static tFilePage *loadIntoBucketFromDisk(tMemBucket *pMemBucket, int32_t segIdx, assert(pPage->numOfElems > 0); tColModelAppend(pDesc->pSchema, buffer, pPage->data, 0, pPage->numOfElems, pPage->numOfElems); - printf("id: %d count: %d\n", j, buffer->numOfElems); + printf("id: %d count: %" PRIu64 "\n", j, buffer->numOfElems); } } tfree(pPage); @@ -1376,10 +1376,16 @@ static void printBinaryData(char *data, int32_t len) { } if (len == 50) { // probably the avg intermediate result - printf("%lf,%d\t", *(double *)data, *(int64_t *)(data + sizeof(double))); + printf("%lf,%" PRId64 "\t", *(double *)data, *(int64_t *)(data + sizeof(double))); } else if (data[8] == ',') { // in TSDB_FUNC_FIRST_DST/TSDB_FUNC_LAST_DST, // the value is seperated by ',' - printf("%ld,%0x\t", *(int64_t *)data, data + sizeof(int64_t) + 1); + //printf("%" PRId64 ",%0x\t", *(int64_t *)data, data + sizeof(int64_t) + 1); + printf("%" PRId64 ", HEX: ", *(int64_t *)data); + int32_t tmp_len = len - sizeof(int64_t) - 1; + for (int32_t i = 0; i < tmp_len; ++i) { + printf("%0x ", *(data + sizeof(int64_t) + 1 + i)); + } + printf("\t"); } else if (isCharString) { printf("%s\t", data); } @@ -1389,26 +1395,26 @@ static void printBinaryData(char *data, int32_t len) { static void printBinaryDataEx(char *data, int32_t len, SSrcColumnInfo *param) { if (param->functionId == TSDB_FUNC_LAST_DST) { switch (param->type) { - case TSDB_DATA_TYPE_TINYINT:printf("%lld,%d\t", *(int64_t *) data, *(int8_t *) (data + TSDB_KEYSIZE + 1)); + case TSDB_DATA_TYPE_TINYINT:printf("%" PRId64 ",%d\t", *(int64_t *) data, *(int8_t *) (data + TSDB_KEYSIZE + 1)); break; - case TSDB_DATA_TYPE_SMALLINT:printf("%lld,%d\t", *(int64_t *) data, *(int16_t *) (data + TSDB_KEYSIZE + 1)); + case TSDB_DATA_TYPE_SMALLINT:printf("%" PRId64 ",%d\t", *(int64_t *) data, *(int16_t *) (data + TSDB_KEYSIZE + 1)); break; case TSDB_DATA_TYPE_TIMESTAMP: - case TSDB_DATA_TYPE_BIGINT:printf("%lld,%lld\t", *(int64_t *) data, *(int64_t *) (data + TSDB_KEYSIZE + 1)); + case TSDB_DATA_TYPE_BIGINT:printf("%" PRId64 ",%" PRId64 "\t", *(int64_t *) data, *(int64_t *) (data + TSDB_KEYSIZE + 1)); break; - case TSDB_DATA_TYPE_FLOAT:printf("%lld,%d\t", *(int64_t *) data, *(float *) (data + TSDB_KEYSIZE + 1)); + case TSDB_DATA_TYPE_FLOAT:printf("%" PRId64 ",%f\t", *(int64_t *) data, *(float *) (data + TSDB_KEYSIZE + 1)); break; - case TSDB_DATA_TYPE_DOUBLE:printf("%lld,%d\t", *(int64_t *) data, *(double *) (data + TSDB_KEYSIZE + 1)); + case TSDB_DATA_TYPE_DOUBLE:printf("%" PRId64 ",%f\t", *(int64_t *) data, *(double *) (data + TSDB_KEYSIZE + 1)); break; - case TSDB_DATA_TYPE_BINARY:printf("%lld,%s\t", *(int64_t *) data, (data + TSDB_KEYSIZE + 1)); + case TSDB_DATA_TYPE_BINARY:printf("%" PRId64 ",%s\t", *(int64_t *) data, (data + TSDB_KEYSIZE + 1)); break; case TSDB_DATA_TYPE_INT: - default:printf("%lld,%d\t", *(int64_t *) data, *(int32_t *) (data + TSDB_KEYSIZE + 1)); + default:printf("%" PRId64 ",%d\t", *(int64_t *) data, *(int32_t *) (data + TSDB_KEYSIZE + 1)); break; } } else if (param->functionId == TSDB_FUNC_AVG) { - printf("%f,%lld\t", *(double *) data, *(int64_t *) (data + sizeof(double) + 1)); + printf("%f,%" PRId64 "\t", *(double *) data, *(int64_t *) (data + sizeof(double) + 1)); } else { // functionId == TSDB_FUNC_MAX_DST | TSDB_FUNC_TAG switch (param->type) { @@ -1420,13 +1426,13 @@ static void printBinaryDataEx(char *data, int32_t len, SSrcColumnInfo *param) { break; case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_BIGINT: - printf("%lld\t", *(int64_t *)data); + printf("%" PRId64 "\t", *(int64_t *)data); break; case TSDB_DATA_TYPE_FLOAT: - printf("%d\t", *(float *)data); + printf("%f\t", *(float *)data); break; case TSDB_DATA_TYPE_DOUBLE: - printf("%d\t", *(double *)data); + printf("%f\t", *(double *)data); break; case TSDB_DATA_TYPE_BINARY: printf("%s\t", data); @@ -1434,7 +1440,7 @@ static void printBinaryDataEx(char *data, int32_t len, SSrcColumnInfo *param) { case TSDB_DATA_TYPE_INT: default: - printf("%d\t", *(double *)data); + printf("%f\t", *(double *)data); break; } } @@ -1450,7 +1456,7 @@ void tColModelDisplay(tColModel *pModel, void *pData, int32_t numOfRows, int32_t switch (type) { case TSDB_DATA_TYPE_BIGINT: - printf("%lld\t", *(int64_t *)val); + printf("%" PRId64 "\t", *(int64_t *)val); break; case TSDB_DATA_TYPE_INT: printf("%d\t", *(int32_t *)val); @@ -1468,7 +1474,7 @@ void tColModelDisplay(tColModel *pModel, void *pData, int32_t numOfRows, int32_t printf("%lf\t", *(double *)val); break; case TSDB_DATA_TYPE_TIMESTAMP: - printf("%lld\t", *(int64_t *)val); + printf("%" PRId64 "\t", *(int64_t *)val); break; case TSDB_DATA_TYPE_TINYINT: printf("%d\t", *(int8_t *)val); @@ -1501,7 +1507,7 @@ void tColModelDisplayEx(tColModel *pModel, void *pData, int32_t numOfRows, int32 switch (pModel->pFields[j].type) { case TSDB_DATA_TYPE_BIGINT: - printf("%lld\t", *(int64_t *)val); + printf("%" PRId64 "\t", *(int64_t *)val); break; case TSDB_DATA_TYPE_INT: printf("%d\t", *(int32_t *)val); @@ -1519,7 +1525,7 @@ void tColModelDisplayEx(tColModel *pModel, void *pData, int32_t numOfRows, int32 printf("%lf\t", *(double *)val); break; case TSDB_DATA_TYPE_TIMESTAMP: - printf("%lld\t", *(int64_t *)val); + printf("%" PRId64 "\t", *(int64_t *)val); break; case TSDB_DATA_TYPE_TINYINT: printf("%d\t", *(int8_t *)val); diff --git a/src/util/src/thistogram.c b/src/util/src/thistogram.c index 5fef9077ea..03c2294938 100644 --- a/src/util/src/thistogram.c +++ b/src/util/src/thistogram.c @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - +#include #include "os.h" #include "taosmsg.h" @@ -447,7 +447,7 @@ void tHistogramPrint(SHistogramInfo* pHisto) { printf("total entries: %d, elements: %d\n", pHisto->numOfEntries, pHisto->numOfElems); #if defined(USE_ARRAYLIST) for (int32_t i = 0; i < pHisto->numOfEntries; ++i) { - printf("%d: (%f, %lld)\n", i + 1, pHisto->elems[i].val, pHisto->elems[i].num); + printf("%d: (%f, %" PRId64 ")\n", i + 1, pHisto->elems[i].val, pHisto->elems[i].num); } #else tSkipListNode* pNode = pHisto->pList->pHead.pForward[0]; diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 72469fa75b..0440e5d5ab 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - +#include #include #include #include @@ -570,7 +570,7 @@ int32_t tSkipListIterateList(tSkipList *pSkipList, tSkipListNode ***pRes, bool ( char* tmp = realloc((*pRes), num * POINTER_BYTES); assert(tmp != NULL); - *pRes = tmp; + *pRes = (tSkipListNode**)tmp; } return num; @@ -688,7 +688,7 @@ void tSkipListPrint(tSkipList *pSkipList, int16_t nlevel) { case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_BIGINT: - fprintf(stdout, "%d: %lld \n", id++, p->key.i64Key); + fprintf(stdout, "%d: %" PRId64 " \n", id++, p->key.i64Key); break; case TSDB_DATA_TYPE_BINARY: fprintf(stdout, "%d: %s \n", id++, p->key.pz); diff --git a/src/util/src/tstrbuild.c b/src/util/src/tstrbuild.c index 6914357493..439370ce07 100644 --- a/src/util/src/tstrbuild.c +++ b/src/util/src/tstrbuild.c @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - +#include #include "os.h" #include "tstrbuild.h" @@ -70,7 +70,7 @@ void taosStringBuilderAppendNull(SStringBuilder* sb) { taosStringBuilderAppendSt void taosStringBuilderAppendInteger(SStringBuilder* sb, int64_t v) { char buf[64]; - size_t len = sprintf(buf, "%lld", v); + size_t len = sprintf(buf, "%" PRId64, v); taosStringBuilderAppendStringLen(sb, buf, len); } diff --git a/src/util/src/ttypes.c b/src/util/src/ttypes.c index 98f0741905..3f0c1732e3 100644 --- a/src/util/src/ttypes.c +++ b/src/util/src/ttypes.c @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - +#include #include "os.h" #include "taos.h" #include "tsdb.h" @@ -213,7 +213,7 @@ int32_t tVariantToString(tVariant *pVar, char *dst) { return sprintf(dst, "%d", (int32_t)pVar->i64Key); case TSDB_DATA_TYPE_BIGINT: - return sprintf(dst, "%lld", pVar->i64Key); + return sprintf(dst, "%" PRId64, pVar->i64Key); case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_DOUBLE: @@ -224,6 +224,7 @@ int32_t tVariantToString(tVariant *pVar, char *dst) { } } +#if 0 static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type, bool releaseVariantPtr) { if (pVariant->nType == TSDB_DATA_TYPE_NULL) { setNull(pDest, type, tDataTypeDesc[type].nSize); @@ -337,7 +338,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type, return 0; } - +#endif static FORCE_INLINE int32_t convertToBoolImpl(char *pStr, int32_t len) { if ((strncasecmp(pStr, "true", len) == 0) && (len == 4)) { return TSDB_TRUE; @@ -386,7 +387,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { } else { if (pVariant->nType >= TSDB_DATA_TYPE_TINYINT && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - sprintf(pBuf == NULL ? *pDest : pBuf, "%lld", pVariant->i64Key); + sprintf(pBuf == NULL ? *pDest : pBuf, "%" PRId64, pVariant->i64Key); } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { sprintf(pBuf == NULL ? *pDest : pBuf, "%lf", pVariant->dKey); } else if (pVariant->nType == TSDB_DATA_TYPE_BOOL) { @@ -411,7 +412,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { int32_t nLen = 0; if (pVariant->nType >= TSDB_DATA_TYPE_TINYINT && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) { - nLen = sprintf(pDst, "%lld", pVariant->i64Key); + nLen = sprintf(pDst, "%" PRId64, pVariant->i64Key); } else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) { nLen = sprintf(pDst, "%lf", pVariant->dKey); } else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { @@ -437,7 +438,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { char* tmp = realloc(pVariant->wpz, (*pDestSize + 1)*TSDB_NCHAR_SIZE); assert(tmp != NULL); - pVariant->wpz = tmp; + pVariant->wpz = (wchar_t *)tmp; } else { taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE); }