Skip to content

Commit

Permalink
net/mlx: add debug checks to glue structure
Browse files Browse the repository at this point in the history
Partial-bug: #1783471
This code should catch mistakes early if a glue structure member is added
without a corresponding implementation in the library.

Change-Id: I99973073e29900b51ea2cf4553c05c9d028c8aff
Signed-off-by: matan <matan@mellanox.com>
  • Loading branch information
Matan Azrad committed Jul 31, 2018
1 parent e1c9254 commit 2df7d9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/net/mlx4/mlx4.c
Expand Up @@ -777,6 +777,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);
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/mlx5/mlx5.c
Expand Up @@ -1230,6 +1230,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);
Expand Down

0 comments on commit 2df7d9f

Please sign in to comment.