From: Adrien Mazarguil Date: Fri, 2 Feb 2018 16:46:12 +0000 (+0100) Subject: net/mlx: add debug checks to glue structure X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2a3b00973d7937e36851c13078d76c02f18e5814;p=dpdk.git 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 --- 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);