summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Brandner <simon.brandner@partner.bmw.de>2013-04-25 13:25:35 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2013-07-19 16:54:47 +0200
commitf524304ff10ce50259cc28ced0915ba47e294920 (patch)
treee06d68656f882a44ca56084725679599c3ea833a
parent205f941eabcac08cf66745e6527067077e57aaa7 (diff)
downloadDLT-daemon-f524304ff10ce50259cc28ced0915ba47e294920.tar.gz
Invalid Sock is set to -1 instead 0 (stdin). Consequent error handling in fseek failure cases
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
-rw-r--r--src/daemon/dlt-daemon.c6
-rwxr-xr-xsrc/shared/dlt_common.c23
2 files changed, 20 insertions, 9 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 6871ca8..64a8acd 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -1232,9 +1232,9 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon
if (dlt_receiver_receive_socket(&(daemon_local->receiverSock))<=0)
{
- close(daemon_local->receiverSock.fd);
- daemon_local->receiverSock.fd = 0;
+ close(daemon_local->receiverSock.fd);
FD_CLR(daemon_local->receiverSock.fd, &(daemon_local->master));
+ daemon_local->receiverSock.fd = -1;
if (daemon_local->client_connections)
{
@@ -1261,7 +1261,7 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon
while (dlt_message_read(&(daemon_local->msg),(uint8_t*)daemon_local->receiverSock.buf,daemon_local->receiverSock.bytesRcvd,daemon_local->flags.nflag,daemon_local->flags.vflag)==0)
{
/* Check for control message */
- if ( 0 != daemon_local->receiverSock.fd && DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)) )
+ if ( 0 < daemon_local->receiverSock.fd && DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)) )
{
dlt_daemon_control_process_control(daemon_local->receiverSock.fd, daemon, &(daemon_local->msg), daemon_local->flags.vflag);
}
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index 19a1698..b7a865e 100755
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -1484,7 +1484,7 @@ int dlt_file_read_header_raw(DltFile *file,int resync,int verbose)
else
{
/* go back to last file position */
- if (fseek(file->handle,file->file_position,SEEK_SET) < 0)
+ if (0 != fseek(file->handle,file->file_position,SEEK_SET))
return -1;
}
}
@@ -1664,9 +1664,20 @@ int dlt_file_open(DltFile *file,const char *filename,int verbose)
return -1;
}
- fseek(file->handle,0,SEEK_END);
+ if (0 != fseek(file->handle,0,SEEK_END))
+ {
+ sprintf(str,"dlt_file_open: Seek failed to 0,SEEK_END");
+ dlt_log(LOG_ERR, str);
+ return -1;
+ }
file->file_length = ftell(file->handle);
- fseek(file->handle,0,SEEK_SET);
+
+ if (0 != fseek(file->handle,0,SEEK_SET))
+ {
+ sprintf(str,"dlt_file_open: Seek failed to 0,SEEK_SET");
+ dlt_log(LOG_ERR, str);
+ return -1;
+ }
if (verbose)
{
@@ -1712,7 +1723,7 @@ int 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 ( fseek(file->handle,file->file_position,SEEK_SET) < 0 )
+ if (0 != fseek(file->handle,file->file_position,SEEK_SET))
{
sprintf(str,"Seek failed to file_position %ld \n",file->file_position);
dlt_log(LOG_ERR, str);
@@ -1740,7 +1751,7 @@ int dlt_file_read(DltFile *file,int verbose)
if (dlt_file_read_header_extended(file, verbose)<0)
{
/* go back to last position in file */
- if ( 0 != fseek(file->handle,file->file_position,SEEK_SET))
+ if (0 != fseek(file->handle,file->file_position,SEEK_SET))
{
sprintf(str,"Seek to last file pos failed!\n");
dlt_log(LOG_ERR, str);
@@ -1845,7 +1856,7 @@ int dlt_file_read_raw(DltFile *file,int resync, int verbose)
}
/* set to end of last successful read message, because of conflicting calls to dlt_file_read and dlt_file_message */
- if (fseek(file->handle,file->file_position,SEEK_SET) < 0)
+ if (0 != fseek(file->handle,file->file_position,SEEK_SET))
return -1;
/* get file position at start of DLT message */