From 6088448cdfe3cd152c53136544acc4ee7a508a84 Mon Sep 17 00:00:00 2001 From: Saya Sugiura Date: Wed, 12 Jun 2019 16:18:02 +0900 Subject: Fix alerts from lgtm Signed-off-by: Saya Sugiura --- src/console/dlt-control-common.c | 12 ++++++------ src/console/dlt-sortbytimestamp.c | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/console') diff --git a/src/console/dlt-control-common.c b/src/console/dlt-control-common.c index 964dbe8..d6787fc 100644 --- a/src/console/dlt-control-common.c +++ b/src/console/dlt-control-common.c @@ -83,7 +83,7 @@ static int (*response_analyzer_cb)(char *, void *, int); static pthread_t daemon_connect_thread; -static DltClient client; +static DltClient g_client; static int callback_return = -1; static pthread_mutex_t answer_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t answer_cond = PTHREAD_COND_INITIALIZER; @@ -466,7 +466,7 @@ static int dlt_control_init_connection(DltClient *client, void *cb) static void *dlt_control_listen_to_daemon(void *data) { pr_verbose("Ready to receive DLT answers.\n"); - dlt_client_main_loop(&client, NULL, get_verbosity()); + dlt_client_main_loop(&g_client, NULL, get_verbosity()); return data; } @@ -567,7 +567,7 @@ int dlt_control_send_message(DltControlMsgBody *body, int timeout) /* Re-init the return value */ callback_return = -1; - if (dlt_control_send_message_to_socket(client.sock, msg) != 0) { + if (dlt_control_send_message_to_socket(g_client.sock, msg) != 0) { pr_error("Sending message to daemon failed\n"); free(msg); return -1; @@ -611,9 +611,9 @@ int dlt_control_init(int (*response_analyzer)(char *, void *, int), set_ecuid(ecuid); set_verbosity(verbosity); - if (dlt_control_init_connection(&client, dlt_control_callback) != 0) { + if (dlt_control_init_connection(&g_client, dlt_control_callback) != 0) { pr_error("Connection initialization failed\n"); - dlt_client_cleanup(&client, get_verbosity()); + dlt_client_cleanup(&g_client, get_verbosity()); return -1; } @@ -640,5 +640,5 @@ int dlt_control_deinit(void) /* Stopping the listener thread */ pthread_cancel(daemon_connect_thread); /* Closing the socket */ - return dlt_client_cleanup(&client, get_verbosity()); + return dlt_client_cleanup(&g_client, get_verbosity()); } diff --git a/src/console/dlt-sortbytimestamp.c b/src/console/dlt-sortbytimestamp.c index c006681..c7b5818 100644 --- a/src/console/dlt-sortbytimestamp.c +++ b/src/console/dlt-sortbytimestamp.c @@ -93,7 +93,8 @@ void verbose(int level, char *msg, ...) time_t tnow = time((time_t *)0); if (tnow != -1) { - char *snow = ctime(&tnow); + char snow[50]; + ctime_r(&tnow, snow); /* suppress newline char */ snow[strlen(snow) - 1] = 0; printf("%s: ", snow); @@ -340,7 +341,7 @@ int main(int argc, char *argv[]) return -1; } - if ((end < 0) || (end < begin) || (end >= file.counter)) { + if (end >= file.counter) { fprintf(stderr, "ERROR: Selected end message %d is out of range!\n", end); return -1; } -- cgit v1.2.1