From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 399E1A0032 for ; Wed, 11 May 2022 16:04:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DF194282F; Wed, 11 May 2022 16:04:46 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 1B363406B4 for ; Wed, 11 May 2022 16:04:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652277883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Fbk6uqx3k1KPbHl42yuMbS9WA5K5ufxCOAxEsVhET08=; b=gPYkkjmZA1Gya4E0eQTejV2wz3k+yJzFRvxuj+hn1rWIhN6xcFEFdQhMn8tYveqbx42Ttr c4pJ1EwzrB1ooapapmEej4IeQcFJ05KH6z5ILPwvr4mSv4JnZgU+zPPZHbd8o4uf1r/bE3 ZfJq2NENbVMe7i5yb64iuLAQdJuE2vI= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-3emQ0QpzOlydPKCNFvvIKw-1; Wed, 11 May 2022 10:04:40 -0400 X-MC-Unique: 3emQ0QpzOlydPKCNFvvIKw-1 Received: by mail-lj1-f200.google.com with SMTP id m11-20020a2ea88b000000b0024db6246908so766197ljq.22 for ; Wed, 11 May 2022 07:04:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Fbk6uqx3k1KPbHl42yuMbS9WA5K5ufxCOAxEsVhET08=; b=PhZBypIuJ8VqWZoiSAo+pcHYVZws0qSj/sAYu2GTQ3y4Pt/uGsN+uZCJRJZQBz+7IN /X9XbUdqjj5ZxeHvMWHakel9EZq836iigbNV8xJqSbmP8Hv3yefMJS4r1XsSfmJSWhxY uSP/+m2h8D4W11KvxvmvhwsaGtpNMOqF4G1nWMU6OcVOrZBiXuWTNVTyMy2FIadieJEd YnHpdVgUde7qUjT0+WOwHa9fXEgNaAiXS49LrwDHk62BePJkIa9z2Tl9ndASL9mbNDd8 oe21Qi0AjhskCBb19CymvcV6k0CYGKAihcdoN7Bbsrdm2OD5F40siNMO7VcuywBQxQT2 zcFg== X-Gm-Message-State: AOAM533xhd/1LZ7Qr0GHmUAbc7855VSX8M5k2OB5WhN3YAdrfZUxE6YB f4KTuw16A5OML9EHYTo8e2wBUihAOXI7tDe6ULiYubmi/nqiZegfY+vUDFc8260wfRnxp1GNZoc rZP6ioRqUbP/q1VGl/KsFS+E= X-Received: by 2002:a05:6512:3f8c:b0:45d:cb2a:8779 with SMTP id x12-20020a0565123f8c00b0045dcb2a8779mr21074237lfa.499.1652277878439; Wed, 11 May 2022 07:04:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8ZMguDIsMEJji0YQW05vBWLvQOcjfvDukQn7D/K5vymGv2LuVfWP5ksgpZ2qvwypwYupBb748mnKvPm4xnyE= X-Received: by 2002:a05:6512:3f8c:b0:45d:cb2a:8779 with SMTP id x12-20020a0565123f8c00b0045dcb2a8779mr21074214lfa.499.1652277878168; Wed, 11 May 2022 07:04:38 -0700 (PDT) MIME-Version: 1.0 References: <20220511135815.1564053-1-alialnu@nvidia.com> In-Reply-To: <20220511135815.1564053-1-alialnu@nvidia.com> From: David Marchand Date: Wed, 11 May 2022 16:04:26 +0200 Message-ID: Subject: Re: [PATCH] net/mlx5: fix build with clang 14 To: Ali Alnubani Cc: dev , michaelba@mellanox.com, dpdk stable Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Wed, May 11, 2022 at 3:59 PM Ali Alnubani wrote: > > Use fgets instead of fscanf to resolve the following warning > reported by clang 14.0.0 in Fedora 37 (Rawhide): > > drivers/net/mlx5/linux/mlx5_ethdev_os.c:1137:52: error: > 'fscanf' may overflow; destination buffer in argument 3 has size 16, > but the corresponding specifier may require size 17 > [-Werror,-Wfortify-source] > ret = fscanf(file, "%" RTE_STR(IF_NAMESIZE) "s", port_name); > > Fixes: 63d1db710fbc ("net/mlx5: fix unlimited parsing of switch info") > Cc: michaelba@mellanox.com > Cc: stable@dpdk.org > > Signed-off-by: Ali Alnubani > --- > drivers/net/mlx5/linux/mlx5_ethdev_os.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c > index 8fe73f1adb..3d28597e7b 100644 > --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c > +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c > @@ -1118,7 +1118,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) > bool port_switch_id_set = false; > bool device_dir = false; > char c; > - int ret; > + char *ret; > > if (!if_indextoname(ifindex, ifname)) { > rte_errno = errno; > @@ -1134,9 +1134,9 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info) > > file = fopen(phys_port_name, "rb"); > if (file != NULL) { > - ret = fscanf(file, "%" RTE_STR(IF_NAMESIZE) "s", port_name); > + ret = fgets(port_name, IF_NAMESIZE, file); > fclose(file); > - if (ret == 1) > + if (ret != NULL) > mlx5_translate_port_name(port_name, &data); You can directly check fgets return value and remove (misleading) variable ret from the global scope of this function. > } > file = fopen(phys_switch_id, "rb"); -- David Marchand