From 8a0a808c5d42eef207cbb2cdfdf0546b160bac77 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Wed, 8 Jan 2025 16:18:18 +0000 Subject: [PATCH] minor indentations --- src/ctlib/unittests/.gitignore | 1 + src/ctlib/unittests/timeout.c | 54 +++++++++++++--------------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/ctlib/unittests/.gitignore b/src/ctlib/unittests/.gitignore index 5ca1f9467..01a70d5b8 100644 --- a/src/ctlib/unittests/.gitignore +++ b/src/ctlib/unittests/.gitignore @@ -37,4 +37,5 @@ /variant /errors /ct_command +/timeout /libcommon.a diff --git a/src/ctlib/unittests/timeout.c b/src/ctlib/unittests/timeout.c index 518107890..736037ef1 100644 --- a/src/ctlib/unittests/timeout.c +++ b/src/ctlib/unittests/timeout.c @@ -15,19 +15,17 @@ static const char sql[] = "select getdate() as 'endtime'"; static int -on_interrupt(CS_CONNECTION * con TDS_UNUSED) +on_interrupt(CS_CONNECTION *con TDS_UNUSED) { - printf("In on_interrupt, %ld seconds elapsed.\n", - (long int) (time(NULL) - start_time)); + printf("In on_interrupt, %ld seconds elapsed.\n", (long int) (time(NULL) - start_time)); return CS_INT_CONTINUE; } static int -on_client_msg(CS_CONTEXT * ctx, CS_CONNECTION * con, CS_CLIENTMSG * errmsg) +on_client_msg(CS_CONTEXT *ctx, CS_CONNECTION *con, CS_CLIENTMSG *errmsg) { - if (errmsg->msgnumber == 20003) { /* TDSETIME */ - fprintf(stderr, "%d timeout(s) received in %ld seconds; ", - ++ntimeouts, (long int) (time(NULL) - start_time)); + if (errmsg->msgnumber == 20003) { /* TDSETIME */ + fprintf(stderr, "%d timeout(s) received in %ld seconds; ", ++ntimeouts, (long int) (time(NULL) - start_time)); if (ntimeouts > max_timeouts) { if (++ncancels > 1) { fputs("could not time out cleanly;" @@ -37,9 +35,7 @@ on_client_msg(CS_CONTEXT * ctx, CS_CONNECTION * con, CS_CLIENTMSG * errmsg) } fputs("lost patience;" " cancelling (allowing 10 seconds)\n", stderr); - if (CS_FAIL == ct_con_props(con, CS_SET, CS_TIMEOUT, - &cancel_timeout, CS_UNUSED, - NULL)) + if (CS_FAIL == ct_con_props(con, CS_SET, CS_TIMEOUT, &cancel_timeout, CS_UNUSED, NULL)) fputs("... but ct_con_props() failed" " in error handler.\n", stderr); return CS_FAIL; @@ -51,7 +47,7 @@ on_client_msg(CS_CONTEXT * ctx, CS_CONNECTION * con, CS_CLIENTMSG * errmsg) } static void -test(CS_CONNECTION * con, CS_COMMAND * cmd) +test(CS_CONNECTION *con, CS_COMMAND *cmd) { CS_INT result_type = 0; CS_RETCODE ret; @@ -61,27 +57,22 @@ test(CS_CONNECTION * con, CS_COMMAND * cmd) printf("Using %d-second query timeouts.\n", timeout_seconds); - if (CS_FAIL == ct_con_props(con, CS_SET, CS_TIMEOUT, &timeout_seconds, - CS_UNUSED, NULL)) { - fputs("Failed: ct_con_props(..., CS_SET, CS_TIMEOUT, ...).", - stderr); + if (CS_FAIL == ct_con_props(con, CS_SET, CS_TIMEOUT, &timeout_seconds, CS_UNUSED, NULL)) { + fputs("Failed: ct_con_props(..., CS_SET, CS_TIMEOUT, ...).", stderr); exit(1); } /* Send something that will take a while to execute. */ printf("Issuing a query that will take 30 seconds.\n"); - if (CS_SUCCEED != ct_command(cmd, CS_LANG_CMD, (void *) sql, - sizeof(sql) - 1, CS_UNUSED)) { + if (CS_SUCCEED != ct_command(cmd, CS_LANG_CMD, (void *) sql, sizeof(sql) - 1, CS_UNUSED)) { fputs("Failed: ct_command.\n", stderr); exit(1); } - start_time = time(NULL); /* Track for reporting purposes. */ + start_time = time(NULL); /* Track for reporting purposes. */ ntimeouts = 0; - if (CS_FAIL == ct_callback(NULL, con, CS_SET, CS_CLIENTMSG_CB, - &on_client_msg) - || CS_FAIL == ct_callback(NULL, con, CS_SET, CS_INTERRUPT_CB, - &on_interrupt)) { + if (CS_FAIL == ct_callback(NULL, con, CS_SET, CS_CLIENTMSG_CB, &on_client_msg) + || CS_FAIL == ct_callback(NULL, con, CS_SET, CS_INTERRUPT_CB, &on_interrupt)) { fputs("Failed: ct_callback.\n", stderr); exit(1); } @@ -93,23 +84,20 @@ test(CS_CONNECTION * con, CS_COMMAND * cmd) ret = ct_results(cmd, &result_type); if (ret == CS_SUCCEED) { - fprintf(stderr, - "Query unexpectedly succeeded, with result type %d.\n", - result_type); + fprintf(stderr, "Query unexpectedly succeeded, with result type %d.\n", result_type); } else { - printf("Query failed as expected, with return code %d.\n", - ret); + printf("Query failed as expected, with return code %d.\n", ret); } } -int main(int argc, char** argv) +int +main(int argc, char **argv) { - CS_CONTEXT * ctx; - CS_CONNECTION * con; - CS_COMMAND * cmd; + CS_CONTEXT *ctx; + CS_CONNECTION *con; + CS_COMMAND *cmd; - if (CS_SUCCEED != try_ctlogin_with_options(argc, argv, &ctx, &con, &cmd, - false)) { + if (CS_SUCCEED != try_ctlogin_with_options(argc, argv, &ctx, &con, &cmd, false)) { fputs("Customary setup failed.\n", stderr); return 1; }