Skip to content

Commit 18ddaeb

Browse files
GustavoARSilvarleon
authored andcommitted
RDMA/mlx4: Copy union directly
Copy union directly instead of using memcpy(). Note that in this case, a direct assignment is more readable and consistent with the subsequent assignments. This addresses the following -Wstringop-overflow warning seen in s390 with defconfig: drivers/infiniband/hw/mlx4/main.c:296:33: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=] 296 | memcpy(&port_gid_table->gids[free].gid, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 297 | &attr->gid, sizeof(attr->gid)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This helps with the ongoing efforts to globally enable -Wstringop-overflow. Link: KSPP#308 Signed-off-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/ZNvimeRAPkJ24zRG@work Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 295c95a commit 18ddaeb

File tree

1 file changed

+1
-2
lines changed
  • drivers/infiniband/hw/mlx4

1 file changed

+1
-2
lines changed

drivers/infiniband/hw/mlx4/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,7 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context)
293293
ret = -ENOMEM;
294294
} else {
295295
*context = port_gid_table->gids[free].ctx;
296-
memcpy(&port_gid_table->gids[free].gid,
297-
&attr->gid, sizeof(attr->gid));
296+
port_gid_table->gids[free].gid = attr->gid;
298297
port_gid_table->gids[free].gid_type = attr->gid_type;
299298
port_gid_table->gids[free].vlan_id = vlan_id;
300299
port_gid_table->gids[free].ctx->real_index = free;

0 commit comments

Comments
 (0)