diff mbox

[PATCHv2,2/2] platform: implement odp_queue_sched_prio and odp_queue_sched_group

Message ID 1418650605-8410-3-git-send-email-ciprian.barbu@linaro.org
State New
Headers show

Commit Message

Ciprian Barbu Dec. 15, 2014, 1:36 p.m. UTC
Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org>
---
 platform/linux-generic/odp_queue.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Ola Liljedahl Dec. 15, 2014, 2:01 p.m. UTC | #1
On 15 December 2014 at 14:36, Ciprian Barbu <ciprian.barbu@linaro.org> wrote:
> Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org>
> ---
>  platform/linux-generic/odp_queue.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
> index c278094..e91f51b 100644
> --- a/platform/linux-generic/odp_queue.c
> +++ b/platform/linux-generic/odp_queue.c
> @@ -145,6 +145,30 @@ odp_schedule_sync_t odp_queue_sched_type(odp_queue_t handle)
>         return queue->s.param.sched.sync;
>  }
>
> +odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t handle)
> +{
> +       queue_entry_t *queue;
> +
> +       if (handle == ODP_QUEUE_INVALID)
> +               ODP_ABORT("Ivalid queue handle\n");
You don't actually have to check whether the user is passing
ODP_QUEUE_INVALID, just define that any invalid queue handle implies
undefined behavior (possibly a crash). There are many other invalid
queue handles, not just ODP_QUEUE_INVALID.

There is also a spelling error here.

> +
> +       queue = queue_to_qentry(handle);
queue_to_qentry() and the functions it calls (e.g. get_qentry) don't
perform any error checks at all. Queue handle should be in the range
of 1..ODP_CONFIG_QUEUES, this would take care of ODP_QUEUE_INVALID as
well. Shouldn't there be some flag in queue_entry_s which can be
checked if the qentry is actually in use?

> +
> +       return queue->s.param.sched.prio;
> +}
> +
> +odp_schedule_group_t odp_queue_sched_group(odp_queue_t handle)
> +{
> +       queue_entry_t *queue;
> +
> +       if (handle == ODP_QUEUE_INVALID)
> +               ODP_ABORT("Ivalid queue handle\n");
> +
> +       queue = queue_to_qentry(handle);
> +
> +       return queue->s.param.sched.group;
> +}
> +
>  odp_queue_t odp_queue_create(const char *name, odp_queue_type_t type,
>                              odp_queue_param_t *param)
>  {
> --
> 1.8.3.2
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index c278094..e91f51b 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -145,6 +145,30 @@  odp_schedule_sync_t odp_queue_sched_type(odp_queue_t handle)
 	return queue->s.param.sched.sync;
 }
 
+odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t handle)
+{
+	queue_entry_t *queue;
+
+	if (handle == ODP_QUEUE_INVALID)
+		ODP_ABORT("Ivalid queue handle\n");
+
+	queue = queue_to_qentry(handle);
+
+	return queue->s.param.sched.prio;
+}
+
+odp_schedule_group_t odp_queue_sched_group(odp_queue_t handle)
+{
+	queue_entry_t *queue;
+
+	if (handle == ODP_QUEUE_INVALID)
+		ODP_ABORT("Ivalid queue handle\n");
+
+	queue = queue_to_qentry(handle);
+
+	return queue->s.param.sched.group;
+}
+
 odp_queue_t odp_queue_create(const char *name, odp_queue_type_t type,
 			     odp_queue_param_t *param)
 {