From ceaf0970c9b778abbb0be1640dc2cd0ec8e6fa0b Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 14 Oct 2022 16:13:35 +0800 Subject: [PATCH] fix: demoapi.c coverity scan issues (#17350) --- examples/c/demoapi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/c/demoapi.c b/examples/c/demoapi.c index c3a6d26776..88d924e97c 100644 --- a/examples/c/demoapi.c +++ b/examples/c/demoapi.c @@ -74,7 +74,12 @@ static void prepare_data(TAOS* taos) { res = taos_query(taos, "create database test;"); taos_free_result(res); taosMsleep(100); - taos_select_db(taos, "test"); + if (taos_select_db(taos, "test")) { + errorPrint("%s() LN%d: error no: %d, reason: %s\n", + __func__, __LINE__, taos_errno(res), taos_errstr(res)); + taos_free_result(res); + return; + } char command[1024] = {0}; sprintf(command, "%s", "create table meters(ts timestamp, f float, n int, bin1 binary(20), c nchar(20), bin2 binary(20)) tags(area int, city binary(20), dist nchar(20), street binary(20));");