[ovs-dev] [PATCH] netdev-vport: Fix compilation warning

David Marchand david.marchand at redhat.com
Wed Nov 17 12:17:31 UTC 2021


On Wed, Nov 17, 2021 at 1:12 PM Roi Dayan via dev
<ovs-dev at openvswitch.org> wrote:
>
> port is declared as uint16 so use %hu specifier instead of %d.
>
> lib/netdev-vport.c:460:44: error: '%s' directive output may be truncated writing up to 4 bytes into a region of size between 1 and 10 [-Werror=format-truncation=]
>       snprintf(namebuf, bufsize, "dst_port_%d%s",
>                                            ^~

Out of curiosity, is it due to new checks from a recent compiler?


> Fixes: 189de33f02b2 ("netdev-vport: reject concomitant incompatible tunnels")
> Signed-off-by: Roi Dayan <roid at nvidia.com>
> Reviewed-by: Eli Britstein <elibr at nvidia.com>
> ---
>  lib/netdev-vport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
> index 499c0291c933..1c7f55757e9a 100644
> --- a/lib/netdev-vport.c
> +++ b/lib/netdev-vport.c
> @@ -457,7 +457,7 @@ static char *
>  vxlan_get_port_ext_gbp_str(uint16_t port, bool gbp,
>                             char namebuf[], size_t bufsize)
>  {
> -    snprintf(namebuf, bufsize, "dst_port_%d%s",
> +    snprintf(namebuf, bufsize, "dst_port_%hu%s",
>               port, gbp ? "_gbp" : "");

Format for uint16_t is PRIu16.

>
>      return namebuf;


-- 
David Marchand



More information about the dev mailing list