fix:[TD-31696] decimal number check error in config file because precision different in float and double
This commit is contained in:
parent
0e2c6b872a
commit
53eb026559
|
@ -55,7 +55,7 @@ void taosIpPort2String(uint32_t ip, uint16_t port, char *str);
|
|||
|
||||
void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen);
|
||||
|
||||
int32_t parseCfgReal(const char *str, double *out);
|
||||
int32_t parseCfgReal(const char *str, float *out);
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
|
||||
T_MD5_CTX context;
|
||||
|
|
|
@ -691,7 +691,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
|||
continue;
|
||||
}
|
||||
if (taosLockFile(pFile) < 0) {
|
||||
tscError("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
|
||||
tscInfo("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
|
||||
(void)taosCloseFile(&pFile);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ static int32_t cfgSetInt64(SConfigItem *pItem, const char *value, ECfgSrcType st
|
|||
}
|
||||
|
||||
static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
|
||||
double dval;
|
||||
float dval = 0;
|
||||
TAOS_CHECK_RETURN(parseCfgReal(value, &dval));
|
||||
if (dval < pItem->fmin || dval > pItem->fmax) {
|
||||
uError("cfg:%s, type:%s src:%s value:%f out of range[%f, %f]", pItem->name, cfgDtypeStr(pItem->dtype),
|
||||
|
@ -473,7 +473,7 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p
|
|||
} break;
|
||||
case CFG_DTYPE_FLOAT:
|
||||
case CFG_DTYPE_DOUBLE: {
|
||||
double dval;
|
||||
float dval = 0;
|
||||
int32_t code = parseCfgReal(pVal, &dval);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
cfgUnLock(pCfg);
|
||||
|
|
|
@ -506,11 +506,11 @@ size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rs
|
|||
return index;
|
||||
}
|
||||
|
||||
int32_t parseCfgReal(const char *str, double *out) {
|
||||
double val;
|
||||
int32_t parseCfgReal(const char *str, float *out) {
|
||||
float val;
|
||||
char *endPtr;
|
||||
errno = 0;
|
||||
val = taosStr2Double(str, &endPtr);
|
||||
val = taosStr2Float(str, &endPtr);
|
||||
if (str == endPtr || errno == ERANGE || isnan(val)) {
|
||||
return terrno = TSDB_CODE_INVALID_CFG_VALUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue