@@ -86,8 +86,12 @@ queue_entry_t *get_qentry(uint32_t queue_id)
static int queue_init(queue_entry_t *queue, const char *name,
const odp_queue_param_t *param)
{
- strncpy(queue->s.name, name, ODP_QUEUE_NAME_LEN - 1);
-
+ if (name == NULL) {
+ queue->s.name[0] = 0;
+ } else {
+ strncpy(queue->s.name, name, ODP_QUEUE_NAME_LEN - 1);
+ queue->s.name[ODP_QUEUE_NAME_LEN - 1] = 0;
+ }
memcpy(&queue->s.param, param, sizeof(odp_queue_param_t));
if (queue->s.param.sched.lock_count >
SCHEDULE_ORDERED_LOCKS_PER_QUEUE)
@@ -137,7 +137,7 @@ void queue_test_mode(void)
void queue_test_param(void)
{
- odp_queue_t queue;
+ odp_queue_t queue, null_queue;
odp_event_t enev[MAX_BUFFER_QUEUE];
odp_event_t deev[MAX_BUFFER_QUEUE];
odp_buffer_t buf;
@@ -173,6 +173,11 @@ void queue_test_param(void)
CU_ASSERT(&queue_context == odp_queue_context(queue));
CU_ASSERT(odp_queue_destroy(queue) == 0);
+ /* Create queue with no name */
+ odp_queue_param_init(&qparams);
+ null_queue = odp_queue_create(NULL, &qparams);
+ CU_ASSERT(ODP_QUEUE_INVALID != null_queue);
+
/* Plain type queue */
odp_queue_param_init(&qparams);
qparams.type = ODP_QUEUE_TYPE_PLAIN;
@@ -185,6 +190,9 @@ void queue_test_param(void)
CU_ASSERT(ODP_QUEUE_TYPE_PLAIN == odp_queue_type(queue));
CU_ASSERT(&queue_context == odp_queue_context(queue));
+ /* Destroy queue with no name */
+ CU_ASSERT(odp_queue_destroy(null_queue) == 0);
+
msg_pool = odp_pool_lookup("msg_pool");
buf = odp_buffer_alloc(msg_pool);
CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID);
Previously trying to create a queue with no name (=NULL) caused a segfault. Fix this and test it in the validation suite. Signed-off-by: Matias Elo <matias.elo@nokia.com> --- platform/linux-generic/odp_queue.c | 8 ++++++-- test/common_plat/validation/api/queue/queue.c | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) -- 2.7.4