summaryrefslogtreecommitdiff
path: root/src/shared/dlt_common.c
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 /src/shared/dlt_common.c
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>
Diffstat (limited to 'src/shared/dlt_common.c')
-rwxr-xr-xsrc/shared/dlt_common.c23
1 files changed, 17 insertions, 6 deletions
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 */