Skip to content
Commit 16509081 authored by Anisse Astier's avatar Anisse Astier Committed by Will Deacon
Browse files

virtio: fix warning on strncpy



GCC 8.2 gives this warning:

virtio/net.c: In function ‘virtio_net__tap_init’:
virtio/net.c:336:47: error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
   strncpy(ifr.ifr_name, ndev->tap_name, sizeof(ndev->tap_name));
                                               ^
virtio/net.c:348:47: error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
   strncpy(ifr.ifr_name, ndev->tap_name, sizeof(ndev->tap_name));
                                               ^

Fix it by using sizeof of destination instead, even if they're the same
size in this case.

Reviewed-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarAnisse Astier <aastier@freebox.fr>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 96eda741
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment