From eb9bfffa677e781decd00747266e5fce0d6099f4 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 19 Jun 2020 06:39:49 +0000 Subject: [PATCH] fix coverity error --- src/client/src/TSDBJNIConnector.c | 6 ++---- src/client/src/tscSql.c | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 1a4ad8f050..4ee916c184 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -228,11 +228,9 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn if (user == NULL) { jniTrace("jobj:%p, user is null, use default user %s", jobj, TSDB_DEFAULT_USER); - user = TSDB_DEFAULT_USER; } if (pass == NULL) { jniTrace("jobj:%p, pass is null, use default password", jobj); - pass = TSDB_DEFAULT_PASS; } /* @@ -252,8 +250,8 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn if (host != NULL) (*env)->ReleaseStringUTFChars(env, jhost, host); if (dbname != NULL) (*env)->ReleaseStringUTFChars(env, jdbName, dbname); - if (user != NULL && user != (const char *)TSDB_DEFAULT_USER) (*env)->ReleaseStringUTFChars(env, juser, user); - if (pass != NULL && pass != (const char *)TSDB_DEFAULT_PASS) (*env)->ReleaseStringUTFChars(env, jpass, pass); + if (user != NULL) (*env)->ReleaseStringUTFChars(env, juser, user); + if (pass != NULL) (*env)->ReleaseStringUTFChars(env, jpass, pass); return ret; } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 6d4337e032..0fa841bc7c 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -147,6 +147,8 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) { TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { tscTrace("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db); + if (user == NULL) user = TSDB_DEFAULT_USER; + if (pass == NULL) pass = TSDB_DEFAULT_PASS; STscObj* pObj = NULL; SSqlObj *pSql = taosConnectImpl(ip, user, pass, db, port, syncConnCallback, NULL, (void**) &pObj); -- GitLab