net/mlx: add debug checks to glue structure
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Fri, 2 Feb 2018 16:46:12 +0000 (17:46 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 6 Feb 2018 13:35:07 +0000 (14:35 +0100)
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 <adrien.mazarguil@6wind.com>
drivers/net/mlx4/mlx4.c
drivers/net/mlx5/mlx5.c

index 8928b31..8611e0c 100644 (file)
@@ -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);
index b66303d..e437818 100644 (file)
@@ -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);