Skip to content

Commit 72fcca0

Browse files
clamattiakartben
authored andcommitted
net: virtual: Fix compiler warnings related to interface name
Fix compiler warning by adjusting the number of chars copied to the destination. Compiler does not like if the destination size of the `strncpy`-operation is the same as the number of characters written. Even though it is not a bug in this case. Only copying size-1 characters fixes the warning and exhibits the same behavior. Signed-off-by: Cla Mattia Galliard <[email protected]>
1 parent c9e1ff3 commit 72fcca0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/net/l2/virtual/virtual.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ void net_virtual_set_name(struct net_if *iface, const char *name)
388388

389389
ctx = net_if_l2_data(iface);
390390

391-
strncpy(ctx->name, name, CONFIG_NET_L2_VIRTUAL_MAX_NAME_LEN);
392-
ctx->name[CONFIG_NET_L2_VIRTUAL_MAX_NAME_LEN - 1] = '\0';
391+
strncpy(ctx->name, name, ARRAY_SIZE(ctx->name) - 1);
392+
ctx->name[ARRAY_SIZE(ctx->name) - 1] = '\0';
393393
}
394394

395395
enum net_l2_flags net_virtual_set_flags(struct net_if *iface,

0 commit comments

Comments
 (0)