From dbe849384ca675fbd859daad78058f73879832dd Mon Sep 17 00:00:00 2001 From: Declan Doherty Date: Fri, 27 Nov 2015 17:44:47 +0000 Subject: [PATCH] cryptodev: fix build with gcc 4.4.7 - Fix for build error caused by flexible array member in struct rte_ccryptodev_session: error: flexible array member in otherwise empty struct - Change void** casting of sess parameter in rte_cryptodev_session_create which causes a strict-aliasing error. Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto devices") Signed-off-by: Declan Doherty --- lib/librte_cryptodev/rte_cryptodev.c | 7 +++++-- lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index edd13208e3..f09f67e9a2 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -1037,6 +1037,7 @@ rte_cryptodev_session_create(uint8_t dev_id, struct rte_crypto_xform *xform) { struct rte_cryptodev *dev; struct rte_cryptodev_session *sess; + void *_sess; if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) { CDEV_LOG_ERR("Invalid dev_id=%d", dev_id); @@ -1046,11 +1047,13 @@ rte_cryptodev_session_create(uint8_t dev_id, struct rte_crypto_xform *xform) dev = &rte_crypto_devices[dev_id]; /* Allocate a session structure from the session pool */ - if (rte_mempool_get(dev->data->session_pool, (void **)&sess)) { + if (rte_mempool_get(dev->data->session_pool, &_sess)) { CDEV_LOG_ERR("Couldn't get object from session mempool"); return NULL; } + sess = (struct rte_cryptodev_session *)_sess; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_configure, NULL); if (dev->dev_ops->session_configure(dev, xform, sess->_private) == NULL) { @@ -1058,7 +1061,7 @@ rte_cryptodev_session_create(uint8_t dev_id, struct rte_crypto_xform *xform) dev_id); /* Return session to mempool */ - rte_mempool_put(sess->mp, (void *)sess); + rte_mempool_put(sess->mp, _sess); return NULL; } diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h index d5fbe4436f..8270afaeca 100644 --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h @@ -76,7 +76,7 @@ struct rte_cryptodev_session { struct rte_mempool *mp; } __rte_aligned(8); - char _private[]; + char _private[0]; }; struct rte_cryptodev_driver; -- 2.20.1