diff options
author | Lutz Helwing <lutz_helwing@mentor.com> | 2015-07-15 14:14:19 +0200 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2015-10-07 10:40:33 +0200 |
commit | 1236195e9b93aeb6bfa625956fa027f96003756d (patch) | |
tree | 07b08c892a486f9f97c1674e0d253099eb3388f3 /src/console | |
parent | 033a69218af3490f6be409f66f350c1568655f61 (diff) | |
download | DLT-daemon-1236195e9b93aeb6bfa625956fa027f96003756d.tar.gz |
DLT daemon improvement - dlt_init()-check
DLT daemon improvement - parameter value range check
Adapt unit tests to check for enum return values
Changed C version to gnu99 and C++ version to gnu++0c
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/console')
-rw-r--r-- | src/console/dlt-control.c | 47 | ||||
-rw-r--r-- | src/console/dlt-convert.c | 6 | ||||
-rw-r--r-- | src/console/dlt-receive.c | 7 |
3 files changed, 26 insertions, 34 deletions
diff --git a/src/console/dlt-control.c b/src/console/dlt-control.c index 92f841d..8db6467 100644 --- a/src/console/dlt-control.c +++ b/src/console/dlt-control.c @@ -396,7 +396,7 @@ int main(int argc, char* argv[]) } /* Connect to TCP socket or open serial device */ - if (dlt_client_connect(&dltclient, dltdata.vflag)!=-1) + if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR) { /* send injection message */ if(dltdata.mvalue && dltdata.avalue && dltdata.cvalue) @@ -408,9 +408,8 @@ int main(int argc, char* argv[]) printf("ServiceId: %d\n",dltdata.svalue); printf("Message: %s\n",dltdata.mvalue); /* send control message in ascii */ - if (0 != dlt_client_send_inject_msg(&dltclient,dltdata.avalue,dltdata.cvalue,dltdata.svalue,(uint8_t*)dltdata.mvalue,strlen(dltdata.mvalue))) { - fprintf (stderr, "ERROR: Could not send inject message\n"); - } + if (dlt_client_send_inject_msg(&dltclient,dltdata.avalue,dltdata.cvalue,dltdata.svalue,(uint8_t*)dltdata.mvalue,strlen(dltdata.mvalue)) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could not send inject message\n"); } else if(dltdata.xvalue && dltdata.avalue && dltdata.cvalue) { @@ -425,9 +424,8 @@ int main(int argc, char* argv[]) hexAsciiToBinary(dltdata.xvalue,buffer,&size); printf("Size: %d\n",size); /* send control message in hex */ - if (0 != dlt_client_send_inject_msg(&dltclient,dltdata.avalue,dltdata.cvalue,dltdata.svalue,buffer,size)) { - fprintf (stderr, "ERROR: Could not send inject message\n"); - } + if (dlt_client_send_inject_msg(&dltclient,dltdata.avalue,dltdata.cvalue,dltdata.svalue,buffer,size) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could not send inject message\n"); } else if(dltdata.lvalue!=-1 && dltdata.avalue && dltdata.cvalue) { @@ -437,9 +435,8 @@ int main(int argc, char* argv[]) printf("ConId: %s\n",dltdata.cvalue); printf("Loglevel: %d\n",dltdata.lvalue); /* send control message*/ - if (0 != dlt_client_send_log_level(&dltclient,dltdata.avalue,dltdata.cvalue,dltdata.lvalue)) { - fprintf (stderr, "ERROR: Could not send log level\n"); - } + if (dlt_client_send_log_level(&dltclient,dltdata.avalue,dltdata.cvalue,dltdata.lvalue) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could not send log level\n"); } else if(dltdata.rvalue!=-1 && dltdata.avalue && dltdata.cvalue) { @@ -449,9 +446,8 @@ int main(int argc, char* argv[]) printf("ConId: %s\n",dltdata.cvalue); printf("TraceStatus: %d\n",dltdata.rvalue); /* send control message in*/ - if (0 != dlt_client_send_trace_status(&dltclient,dltdata.avalue,dltdata.cvalue,dltdata.rvalue)) { - fprintf (stderr, "ERROR: Could not send trace status\n"); - } + if (dlt_client_send_trace_status(&dltclient,dltdata.avalue,dltdata.cvalue,dltdata.rvalue) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could not send trace status\n"); } else if(dltdata.dvalue!=-1) { @@ -459,9 +455,8 @@ int main(int argc, char* argv[]) printf("Set default log level:\n"); printf("Loglevel: %d\n",dltdata.dvalue); /* send control message in*/ - if (0 != dlt_client_send_default_log_level(&dltclient,dltdata.dvalue)) { - fprintf (stderr, "ERROR: Could not send default log level\n"); - } + if (dlt_client_send_default_log_level(&dltclient,dltdata.dvalue) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could not send default log level\n"); } else if(dltdata.rvalue!=-1) { @@ -469,9 +464,8 @@ int main(int argc, char* argv[]) printf("Set default trace status:\n"); printf("TraceStatus: %d\n",dltdata.rvalue); /* send control message in*/ - if (0 != dlt_client_send_default_trace_status(&dltclient,dltdata.rvalue)) { - fprintf (stderr, "ERROR: Could not send default trace status\n"); - } + if (dlt_client_send_default_trace_status(&dltclient,dltdata.rvalue) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could not send default trace status\n"); } else if(dltdata.ivalue!=-1) { @@ -479,27 +473,24 @@ int main(int argc, char* argv[]) printf("Set timing pakets:\n"); printf("Timing packets: %d\n",dltdata.ivalue); /* send control message in*/ - if (0 != dlt_client_send_timing_pakets(&dltclient,dltdata.ivalue)) { - fprintf (stderr, "ERROR: Could not send timing packets\n"); - } + if (dlt_client_send_timing_pakets(&dltclient,dltdata.ivalue) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could not send timing packets\n"); } else if(dltdata.oflag!=-1) { /* default trace status */ printf("Store config\n"); /* send control message in*/ - if (0 != dlt_client_send_store_config(&dltclient)) { - fprintf (stderr, "ERROR: Could not send store config\n"); - } + if (dlt_client_send_store_config(&dltclient) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could not send store config\n"); } else if(dltdata.gflag!=-1) { /* reset to factory default */ printf("Reset to factory default\n"); /* send control message in*/ - if (0 != dlt_client_send_reset_to_factory_default(&dltclient)) { - fprintf (stderr, "ERROR: Could send reset to factory default\n"); - } + if (dlt_client_send_reset_to_factory_default(&dltclient) != DLT_RETURN_OK) + fprintf (stderr, "ERROR: Could send reset to factory default\n"); } /* Dlt Client Main Loop */ diff --git a/src/console/dlt-convert.c b/src/console/dlt-convert.c index 55143f6..8c5c901 100644 --- a/src/console/dlt-convert.c +++ b/src/console/dlt-convert.c @@ -249,7 +249,7 @@ int main(int argc, char* argv[]) /* first parse filter file if filter parameter is used */ if (fvalue) { - if (dlt_filter_load(&filter,fvalue,vflag)<0) + if (dlt_filter_load(&filter,fvalue,vflag) < DLT_RETURN_OK) { dlt_file_free(&file,vflag); return -1; @@ -273,9 +273,9 @@ int main(int argc, char* argv[]) for (index = optind; index < argc; index++) { /* load, analyse data file and create index list */ - if (dlt_file_open(&file,argv[index],vflag)>=0) + if (dlt_file_open(&file,argv[index],vflag) >= DLT_RETURN_OK) { - while (dlt_file_read(&file,vflag)>=0) + while (dlt_file_read(&file,vflag) >= DLT_RETURN_OK) { } } diff --git a/src/console/dlt-receive.c b/src/console/dlt-receive.c index 99268e5..ef3ba20 100644 --- a/src/console/dlt-receive.c +++ b/src/console/dlt-receive.c @@ -479,7 +479,7 @@ int main(int argc, char* argv[]) if (dltdata.fvalue) { - if (dlt_filter_load(&(dltdata.filter),dltdata.fvalue,dltdata.vflag)<0) + if (dlt_filter_load(&(dltdata.filter),dltdata.fvalue,dltdata.vflag) < DLT_RETURN_OK) { dlt_file_free(&(dltdata.file),dltdata.vflag); return -1; @@ -521,7 +521,7 @@ int main(int argc, char* argv[]) } /* Connect to TCP socket or open serial device */ - if (dlt_client_connect(&dltclient, dltdata.vflag)!=-1) + if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR) { /* Dlt Client Main Loop */ @@ -571,7 +571,8 @@ int dlt_receive_message_callback(DltMessage *message, void *data) dlt_set_storageheader(message->storageheader,dltdata->ecuid); } - if ((dltdata->fvalue==0) || (dltdata->fvalue && dlt_message_filter_check(message,&(dltdata->filter),dltdata->vflag)==1)) + if ((dltdata->fvalue==0) || + (dltdata->fvalue && dlt_message_filter_check(message,&(dltdata->filter),dltdata->vflag) == DLT_RETURN_TRUE)) { /* if no filter set or filter is matching display message */ if (dltdata->xflag) |