[1/2] net/mlx4: fix initialization of struct members

Message ID 20181113191039.12720-1-alialnu@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers
Series [1/2] net/mlx4: fix initialization of struct members |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Ali Alnubani Nov. 13, 2018, 7:11 p.m. UTC
  This patch fixes compilation errors with meson and the clang
compiler caused by some of the struct members not being
initialized.

```
../drivers/net/mlx4/mlx4_mr.c:357:37: error: missing field 'end'
initializer [-Werror,-Wmissing-field-initializers]
                struct mlx4_mr_cache entry = { 0, };
                                                  ^
../drivers/net/mlx4/mlx4_mr.c:401:36: error: missing field 'end'
initializer [-Werror,-Wmissing-field-initializers]
                        struct mlx4_mr_cache ret = { 0, };
                                                        ^
../drivers/net/mlx4/mlx4_mr.c:691:35: error: missing field 'end'
initializer [-Werror,-Wmissing-field-initializers]
                struct mlx4_mr_cache ret = { 0, };
                                                ^
```

The compilation errors reproduce with
clang version 3.4.2 (tags/RELEASE_34/dot2-final) on RHEL.

Fixes: 9797bfcce1c9 ("net/mlx4: add new memory region support")
Cc: stable@dpdk.org

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
---
 drivers/net/mlx4/mlx4_mr.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
  

Comments

Shahaf Shuler Nov. 15, 2018, 8:49 a.m. UTC | #1
Tuesday, November 13, 2018 9:11 PM, Ali Alnubani:
> Subject: [PATCH 1/2] net/mlx4: fix initialization of struct members
> 
> This patch fixes compilation errors with meson and the clang compiler caused
> by some of the struct members not being initialized.
> 
> ```
> ../drivers/net/mlx4/mlx4_mr.c:357:37: error: missing field 'end'
> initializer [-Werror,-Wmissing-field-initializers]
>                 struct mlx4_mr_cache entry = { 0, };
>                                                   ^
> ../drivers/net/mlx4/mlx4_mr.c:401:36: error: missing field 'end'
> initializer [-Werror,-Wmissing-field-initializers]
>                         struct mlx4_mr_cache ret = { 0, };
>                                                         ^
> ../drivers/net/mlx4/mlx4_mr.c:691:35: error: missing field 'end'
> initializer [-Werror,-Wmissing-field-initializers]
>                 struct mlx4_mr_cache ret = { 0, };
>                                                 ^ ```
> 
> The compilation errors reproduce with
> clang version 3.4.2 (tags/RELEASE_34/dot2-final) on RHEL.
> 
> Fixes: 9797bfcce1c9 ("net/mlx4: add new memory region support")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ali Alnubani <alialnu@mellanox.com>

Series applied to next-net-mlx, thanks.
  

Patch

diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index c2066ea4b..726788a60 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -354,8 +354,9 @@  mr_insert_dev_cache(struct rte_eth_dev *dev, struct mlx4_mr *mr)
 	DEBUG("port %u inserting MR(%p) to global cache",
 	      dev->data->port_id, (void *)mr);
 	for (n = 0; n < mr->ms_bmp_n; ) {
-		struct mlx4_mr_cache entry = { 0, };
+		struct mlx4_mr_cache entry;
 
+		memset(&entry, 0, sizeof(entry));
 		/* Find a contiguous chunk and advance the index. */
 		n = mr_find_next_chunk(mr, &entry, n);
 		if (!entry.end)
@@ -398,8 +399,9 @@  mr_lookup_dev_list(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 		if (mr->ms_n == 0)
 			continue;
 		for (n = 0; n < mr->ms_bmp_n; ) {
-			struct mlx4_mr_cache ret = { 0, };
+			struct mlx4_mr_cache ret;
 
+			memset(&ret, 0, sizeof(ret));
 			n = mr_find_next_chunk(mr, &ret, n);
 			if (addr >= ret.start && addr < ret.end) {
 				/* Found. */
@@ -688,8 +690,9 @@  mlx4_mr_create(struct rte_eth_dev *dev, struct mlx4_mr_cache *entry,
 	 */
 	for (n = 0; n < ms_n; ++n) {
 		uintptr_t start;
-		struct mlx4_mr_cache ret = { 0, };
+		struct mlx4_mr_cache ret;
 
+		memset(&ret, 0, sizeof(ret));
 		start = data_re.start + n * msl->page_sz;
 		/* Exclude memsegs already registered by other MRs. */
 		if (mr_lookup_dev(dev, &ret, start) == UINT32_MAX) {
@@ -1277,8 +1280,9 @@  mlx4_mr_dump_dev(struct rte_eth_dev *dev)
 		if (mr->ms_n == 0)
 			continue;
 		for (n = 0; n < mr->ms_bmp_n; ) {
-			struct mlx4_mr_cache ret = { 0, };
+			struct mlx4_mr_cache ret;
 
+			memset(&ret, 0, sizeof(ret));
 			n = mr_find_next_chunk(mr, &ret, n);
 			if (!ret.end)
 				break;