Skip to content
  • Anisse Astier's avatar
    virtio: fix warning on strncpy · 16509081
    Anisse Astier authored
    
    
    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: default 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>
    16509081