From: Ali Alnubani Date: Thu, 21 Mar 2019 09:07:26 +0000 (+0000) Subject: net/mlx5: add missing return value check X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e3bcaf3a0f375998a2f2f487e06ff71705a858c0;p=dpdk.git net/mlx5: add missing return value check This patch fixes the build failure with message: drivers/net/mlx5/mlx5_ethdev.c: In function ‘mlx5_sysfs_switch_info’: drivers/net/mlx5/mlx5_ethdev.c:1381:3: error: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Werror=unused-result] fscanf(file, "%s", port_name); ^ Which reproduces on Ubuntu 16.04 LTS with gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609. Fixes: b2f3a3810125 ("net/mlx5: support new representor naming format") Signed-off-by: Ali Alnubani Acked-by: Viacheslav Ovsiienko Acked-by: Dekel Peled --- diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 84d761c8e9..2e8a2969fe 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1365,6 +1365,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) bool port_name_set = false; bool port_switch_id_set = false; char c; + int ret; if (!if_indextoname(ifindex, ifname)) { rte_errno = errno; @@ -1378,9 +1379,11 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) file = fopen(phys_port_name, "rb"); if (file != NULL) { - fscanf(file, "%s", port_name); + ret = fscanf(file, "%s", port_name); fclose(file); - port_name_set = mlx5_translate_port_name(port_name, &data); + if (ret == 1) + port_name_set = mlx5_translate_port_name(port_name, + &data); } file = fopen(phys_switch_id, "rb"); if (file == NULL) {