summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/daemon/dlt_daemon_common_cfg.h2
-rw-r--r--src/daemon/dlt_daemon_event_handler.h6
-rw-r--r--src/daemon/dlt_daemon_event_handler_types.h6
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage.h8
-rw-r--r--src/daemon/dlt_daemon_serial.c27
-rw-r--r--src/daemon/dlt_daemon_serial.h7
-rw-r--r--src/daemon/dlt_daemon_socket.c62
-rw-r--r--src/daemon/dlt_daemon_socket.h7
-rw-r--r--src/lib/dlt_client_cfg.h4
-rw-r--r--src/lib/dlt_env_ll.c157
-rw-r--r--src/lib/dlt_filetransfer.c143
-rw-r--r--src/lib/dlt_user_cfg.h3
12 files changed, 267 insertions, 165 deletions
diff --git a/src/daemon/dlt_daemon_common_cfg.h b/src/daemon/dlt_daemon_common_cfg.h
index 8fbd9b0..77c6ca6 100644
--- a/src/daemon/dlt_daemon_common_cfg.h
+++ b/src/daemon/dlt_daemon_common_cfg.h
@@ -87,7 +87,7 @@
"/dlt-ctrl.sock"
#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
-# define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
+#define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
"/dlt-app.sock"
#endif
diff --git a/src/daemon/dlt_daemon_event_handler.h b/src/daemon/dlt_daemon_event_handler.h
index bd550d3..62ef89b 100644
--- a/src/daemon/dlt_daemon_event_handler.h
+++ b/src/daemon/dlt_daemon_event_handler.h
@@ -32,7 +32,7 @@
#include "dlt-daemon.h"
#ifndef DLT_DAEMON_EVENT_HANDLER_H
-# define DLT_DAEMON_EVENT_HANDLER_H
+#define DLT_DAEMON_EVENT_HANDLER_H
int dlt_daemon_prepare_event_handling(DltEventHandler *);
int dlt_daemon_handle_event(DltEventHandler *, DltDaemon *, DltDaemonLocal *);
@@ -56,11 +56,11 @@ int dlt_event_handler_unregister_connection(DltEventHandler *,
int dlt_connection_check_activate(DltEventHandler *,
DltConnection *,
int);
-# ifdef DLT_UNIT_TESTS
+#ifdef DLT_UNIT_TESTS
int dlt_daemon_remove_connection(DltEventHandler *ev,
DltConnection *to_remove);
void dlt_daemon_add_connection(DltEventHandler *ev,
DltConnection *connection);
-# endif
+#endif
#endif /* DLT_DAEMON_EVENT_HANDLER_H */
diff --git a/src/daemon/dlt_daemon_event_handler_types.h b/src/daemon/dlt_daemon_event_handler_types.h
index 0b16d08..a879d4d 100644
--- a/src/daemon/dlt_daemon_event_handler_types.h
+++ b/src/daemon/dlt_daemon_event_handler_types.h
@@ -30,7 +30,7 @@
#include "dlt_daemon_connection_types.h"
#ifndef DLT_DAEMON_EVENT_HANDLER_TYPES_H
-# define DLT_DAEMON_EVENT_HANDLER_TYPES_H
+#define DLT_DAEMON_EVENT_HANDLER_TYPES_H
/* FIXME: Remove the need for DltDaemonLocal everywhere in the code
* These typedefs are needed by DltDaemonLocal which is
@@ -41,9 +41,9 @@
typedef enum {
DLT_TIMER_PACKET = 0,
DLT_TIMER_ECU,
-# ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
DLT_TIMER_SYSTEMD,
-# endif
+#endif
DLT_TIMER_GATEWAY,
DLT_TIMER_UNKNOWN
} DltTimers;
diff --git a/src/daemon/dlt_daemon_offline_logstorage.h b/src/daemon/dlt_daemon_offline_logstorage.h
index 956b09d..cd7803d 100644
--- a/src/daemon/dlt_daemon_offline_logstorage.h
+++ b/src/daemon/dlt_daemon_offline_logstorage.h
@@ -59,10 +59,10 @@
#define DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL 0
typedef enum {
- DLT_DAEMON_LOGSTORAGE_CMP_MIN = 0,
- DLT_DAEMON_LOGSTORAGE_CMP_APID = 1,
- DLT_DAEMON_LOGSTORAGE_CMP_CTID = 2,
- DLT_DAEMON_LOGSTORAGE_CMP_ECID = 3,
+ DLT_DAEMON_LOGSTORAGE_CMP_MIN = 0,
+ DLT_DAEMON_LOGSTORAGE_CMP_APID = 1,
+ DLT_DAEMON_LOGSTORAGE_CMP_CTID = 2,
+ DLT_DAEMON_LOGSTORAGE_CMP_ECID = 3,
DLT_DAEMON_LOGSTORAGE_CMP_MAX,
} DltCompareFlags;
diff --git a/src/daemon/dlt_daemon_serial.c b/src/daemon/dlt_daemon_serial.c
index 36b7990..272a3dc 100644
--- a/src/daemon/dlt_daemon_serial.c
+++ b/src/daemon/dlt_daemon_serial.c
@@ -66,24 +66,33 @@
#include "dlt_daemon_serial.h"
-int dlt_daemon_serial_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader)
+int dlt_daemon_serial_send(int sock,
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ char serialheader)
{
/* Optional: Send serial header, if requested */
- if (serialheader)
- if (0 > write(sock, dltSerialHeader, sizeof(dltSerialHeader)))
+ if (serialheader) {
+ if (0 > write(sock, dltSerialHeader, sizeof(dltSerialHeader))) {
return DLT_DAEMON_ERROR_SEND_FAILED;
+ }
+ }
/* Send data */
- if (data1 && (size1 > 0))
- if (0 > write(sock, data1, size1))
+ if (data1 && (size1 > 0)) {
+ if (0 > write(sock, data1, size1)) {
return DLT_DAEMON_ERROR_SEND_FAILED;
+ }
+ }
-
-
- if (data2 && (size2 > 0))
- if (0 > write(sock, data2, size2))
+ if (data2 && (size2 > 0)) {
+ if (0 > write(sock, data2, size2)) {
return DLT_DAEMON_ERROR_SEND_FAILED;
+ }
+ }
return DLT_DAEMON_ERROR_OK;
}
diff --git a/src/daemon/dlt_daemon_serial.h b/src/daemon/dlt_daemon_serial.h
index fe49bff..08fdfac 100644
--- a/src/daemon/dlt_daemon_serial.h
+++ b/src/daemon/dlt_daemon_serial.h
@@ -60,6 +60,11 @@
#include "dlt_common.h"
#include "dlt_user.h"
-int dlt_daemon_serial_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader);
+int dlt_daemon_serial_send(int sock,
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ char serialheader);
#endif /* DLT_DAEMON_SERIAL_H */
diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c
index 9db48b9..803b821 100644
--- a/src/daemon/dlt_daemon_socket.c
+++ b/src/daemon/dlt_daemon_socket.c
@@ -41,11 +41,11 @@
#include <sys/ioctl.h>
#ifdef linux
-# include <sys/timerfd.h>
+#include <sys/timerfd.h>
#endif
#include <sys/time.h>
#if defined(linux) && defined(__NR_statx)
-# include <linux/stat.h>
+#include <linux/stat.h>
#endif
#include "dlt_types.h"
@@ -66,7 +66,8 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
/* create socket */
if ((*sock = socket(AF_INET6, SOCK_STREAM, 0)) == -1) {
lastErrno = errno;
- dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno, strerror(lastErrno));
+ dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno,
+ strerror(lastErrno));
return -1;
}
@@ -74,7 +75,8 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
if ((*sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
lastErrno = errno;
- dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno, strerror(lastErrno));
+ dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno,
+ strerror(lastErrno));
return -1;
}
@@ -85,10 +87,11 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
/* setsockpt SO_REUSEADDR */
if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
lastErrno = errno;
- dlt_vlog(LOG_ERR,
- "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n",
- lastErrno,
- strerror(lastErrno));
+ dlt_vlog(
+ LOG_ERR,
+ "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n",
+ lastErrno,
+ strerror(lastErrno));
return -1;
}
@@ -98,10 +101,13 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
memset(&forced_addr, 0, sizeof(forced_addr));
forced_addr.sin6_family = AF_INET6;
forced_addr.sin6_port = htons(servPort);
- if (0 == strcmp(ip, "0.0.0.0"))
+
+ if (0 == strcmp(ip, "0.0.0.0")) {
forced_addr.sin6_addr = in6addr_any;
- else
+ } else {
ret_inet_pton = inet_pton(AF_INET6, ip, &forced_addr.sin6_addr);
+ }
+
#else
struct sockaddr_in forced_addr;
memset(&forced_addr, 0, sizeof(forced_addr));
@@ -113,18 +119,20 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
/* inet_pton returns 1 on success */
if (ret_inet_pton != 1) {
lastErrno = errno;
- dlt_vlog(LOG_WARNING,
- "dlt_daemon_socket_open: inet_pton() error %d: %s. Cannot convert IP address: %s\n",
- lastErrno,
- strerror(lastErrno),
- ip);
+ dlt_vlog(
+ LOG_WARNING,
+ "dlt_daemon_socket_open: inet_pton() error %d: %s. Cannot convert IP address: %s\n",
+ lastErrno,
+ strerror(lastErrno),
+ ip);
return -1;
}
if (bind(*sock, (struct sockaddr *)&forced_addr, sizeof(forced_addr)) == -1) {
lastErrno = errno; /*close() may set errno too */
close(*sock);
- dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: bind() error %d: %s\n", lastErrno, strerror(lastErrno));
+ dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: bind() error %d: %s\n", lastErrno,
+ strerror(lastErrno));
return -1;
}
@@ -137,7 +145,9 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
if (listen(*sock, 3) < 0) {
lastErrno = errno;
- dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: listen() failed with error %d: %s\n", lastErrno,
+ dlt_vlog(LOG_WARNING,
+ "dlt_daemon_socket_open: listen() failed with error %d: %s\n",
+ lastErrno,
strerror(lastErrno));
return -1;
}
@@ -152,7 +162,12 @@ int dlt_daemon_socket_close(int sock)
return 0;
}
-int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader)
+int dlt_daemon_socket_send(int sock,
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ char serialheader)
{
int ret = DLT_RETURN_OK;
@@ -162,20 +177,23 @@ int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int si
(void *)dltSerialHeader,
sizeof(dltSerialHeader));
- if (ret != DLT_RETURN_OK)
+ if (ret != DLT_RETURN_OK) {
return ret;
+ }
}
/* Send data */
if ((data1 != NULL) && (size1 > 0)) {
ret = dlt_daemon_socket_sendreliable(sock, data1, size1);
- if (ret != DLT_RETURN_OK)
+ if (ret != DLT_RETURN_OK) {
return ret;
+ }
}
- if ((data2 != NULL) && (size2 > 0))
+ if ((data2 != NULL) && (size2 > 0)) {
ret = dlt_daemon_socket_sendreliable(sock, data2, size2);
+ }
return ret;
}
@@ -195,7 +213,7 @@ int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size
while (data_sent < message_size) {
ssize_t ret = send(sock,
- (uint8_t*)data_buffer + data_sent,
+ (uint8_t *)data_buffer + data_sent,
message_size - data_sent,
0);
diff --git a/src/daemon/dlt_daemon_socket.h b/src/daemon/dlt_daemon_socket.h
index a180529..c2cced6 100644
--- a/src/daemon/dlt_daemon_socket.h
+++ b/src/daemon/dlt_daemon_socket.h
@@ -65,7 +65,12 @@ int dlt_daemon_socket_close(int sock);
int dlt_daemon_socket_get_send_qeue_max_size(int sock);
-int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader);
+int dlt_daemon_socket_send(int sock,
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ char serialheader);
/**
* @brief dlt_daemon_socket_sendreliable - sends data to socket with additional checks and resending functionality - trying to be reliable
diff --git a/src/lib/dlt_client_cfg.h b/src/lib/dlt_client_cfg.h
index aa67525..104823e 100644
--- a/src/lib/dlt_client_cfg.h
+++ b/src/lib/dlt_client_cfg.h
@@ -82,9 +82,9 @@
/* Initial baudrate */
#if !defined (__WIN32__) && !defined(_MSC_VER)
-# define DLT_CLIENT_INITIAL_BAUDRATE B115200
+#define DLT_CLIENT_INITIAL_BAUDRATE B115200
#else
-# define DLT_CLIENT_INITIAL_BAUDRATE 0
+#define DLT_CLIENT_INITIAL_BAUDRATE 0
#endif
/* Name of environment variable for specifying the daemon port */
diff --git a/src/lib/dlt_env_ll.c b/src/lib/dlt_env_ll.c
index 8770a02..3923704 100644
--- a/src/lib/dlt_env_ll.c
+++ b/src/lib/dlt_env_ll.c
@@ -59,20 +59,24 @@ int dlt_env_extract_id(char **const env, char *id)
{
int i;
- if (!env || !id)
+ if (!env || !id) {
return -1;
+ }
- if (!(*env))
+ if (!(*env)) {
return -1;
+ }
memset(id, 0, 4);
- for (i = 0; (i < 4) && (**env != ':') && (**env != 0); ++i)
+ for (i = 0; (i < 4) && (**env != ':') && (**env != 0); ++i) {
*id++ = *((*env)++);
+ }
/* the next/last character must be ':' */
- if ((0 != **env) && (':' == **env))
+ if ((0 != **env) && (':' == **env)) {
return 0;
+ }
return -1;
}
@@ -88,19 +92,22 @@ int dlt_env_helper_to_lower(char **const env, char *result, int const res_len)
int count = 0;
char ch;
- if (!env || !result)
+ if (!env || !result) {
return -1;
+ }
- if (!(*env))
+ if (!(*env)) {
return -1;
+ }
ch = *(*env);
while (ch && (count < res_len - 1) && (ch != ';')) {
- if ((ch >= 'A') && (ch <= 'Z'))
+ if ((ch >= 'A') && (ch <= 'Z')) {
result[count] = ch + 'a' - 'A';
- else
+ } else {
result[count] = ch;
+ }
ch = *(++(*env));
++count;
@@ -108,10 +115,11 @@ int dlt_env_helper_to_lower(char **const env, char *result, int const res_len)
result[count] = 0;
- if (!ch || (ch == ';')) /* full input was parsed */
+ if (!ch || (ch == ';')) { /* full input was parsed */
return 0;
- else
+ } else {
return -1;
+ }
}
@@ -119,38 +127,41 @@ int dlt_env_extract_symbolic_ll(char **const env, int8_t *ll)
{
char result[strlen("verbose") + 1];
- if (!env || !ll)
+ if (!env || !ll) {
return -1;
+ }
- if (!(*env))
+ if (!(*env)) {
return -1;
+ }
if (dlt_env_helper_to_lower(env, &result[0], sizeof(result)) == 0) {
- if (strncmp("default", result, sizeof(result)) == 0)
+ if (strncmp("default", result, sizeof(result)) == 0) {
*ll = -1;
- else if (strncmp("off", result, sizeof(result)) == 0)
+ } else if (strncmp("off", result, sizeof(result)) == 0) {
*ll = 0;
- else if (strncmp("fatal", result, sizeof(result)) == 0)
+ } else if (strncmp("fatal", result, sizeof(result)) == 0) {
*ll = 1;
- else if (strncmp("error", result, sizeof(result)) == 0)
+ } else if (strncmp("error", result, sizeof(result)) == 0) {
*ll = 2;
- else if (strncmp("warning", result, sizeof(result)) == 0)
+ } else if (strncmp("warning", result, sizeof(result)) == 0) {
*ll = 3;
- else if (strncmp("info", result, sizeof(result)) == 0)
+ } else if (strncmp("info", result, sizeof(result)) == 0) {
*ll = 4;
- else if (strncmp("debug", result, sizeof(result)) == 0)
+ } else if (strncmp("debug", result, sizeof(result)) == 0) {
*ll = 5;
- else if (strncmp("verbose", result, sizeof(result)) == 0)
+ } else if (strncmp("verbose", result, sizeof(result)) == 0) {
*ll = 6;
- else
+ } else {
return -1;
+ }
- if (**env != 0)
+ if (**env != 0) {
(*env)++;
+ }
return 0;
- }
- else {
+ } else {
return -1;
}
}
@@ -186,11 +197,13 @@ int dlt_env_extract_symbolic_ll(char **const env, int8_t *ll)
*/
int dlt_env_extract_ll(char **const env, int8_t *ll)
{
- if (!env || !ll)
+ if (!env || !ll) {
return -1;
+ }
- if (!(*env))
+ if (!(*env)) {
return -1;
+ }
/* extract number */
if (**env == '-') {
@@ -200,19 +213,19 @@ int dlt_env_extract_ll(char **const env, int8_t *ll)
*ll = -1;
(*env)++;
}
- }
- else {
+ } else {
if ((**env >= '0') && (**env < '7')) {
*ll = **env - '0';
(*env)++;
- }
- else if (dlt_env_extract_symbolic_ll(env, ll) != 0)
+ } else if (dlt_env_extract_symbolic_ll(env, ll) != 0) {
return -1;
+ }
}
/* check end, either next char is NULL or ';' */
- if ((**env == ';') || (**env == 0))
+ if ((**env == ';') || (**env == 0)) {
return 0;
+ }
return -1;
}
@@ -227,29 +240,34 @@ int dlt_env_extract_ll_item(char **const env, dlt_env_ll_item *const item)
{
int ret = -1;
- if (!env || !item)
+ if (!env || !item) {
return -1;
+ }
- if (!(*env))
+ if (!(*env)) {
return -1;
+ }
memset(item, 0, sizeof(dlt_env_ll_item));
ret = dlt_env_extract_id(env, item->appId);
- if (ret == -1)
+ if (ret == -1) {
return -1;
+ }
(*env)++;
ret = dlt_env_extract_id(env, item->ctxId);
- if (ret == -1)
+ if (ret == -1) {
return -1;
+ }
(*env)++;
ret = dlt_env_extract_ll(env, &item->ll);
- if (ret == -1)
+ if (ret == -1) {
return -1;
+ }
return 0;
}
@@ -265,8 +283,9 @@ int dlt_env_extract_ll_item(char **const env, dlt_env_ll_item *const item)
*/
int dlt_env_init_ll_set(dlt_env_ll_set *const ll_set)
{
- if (!ll_set)
+ if (!ll_set) {
return -1;
+ }
ll_set->array_size = DLT_ENV_LL_SET_INCREASE;
ll_set->item = (dlt_env_ll_item *)malloc(sizeof(dlt_env_ll_item) * ll_set->array_size);
@@ -287,8 +306,9 @@ int dlt_env_init_ll_set(dlt_env_ll_set *const ll_set)
*/
void dlt_env_free_ll_set(dlt_env_ll_set *const ll_set)
{
- if (!ll_set)
+ if (!ll_set) {
return;
+ }
if (ll_set->item != NULL) {
free(ll_set->item);
@@ -311,8 +331,9 @@ int dlt_env_increase_ll_set(dlt_env_ll_set *const ll_set)
dlt_env_ll_item *old_set;
size_t old_size;
- if (!ll_set)
+ if (!ll_set) {
return -1;
+ }
old_set = ll_set->item;
old_size = ll_set->array_size;
@@ -324,8 +345,7 @@ int dlt_env_increase_ll_set(dlt_env_ll_set *const ll_set)
/* should trigger a warning: no memory left */
ll_set->array_size -= DLT_ENV_LL_SET_INCREASE;
return -1;
- }
- else {
+ } else {
memcpy(ll_set->item, old_set, sizeof(dlt_env_ll_item) * old_size);
free(old_set);
return 0;
@@ -343,26 +363,32 @@ int dlt_env_increase_ll_set(dlt_env_ll_set *const ll_set)
*/
int dlt_env_extract_ll_set(char **const env, dlt_env_ll_set *const ll_set)
{
- if (!env || !ll_set)
+ if (!env || !ll_set) {
return -1;
+ }
- if (!(*env))
+ if (!(*env)) {
return -1;
+ }
- if (dlt_env_init_ll_set(ll_set) == -1)
+ if (dlt_env_init_ll_set(ll_set) == -1) {
return -1;
+ }
do {
if (ll_set->num_elem == ll_set->array_size) {
- if (dlt_env_increase_ll_set(ll_set) == -1)
+ if (dlt_env_increase_ll_set(ll_set) == -1) {
return -1;
+ }
}
- if (dlt_env_extract_ll_item(env, &ll_set->item[ll_set->num_elem++]) == -1)
+ if (dlt_env_extract_ll_item(env, &ll_set->item[ll_set->num_elem++]) == -1) {
return -1;
+ }
- if (**env == ';')
+ if (**env == ';') {
(*env)++;
+ }
} while (**env != 0);
return 0;
@@ -376,17 +402,21 @@ int dlt_env_extract_ll_set(char **const env, dlt_env_ll_set *const ll_set)
*/
int dlt_env_ids_match(char const *const a, char const *const b)
{
- if (a[0] != b[0])
+ if (a[0] != b[0]) {
return 0;
+ }
- if (a[1] != b[1])
+ if (a[1] != b[1]) {
return 0;
+ }
- if (a[2] != b[2])
+ if (a[2] != b[2]) {
return 0;
+ }
- if (a[3] != b[3])
+ if (a[3] != b[3]) {
return 0;
+ }
return 1;
}
@@ -403,23 +433,26 @@ int dlt_env_ids_match(char const *const a, char const *const b)
*
* In case of error, -1 is returned.
*/
-int dlt_env_ll_item_get_matching_prio(dlt_env_ll_item const *const item, char const *const apid, char const *const ctid)
+int dlt_env_ll_item_get_matching_prio(dlt_env_ll_item const *const item,
+ char const *const apid,
+ char const *const ctid)
{
- if ((!item) || (!apid) || (!ctid))
+ if ((!item) || (!apid) || (!ctid)) {
return -1;
+ }
if (item->appId[0] == 0) {
if (item->ctxId[0] == 0) {
return 1;
- }
- else if (dlt_env_ids_match(item->ctxId, ctid))
+ } else if (dlt_env_ids_match(item->ctxId, ctid)) {
return 2;
- }
- else if (dlt_env_ids_match(item->appId, apid)) {
- if (item->ctxId[0] == 0)
+ }
+ } else if (dlt_env_ids_match(item->appId, apid)) {
+ if (item->ctxId[0] == 0) {
return 3;
- else if (dlt_env_ids_match(item->ctxId, ctid))
+ } else if (dlt_env_ids_match(item->ctxId, ctid)) {
return 4;
+ }
}
return 0;
@@ -440,8 +473,9 @@ int dlt_env_adjust_ll_from_env(dlt_env_ll_set const *const ll_set,
char const *const ctid,
int const ll)
{
- if ((!ll_set) || (!apid) || (!ctid))
+ if ((!ll_set) || (!apid) || (!ctid)) {
return ll;
+ }
int res = ll;
int prio = 0; /* no match so far */
@@ -454,8 +488,9 @@ int dlt_env_adjust_ll_from_env(dlt_env_ll_set const *const ll_set,
prio = p;
res = ll_set->item[i].ll;
- if (p == 4) /* maximum reached, immediate return */
+ if (p == 4) { /* maximum reached, immediate return */
return res;
+ }
}
}
diff --git a/src/lib/dlt_filetransfer.c b/src/lib/dlt_filetransfer.c
index bd196ea..7508790 100644
--- a/src/lib/dlt_filetransfer.c
+++ b/src/lib/dlt_filetransfer.c
@@ -101,18 +101,21 @@ uint32_t getFilesize(const char *file, int *ok)
*/
void stringHash(const char *str, uint32_t *hash)
{
- if (!str || !hash)
+ if (!str || !hash) {
return;
+ }
unsigned int len = strlen(str);
unsigned int i = 0;
- if (len <= 0)
+ if (len <= 0) {
return;
+ }
- for (i = 0; i < len; i++)
+ for (i = 0; i < len; i++) {
*hash = 53 * *hash + str[i];
+ }
}
@@ -130,8 +133,7 @@ uint32_t getFileSerialNumber(const char *file, int *ok)
if (-1 == stat(file, &st)) {
*ok = 0;
ret = 0;
- }
- else {
+ } else {
*ok = 1;
ret = st.st_ino;
ret = ret << (sizeof(ret) * 8) / 2;
@@ -217,8 +219,9 @@ int checkUserBufferForFreeSpace()
dlt_user_check_buffer(&total_size, &used_size);
- if ((total_size - used_size) < (total_size / 2))
+ if ((total_size - used_size) < (total_size / 2)) {
return -1;
+ }
return 1;
}
@@ -240,27 +243,30 @@ void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filenam
int ok = 0;
uint32_t fserial = getFileSerialNumber(filename, &ok);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
DLT_STRING("dlt_user_log_file_errorMessage, error in getFileSerialNumber for: "),
DLT_STRING(filename));
+ }
uint32_t fsize = getFilesize(filename, &ok);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext,
DLT_LOG_ERROR,
DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "),
DLT_STRING(filename));
+ }
char fcreationdate[50];
getFileCreationDate2(filename, &ok, fcreationdate);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext,
DLT_LOG_ERROR,
DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "),
DLT_STRING(filename));
+ }
int package_count = dlt_user_log_file_packagesCount(fileContext, filename);
@@ -276,8 +282,7 @@ void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filenam
DLT_UINT(BUFFER_SIZE),
DLT_STRING("FLER")
);
- }
- else {
+ } else {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
DLT_STRING("FLER"),
DLT_INT(errorCode),
@@ -304,28 +309,31 @@ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename)
uint32_t fsize = getFilesize(filename, &ok);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext,
DLT_LOG_ERROR,
DLT_STRING("dlt_user_log_file_infoAbout, Error getting size of file:"),
DLT_STRING(filename));
+ }
uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext,
DLT_LOG_ERROR,
DLT_STRING("dlt_user_log_file_infoAbout, Error getting serial number of file:"),
DLT_STRING(filename));
+ }
char creationdate[50];
getFileCreationDate2(filename, &ok, creationdate);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext,
DLT_LOG_ERROR,
DLT_STRING("dlt_user_log_file_infoAbout, Error getting creation date of file:"),
DLT_STRING(filename));
+ }
DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLIF"),
@@ -333,12 +341,12 @@ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename)
DLT_STRING("filename"), DLT_STRING(filename),
DLT_STRING("file size in bytes"), DLT_UINT(fsize),
DLT_STRING("file creation date"), DLT_STRING(creationdate),
- DLT_STRING("number of packages"), DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
+ DLT_STRING("number of packages"),
+ DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
DLT_STRING("FLIF")
);
return 0;
- }
- else {
+ } else {
dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_INFO_ABOUT);
return DLT_FILETRANSFER_ERROR_INFO_ABOUT;
}
@@ -356,21 +364,28 @@ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename)
* @param timeout Timeout in ms to wait between some logs. Important that the FIFO of dlt will not be flooded with to many messages in a short period of time.
* @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
*/
-int dlt_user_log_file_complete(DltContext *fileContext, const char *filename, int deleteFlag, int timeout)
+int dlt_user_log_file_complete(DltContext *fileContext,
+ const char *filename,
+ int deleteFlag,
+ int timeout)
{
if (!isFile(filename)) {
dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_COMPLETE);
return DLT_FILETRANSFER_ERROR_FILE_COMPLETE;
}
- if (dlt_user_log_file_header(fileContext, filename) != 0)
+ if (dlt_user_log_file_header(fileContext, filename) != 0) {
return DLT_FILETRANSFER_ERROR_FILE_COMPLETE1;
+ }
- if (dlt_user_log_file_data(fileContext, filename, DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES, timeout) != 0)
+ if (dlt_user_log_file_data(fileContext, filename, DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES,
+ timeout) != 0) {
return DLT_FILETRANSFER_ERROR_FILE_COMPLETE2;
+ }
- if (dlt_user_log_file_end(fileContext, filename, deleteFlag) != 0)
+ if (dlt_user_log_file_end(fileContext, filename, deleteFlag) != 0) {
return DLT_FILETRANSFER_ERROR_FILE_COMPLETE3;
+ }
return 0;
}
@@ -405,17 +420,16 @@ int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filenam
if (filesize < BUFFER_SIZE) {
return packages;
- }
- else {
+ } else {
packages = filesize / BUFFER_SIZE;
- if (filesize % BUFFER_SIZE == 0)
+ if (filesize % BUFFER_SIZE == 0) {
return packages;
- else
+ } else {
return packages + 1;
+ }
}
- }
- else {
+ } else {
DLT_LOG(*fileContext,
DLT_LOG_ERROR,
DLT_STRING("Error in: dlt_user_log_file_packagesCount, !isFile"),
@@ -443,24 +457,31 @@ int dlt_user_log_file_header_alias(DltContext *fileContext, const char *filename
uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
- DLT_STRING("dlt_user_log_file_header_alias, Error getting serial number of file:"),
+ DLT_STRING(
+ "dlt_user_log_file_header_alias, Error getting serial number of file:"),
DLT_STRING(filename));
+ }
uint32_t fsize = getFilesize(filename, &ok);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
- DLT_STRING("dlt_user_log_file_header_alias, Error getting size of file:"), DLT_STRING(filename));
+ DLT_STRING(
+ "dlt_user_log_file_header_alias, Error getting size of file:"),
+ DLT_STRING(filename));
+ }
char fcreationdate[50];
getFileCreationDate2(filename, &ok, fcreationdate);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
- DLT_STRING("dlt_user_log_file_header_alias, Error getting creation date of file:"),
+ DLT_STRING(
+ "dlt_user_log_file_header_alias, Error getting creation date of file:"),
DLT_STRING(filename));
+ }
DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLST"),
@@ -474,8 +495,7 @@ int dlt_user_log_file_header_alias(DltContext *fileContext, const char *filename
);
return 0;
- }
- else {
+ } else {
dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_HEAD);
return DLT_FILETRANSFER_ERROR_FILE_HEAD;
}
@@ -498,24 +518,31 @@ int dlt_user_log_file_header(DltContext *fileContext, const char *filename)
uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
- DLT_STRING("dlt_user_log_file_header, Error getting serial number of file:"), DLT_STRING(filename));
+ DLT_STRING(
+ "dlt_user_log_file_header, Error getting serial number of file:"),
+ DLT_STRING(filename));
+ }
uint32_t fsize = getFilesize(filename, &ok);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext,
DLT_LOG_ERROR,
DLT_STRING("dlt_user_log_file_header, Error getting size of file:"),
DLT_STRING(filename));
+ }
char fcreationdate[50];
getFileCreationDate2(filename, &ok, fcreationdate);
- if (!ok)
+ if (!ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
- DLT_STRING("dlt_user_log_file_header, Error getting creation date of file:"), DLT_STRING(filename));
+ DLT_STRING(
+ "dlt_user_log_file_header, Error getting creation date of file:"),
+ DLT_STRING(filename));
+ }
DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLST"),
@@ -529,8 +556,7 @@ int dlt_user_log_file_header(DltContext *fileContext, const char *filename)
);
return 0;
- }
- else {
+ } else {
dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_HEAD);
return DLT_FILETRANSFER_ERROR_FILE_HEAD;
}
@@ -544,7 +570,10 @@ int dlt_user_log_file_header(DltContext *fileContext, const char *filename)
* @param timeout Timeout to wait between dlt logs. Important because the dlt FIFO should not be flooded. Default is defined by MIN_TIMEOUT. The given timeout in ms can not be smaller than MIN_TIMEOUT.
* @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
*/
-int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int packageToTransfer, int timeout)
+int dlt_user_log_file_data(DltContext *fileContext,
+ const char *filename,
+ int packageToTransfer,
+ int timeout)
{
FILE *file;
int pkgNumber;
@@ -561,7 +590,8 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa
if (((packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES) &&
(packageToTransfer >
- dlt_user_log_file_packagesCount(fileContext, filename))) || (packageToTransfer <= 0)) {
+ dlt_user_log_file_packagesCount(fileContext,
+ filename))) || (packageToTransfer <= 0)) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
DLT_STRING("Error at dlt_user_log_file_data: packageToTransfer out of scope"),
DLT_STRING("packageToTransfer:"),
@@ -592,7 +622,6 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa
fclose (file);
return -1;
-
}
readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, file);
@@ -600,10 +629,11 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa
uint32_t fserial = getFileSerialNumber(filename, &ok);
- if (1 != ok)
+ if (1 != ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
DLT_STRING("failed to get FileSerialNumber for: "),
DLT_STRING(filename));
+ }
DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLDA"),
@@ -614,9 +644,7 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa
);
doTimeout(timeout);
-
- }
- else {
+ } else {
pkgNumber = 0;
while (!feof(file)) {
@@ -629,10 +657,11 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa
uint32_t fserial = getFileSerialNumber(filename, &ok);
- if (1 != ok)
+ if (1 != ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
DLT_STRING("failed to get FileSerialNumber for: "),
DLT_STRING(filename));
+ }
DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLDA"),
@@ -650,9 +679,7 @@ int dlt_user_log_file_data(DltContext *fileContext, const char *filename, int pa
fclose(file);
return 0;
-
- }
- else {
+ } else {
dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_DATA);
return DLT_FILETRANSFER_ERROR_FILE_DATA;
}
@@ -674,10 +701,11 @@ int dlt_user_log_file_end(DltContext *fileContext, const char *filename, int del
int ok;
uint32_t fserial = getFileSerialNumber(filename, &ok);
- if (1 != ok)
+ if (1 != ok) {
DLT_LOG(*fileContext, DLT_LOG_ERROR,
DLT_STRING("failed to get FileSerialNumber for: "),
DLT_STRING(filename));
+ }
DLT_LOG(*fileContext, DLT_LOG_INFO,
DLT_STRING("FLFI"),
@@ -687,14 +715,15 @@ int dlt_user_log_file_end(DltContext *fileContext, const char *filename, int del
if (deleteFlag) {
if (doRemoveFile(filename) != 0) {
- dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_END);
+ dlt_user_log_file_errorMessage(fileContext,
+ filename,
+ DLT_FILETRANSFER_ERROR_FILE_END);
return -1;
}
}
return 0;
- }
- else {
+ } else {
dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_END);
return DLT_FILETRANSFER_ERROR_FILE_END;
}
diff --git a/src/lib/dlt_user_cfg.h b/src/lib/dlt_user_cfg.h
index d394daa..8037c28 100644
--- a/src/lib/dlt_user_cfg.h
+++ b/src/lib/dlt_user_cfg.h
@@ -139,7 +139,8 @@
#define DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP 100000000
/* Name of environment variable to disable extended header in non verbose mode */
-#define DLT_USER_ENV_DISABLE_EXTENDED_HEADER_FOR_NONVERBOSE "DLT_DISABLE_EXTENDED_HEADER_FOR_NONVERBOSE"
+#define DLT_USER_ENV_DISABLE_EXTENDED_HEADER_FOR_NONVERBOSE \
+ "DLT_DISABLE_EXTENDED_HEADER_FOR_NONVERBOSE"
typedef enum
{