From 2a3b00973d7937e36851c13078d76c02f18e5814 Mon Sep 17 00:00:00 2001 From: Adrien Mazarguil Date: Fri, 2 Feb 2018 17:46:12 +0100 Subject: [PATCH] net/mlx: add debug checks to glue structure This code should catch mistakes early if a glue structure member is added without a corresponding implementation in the library. Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 9 +++++++++ drivers/net/mlx5/mlx5.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 8928b31b3f..8611e0cd9d 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -770,6 +770,15 @@ rte_mlx4_pmd_init(void) if (mlx4_glue_init()) return; assert(mlx4_glue); +#endif +#ifndef NDEBUG + /* Glue structure must not contain any NULL pointers. */ + { + unsigned int i; + + for (i = 0; i != sizeof(*mlx4_glue) / sizeof(void *); ++i) + assert(((const void *const *)mlx4_glue)[i]); + } #endif mlx4_glue->fork_init(); rte_pci_register(&mlx4_driver); diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index b66303d29d..e437818b3e 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1112,6 +1112,15 @@ rte_mlx5_pmd_init(void) if (mlx5_glue_init()) return; assert(mlx5_glue); +#endif +#ifndef NDEBUG + /* Glue structure must not contain any NULL pointers. */ + { + unsigned int i; + + for (i = 0; i != sizeof(*mlx5_glue) / sizeof(void *); ++i) + assert(((const void *const *)mlx5_glue)[i]); + } #endif mlx5_glue->fork_init(); rte_pci_register(&mlx5_driver); -- 2.20.1