diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 6f5d407a7348b2fa7768f0266c5dcd79a6b4653f..4d278056851f66f1f50dcee9758fa05984120805 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -1209,7 +1209,6 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { } int totalLen = 0; - char temp[16000]; // fetch the records row by row while((row = taos_fetch_row(res))) { @@ -1220,6 +1219,7 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { memset(databuf, 0, 100*1024*1024); } num_rows++; + char temp[16000] = {0}; int len = taos_print_row(temp, row, fields, num_fields); len += sprintf(temp + len, "\n"); //printf("query result:%s\n", temp); diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 2961750efce3f1e746aa2e82ecb5160488065681..a482e2902e2ef635c9ec1b35e249806d17ba9fbb 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -86,7 +86,7 @@ static int print_result(TAOS_RES* res, int blockFetch) { } } else { while ((row = taos_fetch_row(res))) { - char temp[256]; + char temp[256] = {0}; taos_print_row(temp, row, fields, num_fields); puts(temp); nRows++; @@ -389,10 +389,10 @@ void verify_prepare(TAOS* taos) { int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); @@ -606,10 +606,10 @@ void verify_prepare2(TAOS* taos) { int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); @@ -856,8 +856,7 @@ void verify_prepare3(TAOS* taos) { // fetch the records row by row while ((row = taos_fetch_row(result))) { - memset(temp, 0, sizeof(temp)/sizeof(temp[0])); - + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index 0b1cd7b5d2d304a89656c98e88b2a620e16ae5a1..f8c69d0043591afa8f5e32e80bd35e9413e60e76 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -116,12 +116,12 @@ void Test(TAOS *taos, char *qstr, int index) { int rows = 0; int num_fields = taos_field_count(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[1024]; printf("num_fields = %d\n", num_fields); printf("select * from table, result:\n"); // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[1024] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/prepare.c b/tests/examples/c/prepare.c index 13d71beea6156aa32677c20ccc2d222d28826b24..723b340a923c0bf326599e8090f8c6142a249053 100644 --- a/tests/examples/c/prepare.c +++ b/tests/examples/c/prepare.c @@ -184,10 +184,10 @@ int main(int argc, char *argv[]) int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/subscribe.c b/tests/examples/c/subscribe.c index 1d3533fa5ee89f7425a9b0563e738b4e0703e6c8..ad12f0e7a55b0f471f249f92f30cf659c94586a5 100644 --- a/tests/examples/c/subscribe.c +++ b/tests/examples/c/subscribe.c @@ -14,8 +14,6 @@ void print_result(TAOS_RES* res, int blockFetch) { int num_fields = taos_num_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res); int nRows = 0; - char buf[4096]; - if (blockFetch) { nRows = taos_fetch_block(res, &row); @@ -25,6 +23,7 @@ void print_result(TAOS_RES* res, int blockFetch) { //} } else { while ((row = taos_fetch_row(res))) { + char buf[4096] = {0}; taos_print_row(buf, row, fields, num_fields); puts(buf); nRows++;