TD-21220 fix assert (#19363)
* TD-21220 fix assert * fix/compile failed * fix/taosEOFFile exception return Co-authored-by: facetosea <25808407@qq.com>
This commit is contained in:
parent
c64b5d5bee
commit
936f282eab
|
@ -116,6 +116,7 @@ extern "C" {
|
|||
#include "osTimer.h"
|
||||
#include "osTimezone.h"
|
||||
#include "taoserror.h"
|
||||
#include "tlog.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -208,10 +208,9 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
|
|||
return 0;
|
||||
}
|
||||
int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno) {
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
if (pFile == NULL || pFile->fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
||||
|
@ -265,7 +264,10 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
|
|||
} else {
|
||||
mode = (tdFileOptions & TD_FILE_TEXT) ? "rt+" : "rb+";
|
||||
}
|
||||
assert(!(tdFileOptions & TD_FILE_EXCL));
|
||||
ASSERT(!(tdFileOptions & TD_FILE_EXCL));
|
||||
if (tdFileOptions & TD_FILE_EXCL) {
|
||||
return NULL;
|
||||
}
|
||||
fp = fopen(path, mode);
|
||||
if (fp == NULL) {
|
||||
return NULL;
|
||||
|
@ -364,7 +366,10 @@ int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count) {
|
|||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
if (pFile->fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
int64_t leftbytes = count;
|
||||
int64_t readbytes;
|
||||
char *tbuf = (char *)buf;
|
||||
|
@ -408,7 +413,10 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset)
|
|||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
if (pFile->fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
size_t pos = _lseeki64(pFile->fd, 0, SEEK_CUR);
|
||||
_lseeki64(pFile->fd, offset, SEEK_SET);
|
||||
|
@ -466,7 +474,10 @@ int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t
|
|||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockWrlock(&(pFile->rwlock));
|
||||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
if (pFile->fd < 0) {
|
||||
return 0;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
size_t pos = _lseeki64(pFile->fd, 0, SEEK_CUR);
|
||||
_lseeki64(pFile->fd, offset, SEEK_SET);
|
||||
|
@ -485,7 +496,10 @@ int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) {
|
|||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||
#endif
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
if (pFile->fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
int64_t ret = _lseeki64(pFile->fd, offset, whence);
|
||||
#else
|
||||
|
@ -501,7 +515,10 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
|||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
if (pFile->fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct stat fileStat;
|
||||
#ifdef WINDOWS
|
||||
|
@ -525,6 +542,10 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
|
|||
}
|
||||
|
||||
int32_t taosLockFile(TdFilePtr pFile) {
|
||||
ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
if(pFile->fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
BOOL fSuccess = FALSE;
|
||||
LARGE_INTEGER fileSize;
|
||||
|
@ -543,13 +564,15 @@ int32_t taosLockFile(TdFilePtr pFile) {
|
|||
}
|
||||
return 0;
|
||||
#else
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
|
||||
return (int32_t)flock(pFile->fd, LOCK_EX | LOCK_NB);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosUnLockFile(TdFilePtr pFile) {
|
||||
ASSERT(pFile->fd >= 0);
|
||||
if(pFile->fd < 0) {
|
||||
return 0;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
BOOL fSuccess = FALSE;
|
||||
OVERLAPPED overlapped = {0};
|
||||
|
@ -561,19 +584,19 @@ int32_t taosUnLockFile(TdFilePtr pFile) {
|
|||
}
|
||||
return 0;
|
||||
#else
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
|
||||
return (int32_t)flock(pFile->fd, LOCK_UN | LOCK_NB);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
||||
#ifdef WINDOWS
|
||||
if (pFile->fd < 0) {
|
||||
errno = EBADF;
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if(pFile->fd < 0) {
|
||||
printf("Ftruncate file error, fd arg was negative\n");
|
||||
return -1;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
|
||||
HANDLE h = (HANDLE)_get_osfhandle(pFile->fd);
|
||||
|
||||
|
@ -618,11 +641,6 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
|
|||
|
||||
return 0;
|
||||
#else
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
assert(pFile->fd >= 0); // Please check if you have closed the file.
|
||||
|
||||
return ftruncate(pFile->fd, l_size);
|
||||
#endif
|
||||
}
|
||||
|
@ -650,7 +668,10 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
|||
if (pFileOut == NULL || pFileIn == NULL) {
|
||||
return 0;
|
||||
}
|
||||
assert(pFileIn->fd >= 0 && pFileOut->fd >= 0);
|
||||
ASSERT(pFileIn->fd >= 0 && pFileOut->fd >= 0);
|
||||
if(pFileIn->fd < 0 || pFileOut->fd < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
||||
|
@ -743,11 +764,9 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
|||
}
|
||||
|
||||
void taosFprintfFile(TdFilePtr pFile, const char *format, ...) {
|
||||
if (pFile == NULL) {
|
||||
if (pFile == NULL || pFile->fp == NULL) {
|
||||
return;
|
||||
}
|
||||
assert(pFile->fp != NULL);
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(pFile->fp, format, ap);
|
||||
|
@ -772,7 +791,10 @@ int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
|
|||
if (*ptrBuf != NULL) {
|
||||
taosMemoryFreeClear(*ptrBuf);
|
||||
}
|
||||
assert(pFile->fp != NULL);
|
||||
ASSERT(pFile->fp != NULL);
|
||||
if (pFile->fp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
*ptrBuf = taosMemoryMalloc(1024);
|
||||
if (*ptrBuf == NULL) return -1;
|
||||
|
@ -792,7 +814,10 @@ int64_t taosGetsFile(TdFilePtr pFile, int32_t maxSize, char *__restrict buf) {
|
|||
if (pFile == NULL || buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
assert(pFile->fp != NULL);
|
||||
ASSERT(pFile->fp != NULL);
|
||||
if (pFile->fp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (fgets(buf, maxSize, pFile->fp) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -801,9 +826,12 @@ int64_t taosGetsFile(TdFilePtr pFile, int32_t maxSize, char *__restrict buf) {
|
|||
|
||||
int32_t taosEOFFile(TdFilePtr pFile) {
|
||||
if (pFile == NULL) {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
ASSERT(pFile->fp != NULL);
|
||||
if(pFile->fp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
assert(pFile->fp != NULL);
|
||||
|
||||
return feof(pFile->fp);
|
||||
}
|
||||
|
|
|
@ -266,7 +266,10 @@ void *taosMemoryRealloc(void *ptr, int64_t size) {
|
|||
if (ptr == NULL) return taosMemoryMalloc(size);
|
||||
|
||||
TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char *)ptr - sizeof(TdMemoryInfo));
|
||||
assert(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL);
|
||||
ASSERT(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL);
|
||||
if (tpTdMemoryInfo->symbol != TD_MEMORY_SYMBOL) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
|
||||
TdMemoryInfo tdMemoryInfo;
|
||||
memcpy(&tdMemoryInfo, pTdMemoryInfo, sizeof(TdMemoryInfo));
|
||||
|
@ -288,8 +291,10 @@ void *taosMemoryStrDup(const char *ptr) {
|
|||
if (ptr == NULL) return NULL;
|
||||
|
||||
TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char *)ptr - sizeof(TdMemoryInfo));
|
||||
assert(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL);
|
||||
|
||||
ASSERT(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL);
|
||||
if (pTdMemoryInfo->symbol != TD_MEMORY_SYMBOL) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
void *tmp = tstrdup(pTdMemoryInfo);
|
||||
if (tmp == NULL) return NULL;
|
||||
|
||||
|
@ -323,7 +328,10 @@ int64_t taosMemorySize(void *ptr) {
|
|||
|
||||
#ifdef USE_TD_MEMORY
|
||||
TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char *)ptr - sizeof(TdMemoryInfo));
|
||||
assert(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL);
|
||||
ASSERT(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL);
|
||||
if (pTdMemoryInfo->symbol != TD_MEMORY_SYMBOL) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
|
||||
return pTdMemoryInfo->memorySize;
|
||||
#else
|
||||
|
@ -348,7 +356,7 @@ void taosMemoryTrim(int32_t size) {
|
|||
|
||||
void* taosMemoryMallocAlign(uint32_t alignment, int64_t size) {
|
||||
#ifdef USE_TD_MEMORY
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
#else
|
||||
#if defined(LINUX)
|
||||
void* p = memalign(alignment, size);
|
||||
|
|
|
@ -86,8 +86,8 @@ int32_t tsem_timewait(tsem_t* sem, int64_t ms) {
|
|||
while ((rc = sem_timedwait(sem, &ts)) == -1 && errno == EINTR) continue;
|
||||
return rc;
|
||||
/* This should have timed out */
|
||||
// assert(errno == ETIMEDOUT);
|
||||
// assert(rc != 0);
|
||||
// ASSERT(errno == ETIMEDOUT);
|
||||
// ASSERT(rc != 0);
|
||||
// GetSystemTimeAsFileTime(&ft_after);
|
||||
// // We specified a non-zero wait. Time must advance.
|
||||
// if (ft_before.dwLowDateTime == ft_after.dwLowDateTime && ft_before.dwHighDateTime == ft_after.dwHighDateTime)
|
||||
|
|
|
@ -298,7 +298,7 @@ int32_t taosGetSockOpt(TdSocketPtr pSocket, int32_t level, int32_t optname, void
|
|||
return -1;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
#else
|
||||
return getsockopt(pSocket->fd, level, optname, optval, (int *)optlen);
|
||||
|
@ -662,7 +662,7 @@ int32_t taosKeepTcpAlive(TdSocketPtr pSocket) {
|
|||
int taosGetLocalIp(const char *eth, char *ip) {
|
||||
#if defined(WINDOWS)
|
||||
// DO NOTHAING
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
#else
|
||||
int fd;
|
||||
|
@ -689,7 +689,7 @@ int taosGetLocalIp(const char *eth, char *ip) {
|
|||
int taosValidIp(uint32_t ip) {
|
||||
#if defined(WINDOWS)
|
||||
// DO NOTHAING
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
#else
|
||||
int ret = -1;
|
||||
|
@ -924,7 +924,7 @@ uint32_t ip2uint(const char *const ip_addr) {
|
|||
|
||||
void taosBlockSIGPIPE() {
|
||||
#ifdef WINDOWS
|
||||
// assert(0);
|
||||
// ASSERT(0);
|
||||
#else
|
||||
sigset_t signal_mask;
|
||||
sigemptyset(&signal_mask);
|
||||
|
@ -994,7 +994,7 @@ int32_t taosGetFqdn(char *fqdn) {
|
|||
#else
|
||||
printf("failed to get hostname, reason:%s\n", strerror(errno));
|
||||
#endif
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ void taosIgnSIGPIPE() { signal(SIGPIPE, SIG_IGN); }
|
|||
|
||||
void taosSetMaskSIGPIPE() {
|
||||
#ifdef WINDOWS
|
||||
// assert(0);
|
||||
// ASSERT(0);
|
||||
#else
|
||||
sigset_t signal_mask;
|
||||
sigemptyset(&signal_mask);
|
||||
|
|
|
@ -112,7 +112,7 @@ int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes) {
|
|||
}
|
||||
|
||||
TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4) {
|
||||
assert(taosMemorySize(target_ucs4) >= len_ucs4 * sizeof(TdUcs4));
|
||||
ASSERT(taosMemorySize(target_ucs4) >= len_ucs4 * sizeof(TdUcs4));
|
||||
return memcpy(target_ucs4, source_ucs4, len_ucs4 * sizeof(TdUcs4));
|
||||
}
|
||||
|
||||
|
@ -355,8 +355,8 @@ int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
|
|||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
@ -367,8 +367,8 @@ uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
|
|||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
@ -379,8 +379,8 @@ int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
|
|||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
@ -391,8 +391,8 @@ uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
|
|||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
@ -403,10 +403,10 @@ int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
|
|||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
assert(tmp >= SHRT_MIN);
|
||||
assert(tmp <= SHRT_MAX);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
ASSERT(tmp >= SHRT_MIN);
|
||||
ASSERT(tmp <= SHRT_MAX);
|
||||
#endif
|
||||
return (int16_t)tmp;
|
||||
}
|
||||
|
@ -417,9 +417,9 @@ uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) {
|
|||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
assert(tmp <= USHRT_MAX);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
ASSERT(tmp <= USHRT_MAX);
|
||||
#endif
|
||||
return (uint16_t)tmp;
|
||||
}
|
||||
|
@ -427,10 +427,10 @@ uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) {
|
|||
int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix) {
|
||||
int32_t tmp = strtol(str, pEnd, radix);
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
assert(tmp >= SCHAR_MIN);
|
||||
assert(tmp <= SCHAR_MAX);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
ASSERT(tmp >= SCHAR_MIN);
|
||||
ASSERT(tmp <= SCHAR_MAX);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
@ -441,9 +441,9 @@ uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) {
|
|||
if (errno == EINVAL) errno = 0;
|
||||
#endif
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
assert(tmp <= UCHAR_MAX);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
ASSERT(tmp <= UCHAR_MAX);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
@ -451,9 +451,9 @@ uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) {
|
|||
double taosStr2Double(const char *str, char **pEnd) {
|
||||
double tmp = strtod(str, pEnd);
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
assert(tmp != HUGE_VAL);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
ASSERT(tmp != HUGE_VAL);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
@ -461,10 +461,10 @@ double taosStr2Double(const char *str, char **pEnd) {
|
|||
float taosStr2Float(const char *str, char **pEnd) {
|
||||
float tmp = strtof(str, pEnd);
|
||||
#ifdef TD_CHECK_STR_TO_INT_ERROR
|
||||
assert(errno != ERANGE);
|
||||
assert(errno != EINVAL);
|
||||
assert(tmp != HUGE_VALF);
|
||||
assert(tmp != NAN);
|
||||
ASSERT(errno != ERANGE);
|
||||
ASSERT(errno != EINVAL);
|
||||
ASSERT(tmp != HUGE_VALF);
|
||||
ASSERT(tmp != NAN);
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ void taosGetSystemInfo() {
|
|||
|
||||
int32_t taosGetEmail(char *email, int32_t maxLen) {
|
||||
#ifdef WINDOWS
|
||||
// assert(0);
|
||||
// ASSERT(0);
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
const char *filepath = "/usr/local/taos/email";
|
||||
|
||||
|
@ -863,7 +863,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
|
|||
|
||||
char *taosGetCmdlineByPID(int pid) {
|
||||
#ifdef WINDOWS
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return "";
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
static char cmdline[1024];
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef struct FILE TdCmd;
|
|||
|
||||
void* taosLoadDll(const char* filename) {
|
||||
#if defined(WINDOWS)
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
return NULL;
|
||||
|
@ -109,7 +109,7 @@ void* taosLoadDll(const char* filename) {
|
|||
|
||||
void* taosLoadSym(void* handle, char* name) {
|
||||
#if defined(WINDOWS)
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
return NULL;
|
||||
|
@ -130,7 +130,7 @@ void* taosLoadSym(void* handle, char* name) {
|
|||
|
||||
void taosCloseDll(void* handle) {
|
||||
#if defined(WINDOWS)
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return;
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
return;
|
||||
|
|
|
@ -233,7 +233,8 @@ int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock) {
|
|||
|
||||
int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int32_t pshared) {
|
||||
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
||||
assert(pshared == 0);
|
||||
ASSERT(pshared == 0);
|
||||
if (pshared != 0) return -1;
|
||||
return pthread_mutex_init((pthread_mutex_t *)lock, NULL);
|
||||
#else
|
||||
return pthread_spin_init((pthread_spinlock_t *)lock, pshared);
|
||||
|
|
|
@ -715,7 +715,10 @@ void putBackAutoPtr(int type, STire* tire) {
|
|||
|
||||
} else {
|
||||
tires[type]->ref--;
|
||||
assert(tires[type]->ref > 0);
|
||||
ASSERT(tires[type]->ref > 0);
|
||||
if (tires[type]->ref <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
taosThreadMutexUnlock(&tiresMutex);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static void shellPositionCursorEnd(SShellCmd *cmd);
|
|||
static void shellPrintChar(char c, int32_t times);
|
||||
static void shellPositionCursor(int32_t step, int32_t direction);
|
||||
static void shellUpdateBuffer(SShellCmd *cmd);
|
||||
static int32_t shellIsReadyGo(SShellCmd *cmd);
|
||||
static bool shellIsReadyGo(SShellCmd *cmd);
|
||||
static void shellGetMbSizeInfo(const char *str, int32_t *size, int32_t *width);
|
||||
static void shellResetCommand(SShellCmd *cmd, const char s[]);
|
||||
void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos);
|
||||
|
@ -62,7 +62,8 @@ int32_t shellCountPrefixOnes(uint8_t c) {
|
|||
}
|
||||
|
||||
void shellGetPrevCharSize(const char *str, int32_t pos, int32_t *size, int32_t *width) {
|
||||
assert(pos > 0);
|
||||
ASSERT(pos > 0);
|
||||
if (pos <= 0) return;
|
||||
|
||||
TdWchar wc;
|
||||
*size = 0;
|
||||
|
@ -75,13 +76,14 @@ void shellGetPrevCharSize(const char *str, int32_t pos, int32_t *size, int32_t *
|
|||
}
|
||||
|
||||
taosMbToWchar(&wc, str + pos, MB_CUR_MAX);
|
||||
// assert(rc == *size); // it will be core, if str is encode by utf8 and taos charset is gbk
|
||||
// ASSERT(rc == *size); // it will be core, if str is encode by utf8 and taos charset is gbk
|
||||
|
||||
*width = taosWcharWidth(wc);
|
||||
}
|
||||
|
||||
void shellGetNextCharSize(const char *str, int32_t pos, int32_t *size, int32_t *width) {
|
||||
assert(pos >= 0);
|
||||
ASSERT(pos >= 0);
|
||||
if(pos < 0) return;
|
||||
|
||||
TdWchar wc;
|
||||
*size = taosMbToWchar(&wc, str + pos, MB_CUR_MAX);
|
||||
|
@ -89,7 +91,8 @@ void shellGetNextCharSize(const char *str, int32_t pos, int32_t *size, int32_t *
|
|||
}
|
||||
|
||||
void shellInsertChar(SShellCmd *cmd, char *c, int32_t size) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
TdWchar wc;
|
||||
if (taosMbToWchar(&wc, c, size) < 0) return;
|
||||
|
@ -135,7 +138,8 @@ void shellInsertStr(SShellCmd *cmd, char *str, int32_t size) {
|
|||
}
|
||||
|
||||
void shellBackspaceChar(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset > 0) {
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
@ -155,7 +159,8 @@ void shellBackspaceChar(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellClearLineBefore(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
memmove(cmd->command, cmd->command + cmd->cursorOffset, cmd->commandSize - cmd->cursorOffset);
|
||||
|
@ -169,7 +174,8 @@ void shellClearLineBefore(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellClearLineAfter(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
cmd->commandSize -= cmd->endOffset - cmd->cursorOffset;
|
||||
|
@ -178,7 +184,8 @@ void shellClearLineAfter(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellDeleteChar(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset < cmd->commandSize) {
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
@ -196,7 +203,8 @@ void shellDeleteChar(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellMoveCursorLeft(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset > 0) {
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
@ -210,7 +218,8 @@ void shellMoveCursorLeft(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellMoveCursorRight(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset < cmd->commandSize) {
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
@ -224,7 +233,8 @@ void shellMoveCursorRight(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellPositionCursorHome(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset > 0) {
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
@ -244,7 +254,8 @@ void positionCursorMiddle(SShellCmd *cmd) {
|
|||
}
|
||||
|
||||
void shellPositionCursorEnd(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (cmd->cursorOffset < cmd->commandSize) {
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
|
@ -279,7 +290,8 @@ void shellPositionCursor(int32_t step, int32_t direction) {
|
|||
}
|
||||
|
||||
void shellUpdateBuffer(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
if (shellRegexMatch(cmd->buffer, "(\\s+$)|(^$)", REG_EXTENDED)) strcat(cmd->command, " ");
|
||||
strcat(cmd->buffer, cmd->command);
|
||||
|
@ -293,8 +305,9 @@ void shellUpdateBuffer(SShellCmd *cmd) {
|
|||
shellShowOnScreen(cmd);
|
||||
}
|
||||
|
||||
int32_t shellIsReadyGo(SShellCmd *cmd) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
bool shellIsReadyGo(SShellCmd *cmd) {
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return false;
|
||||
|
||||
char *total = (char *)taosMemoryCalloc(1, SHELL_MAX_COMMAND_SIZE);
|
||||
memset(cmd->command + cmd->commandSize, 0, SHELL_MAX_COMMAND_SIZE - cmd->commandSize);
|
||||
|
@ -305,11 +318,11 @@ int32_t shellIsReadyGo(SShellCmd *cmd) {
|
|||
"\\s*clear\\s*$)";
|
||||
if (shellRegexMatch(total, reg_str, REG_EXTENDED | REG_ICASE)) {
|
||||
taosMemoryFree(total);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
taosMemoryFree(total);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void shellGetMbSizeInfo(const char *str, int32_t *size, int32_t *width) {
|
||||
|
@ -321,7 +334,8 @@ void shellGetMbSizeInfo(const char *str, int32_t *size, int32_t *width) {
|
|||
}
|
||||
|
||||
void shellResetCommand(SShellCmd *cmd, const char s[]) {
|
||||
assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
ASSERT(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset);
|
||||
if(cmd->cursorOffset > cmd->commandSize || cmd->endOffset < cmd->screenOffset) return;
|
||||
|
||||
shellClearScreen(cmd->endOffset + PSIZE, cmd->screenOffset + PSIZE);
|
||||
memset(cmd->buffer, 0, SHELL_MAX_COMMAND_SIZE);
|
||||
|
@ -399,7 +413,7 @@ void shellShowOnScreen(SShellCmd *cmd) {
|
|||
int32_t ret = taosMbToWchar(&wc, str, MB_CUR_MAX);
|
||||
if (ret < 0) break;
|
||||
size += ret;
|
||||
/* assert(size >= 0); */
|
||||
/* ASSERT(size >= 0); */
|
||||
int32_t width = taosWcharWidth(wc);
|
||||
if (remain_column > width) {
|
||||
printf("%lc", wc);
|
||||
|
|
|
@ -713,7 +713,7 @@ int32_t shellCalcColWidth(TAOS_FIELD *field, int32_t precision) {
|
|||
}
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue