summaryrefslogtreecommitdiff
path: root/src/daemon/dlt-daemon.c
diff options
context:
space:
mode:
authorSimon Herkenhoff <sherkenhoff@jp.adit-jv.com>2018-10-10 10:43:11 +0900
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2019-05-06 15:55:07 +0900
commit40590be05c5eb99f557dfca6f7f6623dcdbe334a (patch)
tree8542563eacb18119b76f2264cc557ab6739031b8 /src/daemon/dlt-daemon.c
parentdf6fc2a1ce9f3a1778e9c8e14c800cd2ad96e96e (diff)
downloadDLT-daemon-40590be05c5eb99f557dfca6f7f6623dcdbe334a.tar.gz
Fix compiler warnings
Fix compiler warnings about socket usage Correct the data types used for the socket declaration. We use AF_UNIX sockets so we use struct sockaddr_un, but we need to cast to struct sockaddr for the socket API. Fix compiler warnings about sign-compare Fix two occurences of signed - unsigned comparison by casting the values accordingly. Note that the cast is legal as the first parts of both conditional statements make sure the value is not negative before casting to unsigned. While at it, add strtol error checking. Fix compiler warnings about string functions Add string.h to src/daemon/dlt_daemon_unix_socket.c, because it was unaware of memcpy and strerror. While at it, change unsafe use of sprintf to proper dlt_vlog and remove the char buffer. Fix compiler warnings about unused-* Fix two unused-variable and one unused-parameter warning. While at it, change the #ifdef to not run into an empty block. Simply reverse the condition and enclose the complete else with the #ifdef. POSIX: Use memset instead of bzero "The bzero() function is deprecated (marked as LEGACY in POSIX.1-2001); use memset(3) in new programs." Use memset instead of bzero and remove any occurrence from DLT. Include of header "strings.h" that has bzero is also removed. Signed-off-by: Simon Herkenhoff <sherkenhoff@jp.adit-jv.com> Signed-off-by: ManikandanC <Manikandan.Chockalingam@in.bosch.com> Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
Diffstat (limited to 'src/daemon/dlt-daemon.c')
-rw-r--r--src/daemon/dlt-daemon.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index a8404fd..cdfddec 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -1525,7 +1525,7 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
int verbose)
{
socklen_t cli_size;
- struct sockaddr cli;
+ struct sockaddr_un cli;
int in_sock = -1;
char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
@@ -1542,7 +1542,7 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
/* event from TCP server socket, new connection */
cli_size = sizeof(cli);
- if ((in_sock = accept(receiver->fd, &cli, &cli_size)) < 0) {
+ if ((in_sock = accept(receiver->fd, (struct sockaddr *)&cli, &cli_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() for socket %d failed: %s\n", receiver->fd, strerror(errno));
return -1;
}
@@ -1794,7 +1794,7 @@ int dlt_daemon_process_control_connect(
/* event from UNIX server socket, new connection */
ctrl_size = sizeof(ctrl);
- if ((in_sock = accept(receiver->fd, &ctrl, &ctrl_size)) < 0) {
+ if ((in_sock = accept(receiver->fd, (struct sockaddr *)&ctrl, &ctrl_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() on UNIX control socket %d failed: %s\n", receiver->fd, strerror(errno));
return -1;
}
@@ -1847,7 +1847,7 @@ int dlt_daemon_process_app_connect(
/* event from UNIX server socket, new connection */
app_size = sizeof(app);
- if ((in_sock = accept(receiver->fd, &app, &app_size)) < 0) {
+ if ((in_sock = accept(receiver->fd, (struct sockaddr *)&app, &app_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() on UNIX socket %d failed: %s\n", receiver->fd, strerror(errno));
return -1;
}
@@ -3130,7 +3130,6 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
DltTimers timer_id)
{
int local_fd = -1;
- struct itimerspec l_timer_spec;
char *timer_name = NULL;
if (timer_id >= DLT_TIMER_UNKNOWN) {
@@ -3145,8 +3144,15 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
return -1;
}
- if (period_sec > 0) {
+ if (period_sec <= 0 || starts_in <= 0 ) {
+ /* timer not activated via the service file */
+ dlt_vlog(LOG_INFO, "<%s> not set: period=0\n", timer_name);
+ local_fd = -1;
+ }
#ifdef linux
+ else
+ {
+ struct itimerspec l_timer_spec;
local_fd = timerfd_create(CLOCK_MONOTONIC, 0);
if (local_fd < 0) {
@@ -3172,15 +3178,8 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
dlt_log(LOG_WARNING, str);
local_fd = -1;
}
-
-#endif
- }
- else {
- /* timer not activated via the service file */
- snprintf(str, sizeof(str), "<%s> not set: period=0\n", timer_name);
- dlt_log(LOG_INFO, str);
- local_fd = -1;
}
+#endif
/* If fully initialized we are done.
* Event handling registration is done later on with other connections.