From 55d20075bd0f66b24292cb229be355a2369a9a61 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 10 Mar 2016 15:34:02 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9066 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/common/abstractions/nasa_osal/src/osapi.c | 11 ++++------- test/nasa_osal/configuration.xml | 13 +++++++------ test/nasa_osal/source/test/test_sequence_003.c | 13 +++++++------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/os/common/abstractions/nasa_osal/src/osapi.c b/os/common/abstractions/nasa_osal/src/osapi.c index c4b55ed14..bd6448d2a 100644 --- a/os/common/abstractions/nasa_osal/src/osapi.c +++ b/os/common/abstractions/nasa_osal/src/osapi.c @@ -483,19 +483,16 @@ int32 OS_TimerCreate(uint32 *timer_id, const char *timer_name, return OS_ERR_NO_FREE_IDS; } - chSysLock(); - - strncpy(otp->name, timer_name, OS_MAX_API_NAME); + strncpy(otp->name, timer_name, OS_MAX_API_NAME - 1); chVTObjectInit(&otp->vt); otp->start_time = 0; otp->interval_time = 0; otp->callback_ptr = callback_ptr; otp->is_free = 0; /* Note, last.*/ + *timer_id = (uint32)otp; *clock_accuracy = (uint32)(1000000 / CH_CFG_ST_FREQUENCY); - chSysUnlock(); - return OS_SUCCESS; } @@ -727,7 +724,7 @@ int32 OS_QueueCreate(uint32 *queue_id, const char *queue_name, } /* Initializing object static parts.*/ - strncpy(oqp->name, queue_name, OS_MAX_API_NAME); + strncpy(oqp->name, queue_name, OS_MAX_API_NAME - 1); chMBObjectInit(&oqp->mb, oqp->q_buffer, (size_t)queue_depth); chSemObjectInit(&oqp->free_msgs, (cnt_t)queue_depth); chPoolObjectInit(&oqp->messages, msgsize, NULL); @@ -983,7 +980,7 @@ int32 OS_QueueGetInfo (uint32 queue_id, OS_queue_prop_t *queue_prop) { } strncpy(queue_prop->name, oqp->name, OS_MAX_API_NAME - 1); - queue_prop->creator = (uint32)0; + queue_prop->creator = (uint32)0; /* Leaving the critical zone.*/ chSysRestoreStatusX(sts); diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml index eef897b28..ac37ce262 100644 --- a/test/nasa_osal/configuration.xml +++ b/test/nasa_osal/configuration.xml @@ -1157,16 +1157,17 @@ test_assert(err == OS_ERR_INVALID_ID, "wrong timer id not detected");]]> +err = OS_TimerDelete(tmid1); +test_assert(err == OS_SUCCESS, "timer deletion failed");]]> diff --git a/test/nasa_osal/source/test/test_sequence_003.c b/test/nasa_osal/source/test/test_sequence_003.c index 2d2fc0a69..1dd7a44b5 100644 --- a/test/nasa_osal/source/test/test_sequence_003.c +++ b/test/nasa_osal/source/test/test_sequence_003.c @@ -173,16 +173,17 @@ static void test_003_001_execute(void) { test_set_step(7); { int32 err; - uint32 qid1, qid2; + uint32 tmid1, tmid2; + uint32 accuracy; - err = OS_QueueCreate(&qid1, "my queue", 4, 128, 0); - test_assert(err == OS_SUCCESS, "queue creation failed"); + err = OS_TimerCreate(&tmid1, "my timer", &accuracy, tmr_callback); + test_assert(err == OS_SUCCESS, "timer creation failed"); - err = OS_QueueCreate(&qid2, "my queue", 4, 128, 0); + err = OS_TimerCreate(&tmid2, "my timer", &accuracy, tmr_callback); test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected"); - err = OS_QueueDelete(qid1); - test_assert(err == OS_SUCCESS, "queue deletion failed"); + err = OS_TimerDelete(tmid1); + test_assert(err == OS_SUCCESS, "timer deletion failed"); } }