提交 a6c918bf 编写于 作者: F freemine

1. msvc: C4244, conversion-loss-of-data

2. msvc: C4477, "%ld" => "%" PRId64 ""
上级 1df27392
......@@ -290,15 +290,15 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
if (u.v1==0 || u.v1==1) break;
} break;
case TSDB_DATA_TYPE_SMALLINT: {
u.v1 = *(int16_t*)bind->buffer;
u.v1 = (int8_t)*(int16_t*)bind->buffer;
if (u.v1==0 || u.v1==1) break;
} break;
case TSDB_DATA_TYPE_INT: {
u.v1 = *(int32_t*)bind->buffer;
u.v1 = (int8_t)*(int32_t*)bind->buffer;
if (u.v1==0 || u.v1==1) break;
} break;
case TSDB_DATA_TYPE_BIGINT: {
u.v1 = *(int64_t*)bind->buffer;
u.v1 = (int8_t)*(int64_t*)bind->buffer;
if (u.v1==0 || u.v1==1) break;
} break;
case TSDB_DATA_TYPE_BINARY:
......@@ -334,19 +334,19 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
} break;
case TSDB_DATA_TYPE_SMALLINT: {
int16_t v = *(int16_t*)bind->buffer;
u.v1 = v;
u.v1 = (int8_t)v;
if (v >= SCHAR_MIN && v <= SCHAR_MAX) break;
return TSDB_CODE_TSC_INVALID_VALUE;
} break;
case TSDB_DATA_TYPE_INT: {
int32_t v = *(int32_t*)bind->buffer;
u.v1 = v;
u.v1 = (int8_t)v;
if (v >= SCHAR_MIN && v <= SCHAR_MAX) break;
return TSDB_CODE_TSC_INVALID_VALUE;
} break;
case TSDB_DATA_TYPE_BIGINT: {
int64_t v = *(int64_t*)bind->buffer;
u.v1 = v;
u.v1 = (int8_t)v;
if (v >= SCHAR_MIN && v <= SCHAR_MAX) break;
return TSDB_CODE_TSC_INVALID_VALUE;
} break;
......@@ -354,9 +354,9 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
case TSDB_DATA_TYPE_NCHAR: {
int64_t v;
int n,r;
r = sscanf((const char*)bind->buffer, "%ld%n", &v, &n);
r = sscanf((const char*)bind->buffer, "%" PRId64 "%n", &v, &n);
if (r==1 && n==strlen((const char*)bind->buffer)) {
u.v1 = v;
u.v1 = (int8_t)v;
if (v >= SCHAR_MIN && v <= SCHAR_MAX) break;
}
return TSDB_CODE_TSC_INVALID_VALUE;
......@@ -377,17 +377,17 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_SMALLINT: {
int v = *(int16_t*)bind->buffer;
u.v2 = v;
u.v2 = (int16_t)v;
} break;
case TSDB_DATA_TYPE_INT: {
int32_t v = *(int32_t*)bind->buffer;
u.v2 = v;
u.v2 = (int16_t)v;
if (v >= SHRT_MIN && v <= SHRT_MAX) break;
return TSDB_CODE_TSC_INVALID_VALUE;
} break;
case TSDB_DATA_TYPE_BIGINT: {
int64_t v = *(int64_t*)bind->buffer;
u.v2 = v;
u.v2 = (int16_t)v;
if (v >= SHRT_MIN && v <= SHRT_MAX) break;
return TSDB_CODE_TSC_INVALID_VALUE;
} break;
......@@ -395,9 +395,9 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
case TSDB_DATA_TYPE_NCHAR: {
int64_t v;
int n,r;
r = sscanf((const char*)bind->buffer, "%ld%n", &v, &n);
r = sscanf((const char*)bind->buffer, "%" PRId64 "%n", &v, &n);
if (r==1 && n==strlen((const char*)bind->buffer)) {
u.v2 = v;
u.v2 = (int16_t)v;
if (v >= SHRT_MIN && v <= SHRT_MAX) break;
}
return TSDB_CODE_TSC_INVALID_VALUE;
......@@ -430,7 +430,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
case TSDB_DATA_TYPE_NCHAR: {
int64_t v;
int n,r;
r = sscanf((const char*)bind->buffer, "%ld%n", &v, &n);
r = sscanf((const char*)bind->buffer, "%" PRId64 "%n", &v, &n);
if (r==1 && n==strlen((const char*)bind->buffer)) {
u.v4 = v;
if (v >= INT_MIN && v <= INT_MAX) break;
......@@ -457,11 +457,11 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
u.f4 = *(int16_t*)bind->buffer;
} break;
case TSDB_DATA_TYPE_INT: {
u.f4 = *(int32_t*)bind->buffer;
u.f4 = (float)*(int32_t*)bind->buffer;
// shall we check equality?
} break;
case TSDB_DATA_TYPE_BIGINT: {
u.f4 = *(int64_t*)bind->buffer;
u.f4 = (float)*(int64_t*)bind->buffer;
// shall we check equality?
} break;
case TSDB_DATA_TYPE_FLOAT: {
......@@ -509,7 +509,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
case TSDB_DATA_TYPE_NCHAR: {
int64_t v;
int n,r;
r = sscanf((const char*)bind->buffer, "%ld%n", &v, &n);
r = sscanf((const char*)bind->buffer, "%" PRId64 "%n", &v, &n);
if (r==1 && n==strlen((const char*)bind->buffer)) {
u.v8 = v;
break;
......@@ -539,7 +539,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
u.f8 = *(int32_t*)bind->buffer;
} break;
case TSDB_DATA_TYPE_BIGINT: {
u.f8 = *(int64_t*)bind->buffer;
u.f8 = (double)*(int64_t*)bind->buffer;
} break;
case TSDB_DATA_TYPE_FLOAT: {
u.f8 = *(float*)bind->buffer;
......@@ -553,7 +553,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
int n,r;
r = sscanf((const char*)bind->buffer, "%lf%n", &v, &n);
if (r==1 && n==strlen((const char*)bind->buffer)) {
u.v8 = v;
u.f8 = v;
break;
}
return TSDB_CODE_TSC_INVALID_VALUE;
......@@ -574,7 +574,8 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: {
// is this the correct way to call taosParseTime?
if (taosParseTime(bind->buffer, &u.v8, *bind->length, 3, tsDaylight) == TSDB_CODE_SUCCESS) {
int32_t len = (int32_t)*bind->length;
if (taosParseTime(bind->buffer, &u.v8, len, 3, tsDaylight) == TSDB_CODE_SUCCESS) {
break;
}
return TSDB_CODE_TSC_INVALID_VALUE;
......
......@@ -2690,7 +2690,7 @@ static SQLRETURN conv_tsdb_v8_to_c_double(sql_t *sql, c_target_t *target, TAOS_F
static SQLRETURN conv_tsdb_v8_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8)
{
char buf[64];
int n = snprintf(buf, sizeof(buf), "%ld", v8);
int n = snprintf(buf, sizeof(buf), "%" PRId64 "", v8);
DASSERT(n<sizeof(buf));
*target->soi = n;
strncpy(target->ptr, buf, (n>=target->len ? target->len : n+1));
......@@ -2702,7 +2702,7 @@ static SQLRETURN conv_tsdb_v8_to_c_char(sql_t *sql, c_target_t *target, TAOS_FIE
static SQLRETURN conv_tsdb_v8_to_c_binary(sql_t *sql, c_target_t *target, TAOS_FIELD *field, int64_t v8)
{
char buf[64];
int n = snprintf(buf, sizeof(buf), "%ld", v8);
int n = snprintf(buf, sizeof(buf), "%" PRId64 "", v8);
DASSERT(n<sizeof(buf));
*target->soi = n;
strncpy(target->ptr, buf, (n>target->len ? target->len : n));
......@@ -3053,7 +3053,7 @@ static SQLRETURN conv_tsdb_str_to_c_v8(sql_t *sql, c_target_t *target, TAOS_FIEL
}
char buf[64];
snprintf(buf, sizeof(buf), "%ld", v);
snprintf(buf, sizeof(buf), "%" PRId64 "", v);
if (strcmp(buf, str)==0) return SQL_SUCCESS;
......@@ -3156,7 +3156,7 @@ const char* tsdb_int64_to_ts(int64_t src, int64_t *dst)
*dst = src;
char buf[4096];
int n = snprintf(buf, sizeof(buf), "%ld", src);
int n = snprintf(buf, sizeof(buf), "%" PRId64 "", src);
DASSERT(n>=0);
DASSERT(n<sizeof(buf));
......@@ -3181,7 +3181,7 @@ const char* tsdb_int64_to_double(int64_t src, double *dst)
const char* tsdb_int64_to_char(int64_t src, char *dst, size_t dlen)
{
int n = snprintf(dst, dlen, "%ld", src);
int n = snprintf(dst, dlen, "%" PRId64 "", src);
if (n<dlen) return NULL;
return "22003";
}
......@@ -3321,7 +3321,7 @@ const char* tsdb_chars_to_bit(const char *src, int8_t *dst)
{
int bytes = 0;
int64_t v = 0;
int n = sscanf(src, "%ld%n", &v, &bytes);
int n = sscanf(src, "%" PRId64 "%n", &v, &bytes);
if (n!=1) return "22018";
if (bytes!=strlen(src)) {
......@@ -3342,7 +3342,7 @@ const char* tsdb_chars_to_tinyint(const char *src, int8_t *dst)
{
int bytes = 0;
int64_t v = 0;
int n = sscanf(src, "%ld%n", &v, &bytes);
int n = sscanf(src, "%" PRId64 "%n", &v, &bytes);
if (n!=1) return "22018";
......@@ -3364,7 +3364,7 @@ const char* tsdb_chars_to_smallint(const char *src, int16_t *dst)
{
int bytes = 0;
int64_t v = 0;
int n = sscanf(src, "%ld%n", &v, &bytes);
int n = sscanf(src, "%" PRId64 "%n", &v, &bytes);
if (n!=1) return "22018";
......@@ -3386,7 +3386,7 @@ const char* tsdb_chars_to_int(const char *src, int32_t *dst)
{
int bytes = 0;
int64_t v = 0;
int n = sscanf(src, "%ld%n", &v, &bytes);
int n = sscanf(src, "%" PRId64 "%n", &v, &bytes);
if (n!=1) return "22018";
......@@ -3408,7 +3408,7 @@ const char* tsdb_chars_to_bigint(const char *src, int64_t *dst)
{
int bytes = 0;
int64_t v = 0;
int n = sscanf(src, "%ld%n", &v, &bytes);
int n = sscanf(src, "%" PRId64 "%n", &v, &bytes);
if (n!=1) return "22018";
......@@ -3430,7 +3430,7 @@ const char* tsdb_chars_to_ts(const char *src, int64_t *dst)
{
int bytes = 0;
int64_t v = 0;
int n = sscanf(src, "%ld%n", &v, &bytes);
int n = sscanf(src, "%" PRId64 "%n", &v, &bytes);
if (n!=1) return "22018";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册