summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/console/dlt-receive.c25
-rw-r--r--src/daemon/dlt-daemon.c184
-rw-r--r--src/daemon/dlt_daemon_client.c68
-rw-r--r--src/daemon/dlt_daemon_common.c18
-rw-r--r--src/daemon/dlt_daemon_connection.c7
-rw-r--r--src/daemon/dlt_daemon_event_handler.c11
-rw-r--r--src/daemon/dlt_daemon_socket.c14
-rw-r--r--src/lib/dlt_client.c13
-rw-r--r--src/lib/dlt_user.c30
-rw-r--r--src/shared/dlt_common.c152
-rw-r--r--src/shared/dlt_config_file_parser.c5
11 files changed, 156 insertions, 371 deletions
diff --git a/src/console/dlt-receive.c b/src/console/dlt-receive.c
index 9cfad36..aef92b9 100644
--- a/src/console/dlt-receive.c
+++ b/src/console/dlt-receive.c
@@ -188,13 +188,10 @@ int64_t convert_arg_to_byte_size(char *arg)
min_size += 2048 /* DLT_USER_BUF_MAX_SIZE */;
if (min_size > result) {
- char tmp[256];
- snprintf(tmp,
- 256,
+ dlt_vlog(LOG_ERR,
"ERROR: Specified limit: %" PRId64 "is smaller than a the size of a single message: %" PRId64 "!\n",
result,
min_size);
- dlt_log(LOG_ERR, tmp);
result = -2;
}
@@ -212,9 +209,7 @@ int dlt_receive_open_output_file(DltReceiveData *dltdata)
if (glob(dltdata->ovalue, GLOB_TILDE | GLOB_NOSORT, NULL, &outer) == 0) {
if (dltdata->vflag) {
- char tmp[256];
- snprintf(tmp, 256, "File %s already exists, need to rename first\n", dltdata->ovalue);
- dlt_log(LOG_INFO, tmp);
+ dlt_vlog(LOG_INFO, "File %s already exists, need to rename first\n", dltdata->ovalue);
}
if (dltdata->part_num < 0) {
@@ -257,15 +252,12 @@ int dlt_receive_open_output_file(DltReceiveData *dltdata)
snprintf(filename, PATH_MAX, "%s.%i.dlt", dltdata->ovaluebase, dltdata->part_num++);
if (rename(dltdata->ovalue, filename) != 0) {
- char tmp[256];
- snprintf(tmp, 256, "ERROR: rename %s to %s failed with error %s\n", dltdata->ovalue, filename,
- strerror(errno));
- dlt_log(LOG_ERR, tmp);
+ dlt_vlog(LOG_ERR, "ERROR: rename %s to %s failed with error %s\n",
+ dltdata->ovalue, filename, strerror(errno));
}
else if (dltdata->vflag) {
- char tmp[256];
- snprintf(tmp, 256, "Renaming existing file from %s to %s\n", dltdata->ovalue, filename);
- dlt_log(LOG_INFO, tmp);
+ dlt_vlog(LOG_INFO, "Renaming existing file from %s to %s\n",
+ dltdata->ovalue, filename);
}
} /* if (file_already_exists) */
@@ -483,9 +475,8 @@ int main(int argc, char *argv[])
/* open DLT output file */
if (dltdata.ovalue) {
if (dltdata.climit > -1) {
- char tmp[256];
- snprintf(tmp, 256, "Using file size limit of %" PRId64 "bytes\n", dltdata.climit);
- dlt_log(LOG_INFO, tmp);
+ dlt_vlog(LOG_INFO, "Using file size limit of %" PRId64 "bytes\n",
+ dltdata.climit);
dltdata.ohandle = dlt_receive_open_output_file(&dltdata);
}
else { /* in case no limit for the output file is given, we simply overwrite any existing file */
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index b4c82b0..9144b2a 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -76,9 +76,6 @@
\{
*/
-/** Global text output buffer, mainly used for creation of error/warning strings */
-static char str[DLT_DAEMON_TEXTBUFSIZE];
-
static int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose);
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
@@ -632,6 +629,7 @@ static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
int main(int argc, char *argv[])
{
char version[DLT_DAEMON_TEXTBUFSIZE];
+ char local_str[DLT_DAEMON_TEXTBUFSIZE];
DltDaemonLocal daemon_local;
DltDaemon daemon;
int back = 0;
@@ -663,8 +661,7 @@ int main(int argc, char *argv[])
/* Print version information */
dlt_get_version(version, DLT_DAEMON_TEXTBUFSIZE);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Starting DLT Daemon; %s\n", version);
- dlt_log(LOG_NOTICE, str);
+ dlt_vlog(LOG_NOTICE, "Starting DLT Daemon; %s\n", version);
PRINT_FUNCTION_VERBOSE(daemon_local.flags.vflag);
@@ -672,8 +669,7 @@ int main(int argc, char *argv[])
/* Make sure the parent user directory is created */
if (dlt_mkdir_recursive(dltFifoBaseDir) != 0) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Base dir %s cannot be created!\n", dltFifoBaseDir);
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", dltFifoBaseDir);
return -1;
}
@@ -789,9 +785,11 @@ int main(int argc, char *argv[])
&daemon,
&daemon_local);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Exiting DLT daemon... [%d]", g_signo);
- dlt_daemon_log_internal(&daemon, &daemon_local, str, daemon_local.flags.vflag);
- dlt_log(LOG_NOTICE, str);
+ snprintf(local_str, DLT_DAEMON_TEXTBUFSIZE, "Exiting DLT daemon... [%d]",
+ g_signo);
+ dlt_daemon_log_internal(&daemon, &daemon_local, local_str,
+ daemon_local.flags.vflag);
+ dlt_log(LOG_NOTICE, local_str);
dlt_daemon_local_cleanup(&daemon, &daemon_local, daemon_local.flags.vflag);
@@ -974,11 +972,8 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
fd = open(daemon_local->flags.yvalue, O_RDWR);
if (fd < 0) {
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Failed to open serial device %s\n",
+ dlt_vlog(LOG_ERR, "Failed to open serial device %s\n",
daemon_local->flags.yvalue);
- dlt_log(LOG_ERR, str);
daemon_local->flags.yvalue[0] = 0;
return -1;
@@ -996,12 +991,8 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
close(fd);
daemon_local->flags.yvalue[0] = 0;
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Failed to configure serial device %s (%s) \n",
- daemon_local->flags.yvalue,
- strerror(errno));
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "Failed to configure serial device %s (%s) \n",
+ daemon_local->flags.yvalue, strerror(errno));
return -1;
}
@@ -1032,7 +1023,6 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
int ret;
int fd = -1;
int fifo_size;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
/* open named pipe(FIFO) to receive DLT messages from users */
umask(0);
@@ -1044,43 +1034,32 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
ret = mkfifo(tmpFifo, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
if (ret == -1) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "FIFO user %s cannot be created (%s)!\n",
- tmpFifo,
- strerror(errno));
- dlt_log(LOG_WARNING, local_str);
+ dlt_vlog(LOG_WARNING, "FIFO user %s cannot be created (%s)!\n",
+ tmpFifo, strerror(errno));
return -1;
} /* if */
fd = open(tmpFifo, O_RDWR);
if (fd == -1) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "FIFO user %s cannot be opened (%s)!\n",
- tmpFifo,
- strerror(errno));
- dlt_log(LOG_WARNING, local_str);
+ dlt_vlog(LOG_WARNING, "FIFO user %s cannot be opened (%s)!\n",
+ tmpFifo, strerror(errno));
return -1;
} /* if */
if (daemon_local->daemonFifoSize != 0) {
/* Set Daemon FIFO size */
if (fcntl(fd, F_SETPIPE_SZ, daemon_local->daemonFifoSize) == -1) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "set FIFO size error: %s\n", strerror(errno));
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "set FIFO size error: %s\n", strerror(errno));
}
}
/* Get Daemon FIFO size */
if ((fifo_size = fcntl(fd, F_GETPIPE_SZ, 0)) == -1) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "get FIFO size error: %s\n", strerror(errno));
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "get FIFO size error: %s\n", strerror(errno));
}
else {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "FIFO size: %d\n", fifo_size);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "FIFO size: %d\n", fifo_size);
}
/* Early init, to be able to catch client (app) connections
@@ -1099,19 +1078,13 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
int fd = -1;
int mask = 0;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: Invalid function parameters\n",
- __func__);
-
- dlt_log(LOG_ERR, local_str);
+ dlt_vlog(LOG_ERR, "%s: Invalid function parameters\n", __func__);
return -1;
}
@@ -1499,8 +1472,8 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
/* check if overflow occurred */
if (daemon->overflow_counter) {
if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) {
- sprintf(str, "%u messages discarded!\n", daemon->overflow_counter);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "%u messages discarded!\n",
+ daemon->overflow_counter);
daemon->overflow_counter = 0;
}
}
@@ -1603,12 +1576,9 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
daemon_local->flags.vflag);
}
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
+ dlt_vlog(LOG_DEBUG,
"New client connection #%d established, Total Clients : %d\n",
- in_sock,
- daemon_local->client_connections);
- dlt_log(LOG_DEBUG, local_str);
+ in_sock, daemon_local->client_connections);
dlt_daemon_log_internal(daemon, daemon_local, local_str, daemon_local->flags.vflag);
if (daemon_local->client_connections == 1) {
@@ -1820,9 +1790,7 @@ int dlt_daemon_process_control_connect(
}
if (verbose) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE,
- "New connection to control client established\n");
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "New connection to control client established\n");
}
return 0;
@@ -1872,9 +1840,7 @@ int dlt_daemon_process_app_connect(
}
if (verbose) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE,
- "New connection to application established\n");
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "New connection to application established\n");
}
return 0;
@@ -1954,18 +1920,14 @@ static int dlt_daemon_process_user_message_not_sup(DltDaemon *daemon,
DltReceiver *receiver,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
DltUserHeader *userheader = (DltUserHeader *)(receiver->buf);
(void)daemon;
(void)daemon_local;
PRINT_FUNCTION_VERBOSE(verbose);
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid user message type received: %d!\n",
+ dlt_vlog(LOG_ERR, "Invalid user message type received: %d!\n",
userheader->message);
- dlt_log(LOG_ERR, local_str);
/* remove user header */
if (dlt_receiver_remove(receiver, sizeof(DltUserHeader)) == -1)
@@ -2091,18 +2053,13 @@ int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
int verbose)
{
uint32_t len = sizeof(DltUserControlMsgBufferOverflow);
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
DltUserControlMsgBufferOverflow userpayload;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
@@ -2158,7 +2115,6 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
DltDaemonApplication *application = NULL;
DltDaemonApplication *old_application = NULL;
pid_t old_pid = 0;
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
char description[DLT_DAEMON_DESCSIZE + 1] = { '\0' };
DltUserControlMsgRegisterApplication userapp;
char *origin;
@@ -2166,12 +2122,8 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
@@ -2236,15 +2188,13 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
dlt_daemon_user_send_log_state(daemon, application, verbose);
if (application == NULL) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Can't add ApplicationID '%.4s' for PID %d\n",
- userapp.apid,
- userapp.pid);
- dlt_log(LOG_WARNING, local_str);
+ dlt_vlog(LOG_WARNING, "Can't add ApplicationID '%.4s' for PID %d\n",
+ userapp.apid, userapp.pid);
return -1;
}
else if (old_pid != application->pid) {
+ char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"ApplicationID '%.4s' registered for PID %d, Description=%s\n",
@@ -2266,7 +2216,6 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
int to_remove = 0;
uint32_t len = sizeof(DltUserControlMsgRegisterContext);
DltUserControlMsgRegisterContext userctxt;
@@ -2281,12 +2230,8 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
@@ -2380,16 +2325,14 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
verbose);
if (context == 0) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
+ dlt_vlog(LOG_WARNING,
"Can't add ContextID '%.4s' for ApID '%.4s'\n in %s",
- userctxt.ctid,
- userctxt.apid,
- __func__);
- dlt_log(LOG_WARNING, local_str);
+ userctxt.ctid, userctxt.apid, __func__);
return -1;
}
else {
+ char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"ContextID '%.4s' registered for ApID '%.4s', Description=%s\n",
@@ -2474,7 +2417,6 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
{
uint32_t len = sizeof(DltUserControlMsgUnregisterApplication);
DltUserControlMsgUnregisterApplication userapp;
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
DltDaemonApplication *application = NULL;
DltDaemonContext *context;
int i, offset_base;
@@ -2548,6 +2490,8 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
return -1;
}
else {
+ char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Unregistered ApID '%.4s'\n",
@@ -2569,7 +2513,6 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
uint32_t len = sizeof(DltUserControlMsgUnregisterContext);
DltUserControlMsgUnregisterContext userctxt;
DltDaemonContext *context;
@@ -2612,6 +2555,8 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
return -1;
}
else {
+ char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Unregistered CtID '%.4s' for ApID '%.4s'\n",
@@ -2728,8 +2673,8 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
/* check if overflow occurred */
if (daemon->overflow_counter) {
if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) {
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%u messages discarded!\n", daemon->overflow_counter);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "%u messages discarded!\n",
+ daemon->overflow_counter);
daemon->overflow_counter = 0;
}
}
@@ -2768,7 +2713,6 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
int sent;
uint8_t *rcv_buffer = NULL;
int size;
@@ -2780,25 +2724,16 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
rcv_buffer = calloc(1, DLT_SHM_RCV_BUFFER_SIZE);
if (!rcv_buffer) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "No memory to allocate receiver buffer in %s.\n",
+ dlt_vlog(LOG_ERR, "No memory to allocate receiver buffer in %s.\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
-
return -1;
}
@@ -3020,18 +2955,13 @@ int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
DltReceiver *rec,
int verbose)
{
- char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
uint32_t len = sizeof(DltUserControlMsgLogMode);
DltUserControlMsgLogMode userctxt;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Invalid function parameters used for %s\n",
+ dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
__func__);
-
- dlt_log(LOG_ERR, local_str);
return -1;
}
@@ -3162,12 +3092,8 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
local_fd = timerfd_create(CLOCK_MONOTONIC, 0);
if (local_fd < 0) {
- snprintf(str,
- sizeof(str),
- "<%s> timerfd_create failed: %s\n",
- timer_name,
- strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "<%s> timerfd_create failed: %s\n",
+ timer_name, strerror(errno));
}
l_timer_spec.it_interval.tv_sec = period_sec;
@@ -3176,12 +3102,8 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
l_timer_spec.it_value.tv_nsec = 0;
if (timerfd_settime(local_fd, 0, &l_timer_spec, NULL) < 0) {
- snprintf(str,
- sizeof(str),
- "<%s> timerfd_settime failed: %s\n",
- timer_name,
- strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "<%s> timerfd_settime failed: %s\n",
+ timer_name, strerror(errno));
local_fd = -1;
}
}
@@ -3191,12 +3113,8 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
* Event handling registration is done later on with other connections.
*/
if (local_fd > 0) {
- snprintf(str,
- sizeof(str),
- "<%s> initialized with %d timer\n",
- timer_name,
+ dlt_vlog(LOG_INFO, "<%s> initialized with %d timer\n", timer_name,
period_sec);
- dlt_log(LOG_INFO, str);
}
return dlt_connection_create(daemon_local,
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c
index e2a0d12..4565322 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -69,9 +69,6 @@
#include "dlt_daemon_offline_logstorage.h"
#include "dlt_gateway.h"
-/** Global text output buffer, mainly used for creation of error/warning strings */
-static char str[DLT_DAEMON_TEXTBUFSIZE];
-
/** Inline function to calculate/set the requested log level or traces status
* with default log level or trace status when "ForceContextLogLevelAndTraceStatus"
* is enabled and set to 1 in dlt.conf file.
@@ -180,14 +177,9 @@ int dlt_daemon_client_send_all(DltDaemon *daemon,
void *msg1, *msg2;
int msg1_sz, msg2_sz;
int ret = 0;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
if ((daemon == NULL) || (daemon_local == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: Invalid parameters\n",
- __func__);
- dlt_log(LOG_ERR, local_str);
+ dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return 0;
}
@@ -1011,8 +1003,7 @@ void dlt_daemon_control_get_log_info(int sock,
offset += sizeof(uint16_t);
#if (DLT_DEBUG_GETLOGINFO == 1)
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "#apid: %d \n", count_app_ids);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "#apid: %d \n", count_app_ids);
#endif
for (i = 0; i < count_app_ids; i++) {
@@ -1044,8 +1035,7 @@ void dlt_daemon_control_get_log_info(int sock,
#if (DLT_DEBUG_GETLOGINFO == 1)
dlt_print_id(buf, apid);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "apid: %s\n", buf);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "apid: %s\n", buf);
#endif
if (req->apid[0] != '\0')
@@ -1057,14 +1047,12 @@ void dlt_daemon_control_get_log_info(int sock,
offset += sizeof(uint16_t);
#if (DLT_DEBUG_GETLOGINFO == 1)
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "#ctid: %d \n", count_con_ids);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "#ctid: %d \n", count_con_ids);
#endif
for (j = 0; j < count_con_ids; j++) {
#if (DLT_DEBUG_GETLOGINFO == 1)
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "j: %d \n", j);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "j: %d \n", j);
#endif
if (!((count_con_ids == 1) && (req->apid[0] != '\0') &&
@@ -1083,8 +1071,7 @@ void dlt_daemon_control_get_log_info(int sock,
#if (DLT_DEBUG_GETLOGINFO == 1)
dlt_print_id(buf, context->ctid);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "ctid: %s \n", buf);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "ctid: %s \n", buf);
#endif
/* Mode 4, 6, 7 */
@@ -1119,8 +1106,8 @@ void dlt_daemon_control_get_log_info(int sock,
}
#if (DLT_DEBUG_GETLOGINFO == 1)
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "ll=%d ts=%d \n", (int32_t)ll, (int32_t)ts);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "ll=%d ts=%d \n", (int32_t)ll,
+ (int32_t)ts);
#endif
}
@@ -2203,26 +2190,19 @@ int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
{
uint64_t expir = 0;
ssize_t res = 0;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: invalid parameters",
- __func__);
- dlt_log(LOG_ERR, local_str);
+ dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
return -1;
}
res = read(receiver->fd, &expir, sizeof(expir));
if (res < 0) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: Fail to read timer (%s)\n", __func__, strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "%s: Fail to read timer (%s)\n", __func__,
+ strerror(errno));
/* Activity received on timer_wd, but unable to read the fd:
* let's go on sending notification */
}
@@ -2255,26 +2235,19 @@ int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon,
{
uint64_t expir = 0;
ssize_t res = 0;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: invalid parameters",
- __func__);
- dlt_log(LOG_ERR, str);
+ dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
return -1;
}
res = read(receiver->fd, &expir, sizeof(expir));
if (res < 0) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: Fail to read timer (%s)\n", __func__, strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "%s: Fail to read timer (%s)\n", __func__,
+ strerror(errno));
/* Activity received on timer_wd, but unable to read the fd:
* let's go on sending notification */
}
@@ -2313,27 +2286,18 @@ int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
{
uint64_t expir = 0;
ssize_t res = -1;
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "%s: invalid parameters",
- __func__);
- dlt_log(LOG_ERR, local_str);
+ dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
return res;
}
res = read(receiver->fd, &expir, sizeof(expir));
if (res < 0) {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Failed to read timer_wd; %s\n",
- strerror(errno));
- dlt_log(LOG_WARNING, local_str);
+ dlt_vlog(LOG_WARNING, "Failed to read timer_wd; %s\n", strerror(errno));
/* Activity received on timer_wd, but unable to read the fd:
* let's go on sending notification */
}
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index 4a39d64..cb392dc 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -88,7 +88,6 @@
#include "dlt_daemon_socket.h"
#include "dlt_daemon_serial.h"
-static char str[DLT_DAEMON_COMMON_TEXTBUFSIZE];
char *app_recv_buffer = NULL; /* pointer to receiver buffer for application msges */
sem_t dlt_daemon_mutex;
@@ -240,13 +239,8 @@ int dlt_daemon_init(DltDaemon *daemon,
dlt_set_id(daemon->ecuid, "");
/* initialize ring buffer for client connection */
- snprintf(str,
- DLT_DAEMON_COMMON_TEXTBUFSIZE,
- "Ringbuffer configuration: %lu/%lu/%lu\n",
- RingbufferMinSize,
- RingbufferMaxSize,
- RingbufferStepSize);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "Ringbuffer configuration: %lu/%lu/%lu\n",
+ RingbufferMinSize, RingbufferMaxSize, RingbufferStepSize);
if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize, RingbufferMaxSize,
RingbufferStepSize) == DLT_RETURN_ERROR)
@@ -1312,12 +1306,12 @@ int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int v
/* parse arguments here */
if (strcmp(token, "LoggingMode") == 0) {
daemon->mode = atoi(value);
- snprintf(str, DLT_DAEMON_COMMON_TEXTBUFSIZE, "Runtime Option: %s=%d\n", token, daemon->mode);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "Runtime Option: %s=%d\n", token,
+ daemon->mode);
}
else {
- snprintf(str, DLT_DAEMON_COMMON_TEXTBUFSIZE, "Unknown option: %s=%s\n", token, value);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "Unknown option: %s=%s\n", token,
+ value);
}
}
}
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c
index b1a4080..7973b9c 100644
--- a/src/daemon/dlt_daemon_connection.c
+++ b/src/daemon/dlt_daemon_connection.c
@@ -390,13 +390,8 @@ int dlt_connection_create(DltDaemonLocal *daemon_local,
temp->receiver = dlt_connection_get_receiver(daemon_local, type, fd);
if (!temp->receiver) {
- char local_str[DLT_DAEMON_TEXTBUFSIZE];
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Unable to get receiver from %d connection.\n",
+ dlt_vlog(LOG_CRIT, "Unable to get receiver from %d connection.\n",
type);
-
- dlt_log(LOG_CRIT, local_str);
free(temp);
return -1;
}
diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c
index 38aa022..b2af56b 100644
--- a/src/daemon/dlt_daemon_event_handler.c
+++ b/src/daemon/dlt_daemon_event_handler.c
@@ -187,7 +187,6 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
{
int ret = 0;
unsigned int i = 0;
- char str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
int (*callback)(DltDaemon *, DltDaemonLocal *, DltReceiver *, int) = NULL;
if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL))
@@ -249,11 +248,8 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
callback = dlt_connection_get_callback(con);
if (!callback) {
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Unable to find function for %d handle type.\n",
+ dlt_vlog(LOG_CRIT, "Unable to find function for %d handle type.\n",
type);
- dlt_log(LOG_CRIT, str);
return -1;
}
@@ -262,11 +258,8 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
daemon_local,
con->receiver,
daemon_local->flags.vflag) == -1) {
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Processing from %d handle type failed!\n",
+ dlt_vlog(LOG_CRIT, "Processing from %d handle type failed!\n",
type);
- dlt_log(LOG_CRIT, str);
return -1;
}
}
diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c
index f9c4ab2..addd3ce 100644
--- a/src/daemon/dlt_daemon_socket.c
+++ b/src/daemon/dlt_daemon_socket.c
@@ -59,9 +59,6 @@
#include "dlt_daemon_socket.h"
-/** Global text output buffer, mainly used for creation of error/warning strings */
-static char str[DLT_DAEMON_TEXTBUFSIZE];
-
int dlt_daemon_socket_open(int *sock, unsigned int servPort)
{
int yes = 1;
@@ -92,9 +89,8 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
continue;
}
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%s: Socket created - socket_family:%i, socket_type:%i, protocol:%i\n",
+ dlt_vlog(LOG_INFO, "%s: Socket created - socket_family:%i, socket_type:%i, protocol:%i\n",
__FUNCTION__, p->ai_family, p->ai_socktype, p->ai_protocol);
- dlt_log(LOG_INFO, str);
if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
const int lastErrno = errno;
@@ -122,15 +118,11 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
freeaddrinfo(servinfo);
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%s: Listening on port: %u\n", __FUNCTION__, servPort);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "%s: Listening on port: %u\n", __func__, servPort);
/* get socket buffer size */
- snprintf(str,
- DLT_DAEMON_TEXTBUFSIZE,
- "dlt_daemon_socket_open: Socket send queue size: %d\n",
+ dlt_vlog(LOG_INFO, "dlt_daemon_socket_open: Socket send queue size: %d\n",
dlt_daemon_socket_get_send_qeue_max_size(*sock));
- dlt_log(LOG_INFO, str);
if (listen(*sock, 3) < 0) {
const int lastErrno = errno;
diff --git a/src/lib/dlt_client.c b/src/lib/dlt_client.c
index af7e118..62389c2 100644
--- a/src/lib/dlt_client.c
+++ b/src/lib/dlt_client.c
@@ -100,8 +100,6 @@
static int (*message_callback_function)(DltMessage *message, void *data) = NULL;
-static char str[DLT_CLIENT_TEXTBUFSIZE];
-
void dlt_client_register_message_callback(int (*registerd_callback)(DltMessage *message, void *data))
{
message_callback_function = registerd_callback;
@@ -184,19 +182,14 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
for (p = servinfo; p != NULL; p = p->ai_next) {
if ((client->sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) {
- snprintf(str, DLT_CLIENT_TEXTBUFSIZE,
- "socket() failed! %s\n",
- strerror(errno));
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "socket() failed! %s\n", strerror(errno));
continue;
}
if (connect(client->sock, p->ai_addr, p->ai_addrlen) < 0) {
- snprintf(str, DLT_CLIENT_TEXTBUFSIZE,
- "connect() failed! %s\n",
- strerror(errno));
close(client->sock);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "connect() failed! %s\n",
+ strerror(errno));
continue;
}
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index dbaf7f1..c5be77c 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -87,8 +87,6 @@ static char dlt_user_dir[NAME_MAX + 1];
static char dlt_daemon_fifo[NAME_MAX + 1];
#endif
-static char str[DLT_USER_BUFFER_LENGTH];
-
static sem_t dlt_mutex;
static pthread_t dlt_receiverthread_handle;
@@ -118,12 +116,9 @@ void dlt_lock_mutex(pthread_mutex_t *mutex)
if ( lock_mutex_result != 0 )
{
- snprintf(str,
- DLT_USER_BUFFER_LENGTH,
+ dlt_vlog(LOG_ERR,
"Mutex lock failed unexpected pid=%i with result %i!\n",
- getpid(),
- lock_mutex_result);
- dlt_log(LOG_ERR, str);
+ getpid(), lock_mutex_result);
}
}
@@ -371,8 +366,9 @@ DltReturnValue dlt_init(void)
/* init shared memory */
if (dlt_shm_init_client(&(dlt_user.dlt_shm), DLT_SHM_KEY) < 0) {
- snprintf(str, DLT_USER_BUFFER_LENGTH, "Logging disabled, Shared memory %d cannot be created!\n", DLT_SHM_KEY);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING,
+ "Logging disabled, Shared memory %d cannot be created!\n",
+ DLT_SHM_KEY);
/*return 0; */
}
#endif
@@ -574,11 +570,9 @@ DltReturnValue dlt_init_common(void)
if (env_initial_log_level != NULL) {
if (dlt_env_extract_ll_set(&env_initial_log_level, &dlt_user.initial_ll_set) != 0) {
- snprintf(str,
- DLT_USER_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"Unable to parse initial set of log-levels from environment! Env:\n%s\n",
getenv("DLT_INITIAL_LOG_LEVEL"));
- dlt_log(LOG_WARNING, str);
}
}
@@ -4571,10 +4565,9 @@ void dlt_stop_threads()
dlt_receiverthread_result = pthread_cancel(dlt_receiverthread_handle);
if (dlt_receiverthread_result != 0) {
- snprintf(str, DLT_USER_BUFFER_LENGTH,
+ dlt_vlog(LOG_ERR,
"ERROR pthread_cancel(dlt_receiverthread_handle): %s\n",
strerror(errno));
- dlt_log(LOG_ERR, str);
}
}
@@ -4586,10 +4579,9 @@ void dlt_stop_threads()
dlt_segmented_nwt_result = pthread_cancel(dlt_user.dlt_segmented_nwt_handle);
if (dlt_segmented_nwt_result != 0) {
- snprintf(str, DLT_USER_BUFFER_LENGTH,
+ dlt_vlog(LOG_ERR,
"ERROR pthread_cancel(dlt_user.dlt_segmented_nwt_handle): %s\n",
strerror(errno));
- dlt_log(LOG_ERR, str);
}
}
@@ -4598,10 +4590,9 @@ void dlt_stop_threads()
int joined = pthread_join(dlt_receiverthread_handle, NULL);
if (joined < 0) {
- snprintf(str, DLT_USER_BUFFER_LENGTH,
+ dlt_vlog(LOG_ERR,
"ERROR pthread_join(dlt_receiverthread_handle, NULL): %s\n",
strerror(errno));
- dlt_log(LOG_ERR, str);
}
dlt_receiverthread_handle = 0; /* set to invalid */
@@ -4611,10 +4602,9 @@ void dlt_stop_threads()
int joined = pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL);
if (joined < 0) {
- snprintf(str, DLT_USER_BUFFER_LENGTH,
+ dlt_vlog(LOG_ERR,
"ERROR pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL): %s\n",
strerror(errno));
- dlt_log(LOG_ERR, str);
}
dlt_user.dlt_segmented_nwt_handle = 0; /* set to invalid */
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index e74ee5b..4d6fcee 100644
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -65,8 +65,6 @@
# include <winbase.h>
#endif
-static char str[DLT_COMMON_BUFFER_LENGTH];
-
const char dltSerialHeader[DLT_ID_SIZE] = { 'D', 'L', 'S', 1 };
char dltSerialHeaderChar[DLT_ID_SIZE] = { 'D', 'L', 'S', 1 };
char dltFifoBaseDir[PATH_MAX + 1] = "/tmp";
@@ -125,9 +123,9 @@ DltReturnValue dlt_print_hex_string(char *text, int textlength, uint8_t *ptr, in
/* Length 3: AB_ , A is first digit of hex number, B is second digit of hex number, _ is space */
if (textlength < (size * 3)) {
- char str[255];
- snprintf(str, 254, "String does not fit hex data (available=%d, required=%d) !\n", textlength, size * 3);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING,
+ "String does not fit hex data (available=%d, required=%d) !\n",
+ textlength, size * 3);
return DLT_RETURN_ERROR;
}
@@ -169,12 +167,9 @@ DltReturnValue dlt_print_mixed_string(char *text, int textlength, uint8_t *ptr,
* ((size/16) lines + extra line for the rest) */
if (textlength < required_size) {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"String does not fit mixed data (available=%d, required=%d) !\n",
- textlength,
- required_size);
- dlt_log(LOG_WARNING, str);
+ textlength, required_size);
return DLT_RETURN_ERROR;
}
@@ -262,9 +257,9 @@ DltReturnValue dlt_print_char_string(char **text, int textlength, uint8_t *ptr,
return DLT_RETURN_WRONG_PARAMETER;
if (textlength < size) {
- char str[255];
- snprintf(str, 254, "String does not fit character data (available=%d, required=%d) !\n", textlength, size);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING,
+ "String does not fit character data (available=%d, required=%d) !\n",
+ textlength, size);
return DLT_RETURN_WRONG_PARAMETER;
}
@@ -387,8 +382,7 @@ DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verb
handle = fopen(filename, "r");
if (handle == NULL) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Filter file %s cannot be opened!\n", filename);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "Filter file %s cannot be opened!\n", filename);
return DLT_RETURN_ERROR;
}
@@ -430,11 +424,9 @@ DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verb
dlt_filter_add(filter, apid, ctid, verbose);
}
else {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"Maximum number (%d) of allowed filters reached, ignoring rest of filters!\n",
DLT_FILTER_MAX);
- dlt_log(LOG_WARNING, str);
}
}
@@ -457,8 +449,7 @@ DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verb
handle = fopen(filename, "w");
if (handle == NULL) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Filter file %s cannot be opened!\n", filename);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "Filter file %s cannot be opened!\n", filename);
return DLT_RETURN_ERROR;
}
@@ -520,8 +511,9 @@ DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *c
return DLT_RETURN_WRONG_PARAMETER;
if (filter->counter >= DLT_FILTER_MAX) {
- sprintf(str, "Maximum number (%d) of allowed filters reached, ignoring filter!\n", DLT_FILTER_MAX);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING,
+ "Maximum number (%d) of allowed filters reached, ignoring filter!\n",
+ DLT_FILTER_MAX);
return DLT_RETURN_ERROR;
}
@@ -809,10 +801,9 @@ DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength,
id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
if (textlength < ((datalength * 3) + 20)) {
- char str[255];
- snprintf(str, 254, "String does not fit binary data (available=%d, required=%d) !\n", textlength,
- (datalength * 3) + 20);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING,
+ "String does not fit binary data (available=%d, required=%d) !\n",
+ textlength, (datalength * 3) + 20);
return DLT_RETURN_ERROR;
}
@@ -985,22 +976,15 @@ int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int
msg->datasize = DLT_BETOH_16(msg->standardheader->len) - (msg->headersize - sizeof(DltStorageHeader));
if (verbose) {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
- "BufferLength=%d, HeaderSize=%d, DataSize=%d\n",
- length,
- msg->headersize,
- msg->datasize);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "BufferLength=%d, HeaderSize=%d, DataSize=%d\n",
+ length, msg->headersize, msg->datasize);
}
/* check data size */
if (msg->datasize < 0) {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"Plausibility check failed. Complete message size too short (%d)!\n",
msg->datasize);
- dlt_log(LOG_WARNING, str);
return DLT_MESSAGE_ERROR_CONTENT;
}
@@ -1043,9 +1027,9 @@ int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int
}
if (msg->databuffer == NULL) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Cannot allocate memory for payload buffer of size %d!\n",
+ dlt_vlog(LOG_WARNING,
+ "Cannot allocate memory for payload buffer of size %d!\n",
msg->datasize);
- dlt_log(LOG_WARNING, str);
return DLT_MESSAGE_ERROR_UNKNOWN;
}
@@ -1184,18 +1168,15 @@ DltReturnValue dlt_file_read_header(DltFile *file, int verbose)
file->msg.datasize = DLT_BETOH_16(file->msg.standardheader->len) + sizeof(DltStorageHeader) - file->msg.headersize;
if (verbose) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "HeaderSize=%d, DataSize=%d\n", file->msg.headersize,
- file->msg.datasize);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "HeaderSize=%d, DataSize=%d\n",
+ file->msg.headersize, file->msg.datasize);
}
/* check data size */
if (file->msg.datasize < 0) {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"Plausibility check failed. Complete message size too short! (%d)\n",
file->msg.datasize);
- dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
@@ -1277,18 +1258,15 @@ DltReturnValue dlt_file_read_header_raw(DltFile *file, int resync, int verbose)
file->msg.datasize = DLT_BETOH_16(file->msg.standardheader->len) + sizeof(DltStorageHeader) - file->msg.headersize;
if (verbose) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "HeaderSize=%d, DataSize=%d\n", file->msg.headersize,
- file->msg.datasize);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "HeaderSize=%d, DataSize=%d\n",
+ file->msg.headersize, file->msg.datasize);
}
/* check data size */
if (file->msg.datasize < 0) {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"Plausibility check failed. Complete message size too short! (%d)\n",
file->msg.datasize);
- dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
@@ -1358,22 +1336,18 @@ DltReturnValue dlt_file_read_data(DltFile *file, int verbose)
}
if (file->msg.databuffer == NULL) {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"Cannot allocate memory for payload buffer of size %d!\n",
file->msg.datasize);
- dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
/* load payload data from file */
if (fread(file->msg.databuffer, file->msg.datasize, 1, file->handle) != 1) {
if (file->msg.datasize != 0) {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"Cannot read payload data from file of size %d!\n",
file->msg.datasize);
- dlt_log(LOG_WARNING, str);
return DLT_RETURN_ERROR;
}
}
@@ -1403,29 +1377,25 @@ DltReturnValue dlt_file_open(DltFile *file, const char *filename, int verbose)
file->handle = fopen(filename, "rb");
if (file->handle == NULL) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH - 1, "File %s cannot be opened!\n", filename);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "File %s cannot be opened!\n", filename);
return DLT_RETURN_ERROR;
}
if (0 != fseek(file->handle, 0, SEEK_END)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_open: Seek failed to 0,SEEK_END");
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "dlt_file_open: Seek failed to 0,SEEK_END");
return DLT_RETURN_ERROR;
}
file->file_length = ftell(file->handle);
if (0 != fseek(file->handle, 0, SEEK_SET)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_open: Seek failed to 0,SEEK_SET");
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "dlt_file_open: Seek failed to 0,SEEK_SET");
return DLT_RETURN_ERROR;
}
if (verbose) {
/* print file length */
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "File is %lu bytes long\n", file->file_length);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "File is %lu bytes long\n", file->file_length);
}
return DLT_RETURN_OK;
@@ -1437,8 +1407,7 @@ DltReturnValue dlt_file_read(DltFile *file, int verbose)
int found = DLT_RETURN_OK;
if (verbose) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "%s: Message %d:\n", __func__, file->counter_total);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "%s: Message %d:\n", __func__, file->counter_total);
}
if (file == NULL)
@@ -1461,15 +1430,14 @@ DltReturnValue dlt_file_read(DltFile *file, int verbose)
/* set to end of last succesful read message, because of conflicting calls to dlt_file_read and dlt_file_message */
if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek failed to file_position %ld \n", file->file_position);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "Seek failed to file_position %ld \n",
+ file->file_position);
return DLT_RETURN_ERROR;
}
/* get file position at start of DLT message */
if (verbose) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Position in file: %ld\n", file->file_position);
- dlt_log(LOG_INFO, str);
+ dlt_vlog(LOG_INFO, "Position in file: %ld\n", file->file_position);
}
/* read header */
@@ -1484,8 +1452,7 @@ DltReturnValue dlt_file_read(DltFile *file, int verbose)
if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek to last file pos failed!\n");
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "Seek to last file pos failed!\n");
}
return DLT_RETURN_ERROR;
@@ -1505,13 +1472,12 @@ DltReturnValue dlt_file_read(DltFile *file, int verbose)
/* skip payload data */
if (fseek(file->handle, file->msg.datasize, SEEK_CUR) != 0) {
/* go back to last position in file */
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek failed to skip payload data of size %d!\n",
+ dlt_vlog(LOG_WARNING,
+ "Seek failed to skip payload data of size %d!\n",
file->msg.datasize);
- dlt_log(LOG_WARNING, str);
if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek back also failed!\n");
- dlt_log(LOG_WARNING, str);
+ dlt_log(LOG_WARNING, "Seek back also failed!\n");
}
return DLT_RETURN_ERROR;
@@ -1524,17 +1490,14 @@ DltReturnValue dlt_file_read(DltFile *file, int verbose)
file->msg.headersize - sizeof(DltStorageHeader) - sizeof(DltStandardHeader) + file->msg.datasize,
SEEK_CUR)) {
- snprintf(str,
- DLT_COMMON_BUFFER_LENGTH,
+ dlt_vlog(LOG_WARNING,
"Seek failed to skip extra header and payload data from file of size %d!\n",
- file->msg.headersize - (int32_t)sizeof(DltStorageHeader) - (int32_t)sizeof(DltStandardHeader) +
- file->msg.datasize);
- dlt_log(LOG_WARNING, str);
+ file->msg.headersize - (int32_t)sizeof(DltStorageHeader) -
+ (int32_t)sizeof(DltStandardHeader) + file->msg.datasize);
/* go back to last position in file */
if (fseek(file->handle, file->file_position, SEEK_SET)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek back also failed!\n");
- dlt_log(LOG_WARNING, str);
+ dlt_log(LOG_WARNING, "Seek back also failed!\n");
}
return DLT_RETURN_ERROR;
@@ -1563,8 +1526,7 @@ DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
long *ptr;
if (verbose) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "%s: Message %d:\n", __func__, file->counter_total);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "%s: Message %d:\n", __func__, file->counter_total);
}
if (file == NULL)
@@ -1591,16 +1553,14 @@ DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
/* get file position at start of DLT message */
if (verbose) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Position in file: %ld\n", file->file_position);
- dlt_log(LOG_DEBUG, str);
+ dlt_vlog(LOG_DEBUG, "Position in file: %ld\n", file->file_position);
}
/* read header */
if (dlt_file_read_header_raw(file, resync, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_read_raw, fseek failed 1\n");
- dlt_log(LOG_WARNING, str);
+ dlt_log(LOG_WARNING, "dlt_file_read_raw, fseek failed 1\n");
}
return DLT_RETURN_ERROR;
@@ -1610,8 +1570,7 @@ DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_read_raw, fseek failed 2\n");
- dlt_log(LOG_WARNING, str);
+ dlt_log(LOG_WARNING, "dlt_file_read_raw, fseek failed 2\n");
}
return DLT_RETURN_ERROR;
@@ -1620,8 +1579,7 @@ DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
if (dlt_file_read_data(file, verbose) < DLT_RETURN_OK) {
/* go back to last position in file */
if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "dlt_file_read_raw, fseek failed 3\n");
- dlt_log(LOG_WARNING, str);
+ dlt_log(LOG_WARNING, "dlt_file_read_raw, fseek failed 3\n");
}
return DLT_RETURN_ERROR;
@@ -1667,16 +1625,14 @@ DltReturnValue dlt_file_message(DltFile *file, int index, int verbose)
/* check if message is in range */
if (index >= file->counter) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Message %d out of range!\r\n", index);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "Message %d out of range!\r\n", index);
return DLT_RETURN_WRONG_PARAMETER;
}
/* seek to position in file */
if (fseek(file->handle, file->index[index], SEEK_SET) != 0) {
- snprintf(str, DLT_COMMON_BUFFER_LENGTH, "Seek to message %d to position %ld failed!\r\n", index,
- file->index[index]);
- dlt_log(LOG_WARNING, str);
+ dlt_vlog(LOG_WARNING, "Seek to message %d to position %ld failed!\r\n",
+ index, file->index[index]);
return DLT_RETURN_ERROR;
}
diff --git a/src/shared/dlt_config_file_parser.c b/src/shared/dlt_config_file_parser.c
index 8c882e2..738fe3a 100644
--- a/src/shared/dlt_config_file_parser.c
+++ b/src/shared/dlt_config_file_parser.c
@@ -357,7 +357,6 @@ static int dlt_config_file_read_line(char *line, char *str1, char *str2)
static void dlt_config_file_read_file(DltConfigFile *file, FILE *hdl)
{
int ret = 0;
- char error_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
char line[DLT_CONFIG_FILE_LINE_MAX_LEN] = { '\0' };
char str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
char str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
@@ -393,8 +392,8 @@ static void dlt_config_file_read_file(DltConfigFile *file, FILE *hdl)
break;
default: /* something is wrong with the line */
- snprintf(error_str, DLT_DAEMON_TEXTBUFSIZE, "Line (%d) \"%s\" is invalid\n", line_number, line);
- dlt_log(LOG_WARNING, error_str);
+ dlt_vlog(LOG_WARNING, "Line (%d) \"%s\" is invalid\n", line_number,
+ line);
}
}
}