From 73180fc762f015935950f697822710af3f5bd23d Mon Sep 17 00:00:00 2001 From: ManikandanC Date: Fri, 6 Oct 2017 11:37:31 +0530 Subject: Use poll in the dlt-daemon for POSIX compliance The poll system call is now used in the daemon to enable DLT use in POSIX compliant systems. Also added introduced new unregister_app macro to avoid missing of logs in startup buffer. Signed-off-by: Frederic Berat Signed-off-by: ManikandanC Signed-off-by: Saya Sugiura Signed-off-by: S. Hameed --- src/console/dlt-receive.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/console/dlt-receive.c') diff --git a/src/console/dlt-receive.c b/src/console/dlt-receive.c index 200add1..e22d15e 100644 --- a/src/console/dlt-receive.c +++ b/src/console/dlt-receive.c @@ -77,7 +77,11 @@ #include #include #include -#include /* for PATH_MAX */ +#ifdef __linux__ +#include +#else +#include +#endif #include #include "dlt_client.h" @@ -211,7 +215,7 @@ int dlt_receive_open_output_file(DltReceiveData * dltdata) { /* if (file_already_exists) */ glob_t outer; - if (glob(dltdata->ovalue, GLOB_TILDE_CHECK | GLOB_NOSORT, NULL, &outer) == 0) + if (glob(dltdata->ovalue, GLOB_TILDE | GLOB_NOSORT, NULL, &outer) == 0) { if (dltdata->vflag) { @@ -234,7 +238,7 @@ int dlt_receive_open_output_file(DltReceiveData * dltdata) * foo.1000.dlt * foo.11.dlt */ - if (glob(pattern, GLOB_TILDE_CHECK | GLOB_NOSORT, NULL, &inner) == 0) + if (glob(pattern, GLOB_TILDE | GLOB_NOSORT, NULL, &inner) == 0) { /* search for the highest number used */ size_t i; @@ -376,7 +380,16 @@ int main(int argc, char* argv[]) to_copy = to_copy - 4; } - dltdata.ovaluebase = strndup(dltdata.ovalue, to_copy); + dltdata.ovaluebase = (char *)calloc(1, to_copy + 1); + + if (dltdata.ovaluebase == NULL) + { + fprintf (stderr, "Memory allocation failed.\n"); + return -1; + } + + dltdata.ovaluebase[to_copy] = '\0'; + memcpy(dltdata.ovaluebase, dltdata.ovalue, to_copy); break; } case 'e': -- cgit v1.2.1