summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorSimon Brandner <simon.brandner@partner.bmw.de>2013-01-28 12:14:06 +0100
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2013-07-19 16:54:38 +0200
commite2943ff4cf2d7d2da4000e2ca35663a7c83675d7 (patch)
tree1a710a70a5190dacdb26c02da6cb570271f5d506 /src/shared
parent733a1111254882aec6ebc9c90bb690aaee3f2773 (diff)
downloadDLT-daemon-e2943ff4cf2d7d2da4000e2ca35663a7c83675d7.tar.gz
Semaphores and Pointer passing insteasd by value and otehr coverity issue fixes
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/shared')
-rwxr-xr-xsrc/shared/dlt_common.c15
-rw-r--r--src/shared/dlt_offline_trace.c23
2 files changed, 26 insertions, 12 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index 7e9d852..fbc1934 100755
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -1484,7 +1484,8 @@ int dlt_file_read_header_raw(DltFile *file,int resync,int verbose)
else
{
/* go back to last file position */
- fseek(file->handle,file->file_position,SEEK_SET);
+ if (fseek(file->handle,file->file_position,SEEK_SET) < 0)
+ return -1;
}
}
@@ -1711,7 +1712,12 @@ 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 */
- fseek(file->handle,file->file_position,SEEK_SET);
+ if ( fseek(file->handle,file->file_position,SEEK_SET) < 0 )
+ {
+ sprintf(str,"Seek failed to file_position %ld \n",file->file_position);
+ dlt_log(LOG_ERR, str);
+ return -1;
+ }
/* get file position at start of DLT message */
if (verbose)
@@ -1823,8 +1829,9 @@ int dlt_file_read_raw(DltFile *file,int resync, int verbose)
file->index = ptr;
}
- /* set to end of last succesful read message, because of conflicting calls to dlt_file_read and dlt_file_message */
- fseek(file->handle,file->file_position,SEEK_SET);
+ /* 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)
+ return -1;
/* get file position at start of DLT message */
if (verbose)
diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c
index 72b31ad..80c328a 100644
--- a/src/shared/dlt_offline_trace.c
+++ b/src/shared/dlt_offline_trace.c
@@ -101,8 +101,10 @@ unsigned long dlt_offline_trace_get_total_size(DltOfflineTrace *trace) {
while ((dp=readdir(dir)) != NULL) {
if(strstr(dp->d_name,".dlt")) {
sprintf(filename,"%s/%s",trace->directory,dp->d_name);
- stat(filename,&status);
- size += status.st_size;
+ if ( 0 == stat(filename,&status) )
+ size += status.st_size;
+ else
+ printf("Offline trace file %s cannot be stat-ed",filename);
}
}
closedir(dir);
@@ -127,12 +129,17 @@ int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace) {
while ((dp=readdir(dir)) != NULL) {
if(strstr(dp->d_name,".dlt")) {
sprintf(filename,"%s/%s",trace->directory,dp->d_name);
- stat(filename,&status);
- if(time_oldest == 0 || status.st_mtime < time_oldest) {
- time_oldest = status.st_mtime;
- size_oldest = status.st_size;
- strcpy(filename_oldest,filename);
- }
+ if (0 == stat(filename,&status))
+ {
+ if(time_oldest == 0 || status.st_mtime < time_oldest) {
+ time_oldest = status.st_mtime;
+ size_oldest = status.st_size;
+ strcpy(filename_oldest,filename);
+ }
+ }
+ else
+ printf("Old offline trace file %s cannot be stat-ed",filename);
+
}
}
closedir(dir);