diff options
author | Simon Brandner <simon.brandner@partner.bmw.de> | 2013-01-28 12:14:06 +0100 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2013-07-19 16:54:38 +0200 |
commit | e2943ff4cf2d7d2da4000e2ca35663a7c83675d7 (patch) | |
tree | 1a710a70a5190dacdb26c02da6cb570271f5d506 /src/system | |
parent | 733a1111254882aec6ebc9c90bb690aaee3f2773 (diff) | |
download | DLT-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/system')
-rw-r--r-- | src/system/dlt-system-logfile.c | 18 | ||||
-rw-r--r-- | src/system/dlt-system-process-handling.c | 10 | ||||
-rw-r--r-- | src/system/dlt-system-processes.c | 16 |
3 files changed, 26 insertions, 18 deletions
diff --git a/src/system/dlt-system-logfile.c b/src/system/dlt-system-logfile.c index 50964f2..1354b83 100644 --- a/src/system/dlt-system-logfile.c +++ b/src/system/dlt-system-logfile.c @@ -56,7 +56,7 @@ DLT_IMPORT_CONTEXT(dltsystem); extern DltSystemThreads threads; DltContext logfileContext[DLT_SYSTEM_LOG_FILE_MAX]; -void send_file(LogFileOptions fileopt, int n) +void send_file(LogFileOptions const *fileopt, int n) { DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-logfile, sending file.")); @@ -66,7 +66,7 @@ void send_file(LogFileOptions fileopt, int n) int bytes; int seq = 1; - pFile = fopen(fileopt.Filename[n],"r"); + pFile = fopen((*fileopt).Filename[n],"r"); if(pFile != NULL) { @@ -91,19 +91,19 @@ void send_file(LogFileOptions fileopt, int n) { DLT_LOG(dltsystem, DLT_LOG_ERROR, DLT_STRING("dlt-system-logfile, failed to open file."), - DLT_STRING(fileopt.Filename[n])); + DLT_STRING((*fileopt).Filename[n])); } } -void register_contexts(LogFileOptions fileopts) +void register_contexts(LogFileOptions const *fileopts) { DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-logfile, registering file contexts.")); int i; - for(i = 0;i < fileopts.Count;i++) + for(i = 0;i < (*fileopts).Count;i++) { - DLT_REGISTER_CONTEXT(logfileContext[i], fileopts.ContextId[i], - fileopts.Filename[i]); + DLT_REGISTER_CONTEXT(logfileContext[i], (*fileopts).ContextId[i], + (*fileopts).Filename[i]); } } @@ -113,7 +113,7 @@ void logfile_thread(void *v_conf) DLT_STRING("dlt-system-logfile, in thread.")); DltSystemConfiguration *conf = (DltSystemConfiguration *) v_conf; - register_contexts(conf->LogFile); + register_contexts(&(conf->LogFile)); int logfile_delays[DLT_SYSTEM_LOG_FILE_MAX]; int i; @@ -130,7 +130,7 @@ void logfile_thread(void *v_conf) if(logfile_delays[i] <= 0) { - send_file(conf->LogFile, i); + send_file(&(conf->LogFile), i); logfile_delays[i] = conf->LogFile.TimeDelay[i]; if(conf->LogFile.Mode[i] == SEND_MODE_ONCE) conf->LogFile.Mode[i] = SEND_MODE_OFF; diff --git a/src/system/dlt-system-process-handling.c b/src/system/dlt-system-process-handling.c index 3ad7908..49c20e7 100644 --- a/src/system/dlt-system-process-handling.c +++ b/src/system/dlt-system-process-handling.c @@ -81,9 +81,16 @@ int daemonize() close(i); int fd = open("/dev/null",O_RDWR); + if(fd < 0) + { + return -1; + } - if(fd < 0 || dup(fd) < 0 || dup(fd) < 0) + if(dup(fd) < 0 || dup(fd) < 0) + { + close(fd); return -1; + } /** * Ignore signals related to child processes and @@ -93,6 +100,7 @@ int daemonize() signal(SIGTSTP, SIG_IGN); signal(SIGTTOU, SIG_IGN); signal(SIGTTIN, SIG_IGN); + close(fd); return 0; } diff --git a/src/system/dlt-system-processes.c b/src/system/dlt-system-processes.c index ee37bfc..495c784 100644 --- a/src/system/dlt-system-processes.c +++ b/src/system/dlt-system-processes.c @@ -63,7 +63,7 @@ extern DltSystemThreads threads; DLT_IMPORT_CONTEXT(dltsystem) DLT_DECLARE_CONTEXT(procContext) -void send_process(LogProcessOptions popts, int n) +void send_process(LogProcessOptions const *popts, int n) { DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-processes, send process info.")); @@ -90,11 +90,11 @@ void send_process(LogProcessOptions popts, int n) bytes = fread(buffer, 1, sizeof(buffer)-1, pFile); fclose(pFile); } - if((strcmp(popts.Name[n], "*")==0) || - (strcmp(buffer, popts.Name[n])==0)) + if((strcmp((*popts).Name[n], "*")==0) || + (strcmp(buffer, (*popts).Name[n])==0)) { found = 1; - sprintf(filename, "/proc/%s/%s", dp->d_name,popts.Filename[n]); + sprintf(filename, "/proc/%s/%s", dp->d_name,(*popts).Filename[n]); pFile = fopen(filename, "r"); if(pFile != NULL) { @@ -104,10 +104,10 @@ void send_process(LogProcessOptions popts, int n) if(bytes>0) { buffer[bytes] = 0; - DLT_LOG(procContext, DLT_LOG_INFO, DLT_INT(atoi(dp->d_name)), DLT_STRING(popts.Filename[n]), DLT_STRING(buffer)); + DLT_LOG(procContext, DLT_LOG_INFO, DLT_INT(atoi(dp->d_name)), DLT_STRING((*popts).Filename[n]), DLT_STRING(buffer)); } } - if(strcmp(popts.Name[n], "*") !=0) + if(strcmp((*popts).Name[n], "*") !=0) break; } } @@ -121,7 +121,7 @@ void send_process(LogProcessOptions popts, int n) } if(!found) { - DLT_LOG(procContext, DLT_LOG_INFO, DLT_STRING("Process"), DLT_STRING(popts.Name[n]),DLT_STRING("not running!")); + DLT_LOG(procContext, DLT_LOG_INFO, DLT_STRING("Process"), DLT_STRING((*popts).Name[n]),DLT_STRING("not running!")); } } @@ -148,7 +148,7 @@ void logprocess_thread(void *v_conf) if(process_delays[i] <= 0) { - send_process(conf->LogProcesses, i); + send_process(&(conf->LogProcesses), i); process_delays[i] = conf->LogProcesses.TimeDelay[i]; if(conf->LogProcesses.Mode[i] == SEND_MODE_ONCE) conf->LogProcesses.Mode[i] = SEND_MODE_OFF; |