diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/daemon/dlt_daemon_connection.c | 6 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_connection.h | 12 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_event_handler.c | 24 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_event_handler.h | 7 |
4 files changed, 43 insertions, 6 deletions
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index 755e76a..51f975d 100644 --- a/src/daemon/dlt_daemon_connection.c +++ b/src/daemon/dlt_daemon_connection.c @@ -61,7 +61,7 @@ * @return The amount of bytes send on success, -1 otherwise. * errno is appropriately set. */ -static int dlt_connection_send(DltConnection *conn, +STATIC int dlt_connection_send(DltConnection *conn, void *msg, size_t msg_size) { @@ -158,7 +158,7 @@ DltConnection *dlt_connection_get_next(DltConnection *current, int type_mask) return current; } -static void dlt_connection_destroy_receiver(DltConnection *con) +STATIC void dlt_connection_destroy_receiver(DltConnection *con) { if (!con) return; @@ -189,7 +189,7 @@ static void dlt_connection_destroy_receiver(DltConnection *con) * * @return DltReceiver structure or NULL if none corresponds to the type. */ -static DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local, +STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local, DltConnectionType type, int fd) { diff --git a/src/daemon/dlt_daemon_connection.h b/src/daemon/dlt_daemon_connection.h index aa21a11..00759c6 100644 --- a/src/daemon/dlt_daemon_connection.h +++ b/src/daemon/dlt_daemon_connection.h @@ -48,4 +48,16 @@ void dlt_connection_destroy(DltConnection *); void *dlt_connection_get_callback(DltConnection *); +#ifdef DLT_UNIT_TESTS +int dlt_connection_send(DltConnection *conn, + void *msg, + size_t msg_size); + +void dlt_connection_destroy_receiver(DltConnection *con); + +DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local, + DltConnectionType type, + int fd); +#endif + #endif /* DLT_DAEMON_CONNECTION_H */ diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c index 80817a4..9ee3bc1 100644 --- a/src/daemon/dlt_daemon_event_handler.c +++ b/src/daemon/dlt_daemon_event_handler.c @@ -61,6 +61,10 @@ */ int dlt_daemon_prepare_event_handling(DltEventHandler *ev) { + if (ev == NULL) + { + return DLT_RETURN_ERROR; + } ev->epfd = epoll_create(DLT_EPOLL_MAX_EVENTS); if (ev->epfd < 0) @@ -88,6 +92,10 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent, DltDaemon *daemon, DltDaemonLocal *daemon_local) { + if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL)) + { + return DLT_RETURN_ERROR; + } int nfds = 0; int i = 0; char str[DLT_DAEMON_TEXTBUFSIZE]; @@ -187,6 +195,7 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent, DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev, int fd) { + DltConnection *temp = ev->connections; while ((temp != NULL) && (temp->receiver->fd != fd)) @@ -207,9 +216,13 @@ DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev, * * @return 0 on success, -1 if the connection is not found. */ -static int dlt_daemon_remove_connection(DltEventHandler *ev, +STATIC int dlt_daemon_remove_connection(DltEventHandler *ev, DltConnection *to_remove) { + if (ev == NULL || to_remove == NULL) + { + return DLT_RETURN_ERROR; + } DltConnection **curr = &ev->connections; /* Find the address where to_remove value is registered */ @@ -262,16 +275,16 @@ void dlt_event_handler_cleanup_connections(DltEventHandler *ev) * @param ev The event handler structure where the connection list is. * @param connection The connection to be added. */ -static void dlt_daemon_add_connection(DltEventHandler *ev, +STATIC void dlt_daemon_add_connection(DltEventHandler *ev, DltConnection *connection) { + DltConnection **temp = &ev->connections; while (*temp != NULL) { temp = &(*temp)->next; } - *temp = connection; } @@ -429,6 +442,11 @@ int dlt_event_handler_unregister_connection(DltEventHandler *evhdl, DltDaemonLocal *daemon_local, int fd) { + if (evhdl == NULL || daemon_local == NULL) + { + return DLT_RETURN_ERROR; + } + /* Look for the pointer in the client list. * There shall be only one event handler with the same fd. */ diff --git a/src/daemon/dlt_daemon_event_handler.h b/src/daemon/dlt_daemon_event_handler.h index 532cd1f..ea88da9 100644 --- a/src/daemon/dlt_daemon_event_handler.h +++ b/src/daemon/dlt_daemon_event_handler.h @@ -56,4 +56,11 @@ int dlt_event_handler_unregister_connection(DltEventHandler *, int dlt_connection_check_activate(DltEventHandler *, DltConnection *, int); +#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 /* DLT_DAEMON_EVENT_HANDLER_H */ |