summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/console/dlt-convert.c5
-rwxr-xr-xsrc/console/dlt-receive.c5
-rw-r--r--src/daemon/dlt-daemon.c44
-rw-r--r--src/daemon/dlt_daemon_common.c43
-rwxr-xr-xsrc/lib/dlt_client.c12
-rwxr-xr-xsrc/shared/dlt_common.c9
-rwxr-xr-xsrc/tests/dlt-test-client.c14
-rw-r--r--src/tests/dlt-test-stress-client.c4
-rwxr-xr-xsrc/tests/dlt-test-stress.c4
9 files changed, 125 insertions, 15 deletions
diff --git a/src/console/dlt-convert.c b/src/console/dlt-convert.c
index 76e92b9..b5cdd94 100755
--- a/src/console/dlt-convert.c
+++ b/src/console/dlt-convert.c
@@ -351,6 +351,11 @@ int main(int argc, char* argv[])
iov[1].iov_len = file.msg.datasize;
bytes_written = writev(ohandle, iov, 2);
+ if (0 > bytes_written){
+ printf("in main: writev(ohandle, iov, 2); returned an error!" );
+ dlt_file_free(&file,vflag);
+ return -1;
+ }
}
/* check for new messages if follow flag set */
diff --git a/src/console/dlt-receive.c b/src/console/dlt-receive.c
index 7e887fe..4b0e53e 100755
--- a/src/console/dlt-receive.c
+++ b/src/console/dlt-receive.c
@@ -402,6 +402,11 @@ int dlt_receive_message_callback(DltMessage *message, void *data)
iov[1].iov_len = message->datasize;
bytes_written = writev(dltdata->ohandle, iov, 2);
+
+ if (0 > bytes_written){
+ printf("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!" );
+ return -1;
+ }
}
}
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 24d327e..7e9b6ba 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -995,13 +995,25 @@ void dlt_daemon_daemonize(int verbose)
/* Open standard descriptors stdin, stdout, stderr */
i=open("/dev/null",O_RDWR); /* open stdin */
ret=dup(i); /* stdout */
+ if (0 > ret){
+ dlt_log(LOG_CRIT, "can't open standard descriptor stdout\n");
+ exit(-1); /* can not open */
+ }
ret=dup(i); /* stderr */
+ if (0 > ret){
+ dlt_log(LOG_CRIT, "can't open standard descriptor stderr");
+ exit(-1); /* can not open */
+ }
/* Set umask */
umask(DLT_DAEMON_UMASK);
/* Change to known directory */
ret=chdir(DLT_USER_DIR);
+ if (0 > ret){
+ dlt_log(LOG_CRIT, "Can't change to known directory");
+ exit(-1); /* Can't change to known directory */
+ }
/* Ensure single copy of daemon;
run only one instance at a time */
@@ -1020,6 +1032,9 @@ void dlt_daemon_daemonize(int verbose)
sprintf(str,"%d\n",getpid());
bytes_written=write(lfp,str,strlen(str)); /* record pid to lockfile */
+ if (0 > bytes_written){
+ dlt_log(LOG_CRIT, "write pid to lockfile failed:");
+ }
/* Catch signals */
signal(SIGCHLD,SIG_IGN); /* ignore child */
@@ -1917,10 +1932,22 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemo
if (daemon_local->flags.lflag)
{
ret=write(j,dltSerialHeader,sizeof(dltSerialHeader));
+ if (0 > ret)
+ {
+ dlt_log(LOG_ERR,"write(j,daemon_local->msg.headerbuffer failed\n");
+ }
}
ret=write(j,daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader));
+ if (0 > ret)
+ {
+ dlt_log(LOG_ERR,"write(j,dltSerialHeader failed\n");
+ }
ret=write(j,daemon_local->msg.databuffer,daemon_local->msg.datasize);
+ if (0 > ret)
+ {
+ dlt_log(LOG_ERR,"write(j,daemon_local->msg.databuffer failed\n");
+ }
DLT_DAEMON_SEM_FREE();
@@ -2314,10 +2341,22 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem
if (daemon_local->flags.lflag)
{
ret=write(j,dltSerialHeader,sizeof(dltSerialHeader));
+ if (0 > ret)
+ {
+ dlt_log(LOG_ERR, "dlt_daemon_send_ringbuffer_to_client: write(j,dltSerialHeader,sizeof(dltSerialHeader)) failed!\n");
+ DLT_DAEMON_SEM_FREE();
+ return -1;
+ }
}
ret=write(j,data,length);
-
+ if (0 > ret)
+ {
+ dlt_log(LOG_ERR, "dlt_daemon_send_ringbuffer_to_client: write(j,data,length) failed!\n");
+ DLT_DAEMON_SEM_FREE();
+ return -1;
+ }
DLT_DAEMON_SEM_FREE();
+
}
} /* if */
} /* for */
@@ -2569,6 +2608,9 @@ void dlt_daemon_wait_period (DltDaemonPeriodicData *info, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
ret = read (info->timer_fd, &missed, sizeof (missed));
+ if (0 > ret){
+ dlt_log(LOG_ERR,"dlt_daemon_wait_period: Read failed");
+ }
if (missed > 0)
{
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index 3e24475..7bbce7b 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -485,6 +485,12 @@ int dlt_daemon_applications_load(DltDaemon *daemon,const char *filename, int ver
/* Get line */
ret=fgets(buf,sizeof(buf),fd);
+ if (NULL == ret)
+ {
+ snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "dlt_daemon_applications_load fgets(buf,sizeof(buf),fd) returned NULL");
+ dlt_log(LOG_ERR, str);
+ return -1;//seems to be appropriate, but not sure. !feof is already a precondition, so another problem should the reason!
+ }
if (strcmp(buf,"")!=0)
{
@@ -824,6 +830,13 @@ int dlt_daemon_contexts_load(DltDaemon *daemon,const char *filename, int verbose
/* Get line */
ret=fgets(buf,sizeof(buf),fd);
+ if (NULL == ret)
+ {
+ sprintf(str,"dlt_daemon_contexts_load: fgets(buf,sizeof(buf),fd);");
+ dlt_log(LOG_ERR, str);
+ fclose(fd);
+ return -1;//as we are not eof, there seems to be another problem.
+ }
if (strcmp(buf,"")!=0)
{
@@ -2122,7 +2135,7 @@ void dlt_daemon_control_send_ecu_version(int sock, DltDaemon *daemon, const char
{
DltMessage msg;
uint32_t len;
- DltServiceGetSoftwareVersionResponse *resp;
+ DltServiceGetSoftwareVersionResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
@@ -2254,11 +2267,29 @@ void dlt_daemon_control_send_control_message( int sock, DltDaemon *daemon, DltMe
if (daemon->sendserialheader)
{
ret=write(sock,dltSerialHeader,sizeof(dltSerialHeader));
+ if (0 > ret)
+ {
+ dlt_log(LOG_CRIT,"dlt_daemon_control_send_control_message: write dltSerialHeader failed\n");
+ DLT_DAEMON_SEM_FREE();
+ return;
+ }
}
/* Send data */
ret=write(sock, msg->headerbuffer+sizeof(DltStorageHeader),msg->headersize-sizeof(DltStorageHeader));
+ if (0 > ret)
+ {
+ dlt_log(LOG_CRIT,"dlt_daemon_control_send_control_message: write msg->headerbuffer failed\n");
+ DLT_DAEMON_SEM_FREE();
+ return;
+ }
ret=write(sock, msg->databuffer,msg->datasize);
+ if (0 > ret)
+ {
+ dlt_log(LOG_CRIT,"dlt_daemon_control_send_control_message: write msg->databuffer failed\n");
+ DLT_DAEMON_SEM_FREE();
+ return;
+ }
DLT_DAEMON_SEM_FREE();
}
@@ -2485,7 +2516,15 @@ void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, int verbose)
/* Send data */
ret=write(sock, msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader));
if(msg.datasize > 0)
- ret=write(sock, msg.databuffer,msg.datasize);
+ {
+ ret=write(sock, msg.databuffer,msg.datasize);
+ if (0 > ret){
+ dlt_log(LOG_CRIT,"dlt_daemon_control_message_time: Failed to write databuffer\n");
+ dlt_message_free(&msg,0);
+ DLT_DAEMON_SEM_FREE();
+ return;
+ }
+ }
DLT_DAEMON_SEM_FREE();
}
diff --git a/src/lib/dlt_client.c b/src/lib/dlt_client.c
index 141c6ef..7f86b3d 100755
--- a/src/lib/dlt_client.c
+++ b/src/lib/dlt_client.c
@@ -318,8 +318,8 @@ int dlt_client_main_loop(DltClient *client, void *data, int verbose)
int dlt_client_send_inject_msg(DltClient *client, char *apid, char *ctid, uint32_t serviceID, uint8_t *buffer, uint32_t size)
{
DltMessage msg;
- int ret;
- int offset=0;
+ int ret;
+ int offset=0;
int32_t len;
@@ -424,7 +424,15 @@ int dlt_client_send_inject_msg(DltClient *client, char *apid, char *ctid, uint32
{
/* via FileDescriptor */
ret=write(client->sock, msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader));
+ if (0 > ret){
+ dlt_message_free(&msg,0);
+ return -1;
+ }
ret=write(client->sock, msg.databuffer,msg.datasize);
+ if (0 > ret){
+ dlt_message_free(&msg,0);
+ return -1;
+ }
}
else
{
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index 1da96f0..68d06c6 100755
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -3177,7 +3177,8 @@ int dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uint8_t **ptr,
float64_t value64f=0,value64f_tmp=0;
int64_t value64f_tmp_int64i=0,value64f_tmp_int64i_swaped=0;
- uint32_t quantisation=0, quantisation_tmp=0;
+ //uint32_t quantisation=0,
+ uint32_t quantisation_tmp=0;
if (type_info & DLT_TYPE_INFO_STRG)
{
@@ -3256,12 +3257,14 @@ int dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uint8_t **ptr,
}
if (type_info & DLT_TYPE_INFO_FIXP)
{
- quantisation=0;
+ //quantisation=0;
quantisation_tmp=0;
+ //compiler warning: variable ‘quantisation_tmp’ set but not used [-Wunused-but-set-variable], but: DLT_MSG_READ_VALUE wants a parameter, "0" does not work
DLT_MSG_READ_VALUE(quantisation_tmp,*ptr,*datalength,uint32_t);
+
if((*datalength)<0)
return -1;
- quantisation=DLT_ENDIAN_GET_32(msg->standardheader->htyp, quantisation_tmp);
+ //quantisation=DLT_ENDIAN_GET_32(msg->standardheader->htyp, quantisation_tmp);
switch ( type_info & DLT_TYPE_INFO_TYLE)
{
diff --git a/src/tests/dlt-test-client.c b/src/tests/dlt-test-client.c
index 572b04e..3fb98cd 100755
--- a/src/tests/dlt-test-client.c
+++ b/src/tests/dlt-test-client.c
@@ -1510,9 +1510,9 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
if(type_info & DLT_TYPE_INFO_UINT)
{
- uint16_t seq;
+ //uint16_t seq;
DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ //seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
dltdata->test_counter_macro[8]++;
/* Data */
@@ -2664,10 +2664,10 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
if(type_info & DLT_TYPE_INFO_UINT)
{
- uint16_t seq;
+ //uint16_t seq;
DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
- seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
- dltdata->test_counter_function[8]++;
+ //seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
+ dltdata->test_counter_function[8]++;
/* Data */
DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
@@ -2769,6 +2769,10 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
iov[1].iov_len = message->datasize;
bytes_written = writev(dltdata->ohandle, iov, 2);
+ if (0 > bytes_written){
+ printf("dlt_testclient_message_callback, error in: writev(dltdata->ohandle, iov, 2)\n");
+ return -1;
+ }
}
}
diff --git a/src/tests/dlt-test-stress-client.c b/src/tests/dlt-test-stress-client.c
index 3ff14ae..b9e54ad 100644
--- a/src/tests/dlt-test-stress-client.c
+++ b/src/tests/dlt-test-stress-client.c
@@ -556,6 +556,10 @@ int dlt_testclient_message_callback(DltMessage *message, void *data)
iov[1].iov_len = message->datasize;
bytes_written = writev(dltdata->ohandle, iov, 2);
+ if (0 > bytes_written){
+ printf("dlt_testclient_message_callback, error when: writev(dltdata->ohandle, iov, 2) \n");
+ return -1;
+ }
}
}
diff --git a/src/tests/dlt-test-stress.c b/src/tests/dlt-test-stress.c
index 4b5967f..2f50e7e 100755
--- a/src/tests/dlt-test-stress.c
+++ b/src/tests/dlt-test-stress.c
@@ -91,7 +91,7 @@ typedef struct
void stress1(void);
void stress2(void);
-void thread_function(void *ptr);
+void thread_function(void);
void stress3(void);
@@ -311,7 +311,7 @@ void stress2(void)
printf("Finished stress test2 \n\n");
}
-void thread_function(void *ptr)
+void thread_function(void)
{
//thread_data_t *data;
DLT_DECLARE_CONTEXT(context_thread1);