[22/25] net/nfp: replace snprintf with strlcpy

Message ID 20230601150106.18375-23-stephen@networkplumber.org (mailing list archive)
State Rejected
Delegated to: Thomas Monjalon
Headers
Series replace snprintf with strlcpy |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger June 1, 2023, 3:01 p.m. UTC
  Suggested by devtools/cocci/strlcpy-with-header.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/nfp/flower/nfp_flower_representor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Niklas Söderlund June 5, 2023, 11:10 a.m. UTC | #1
Hi Stephen,

Thanks for your work.

On 2023-06-01 08:01:03 -0700, Stephen Hemminger wrote:
> Suggested by devtools/cocci/strlcpy-with-header.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>

> ---
>  drivers/net/nfp/flower/nfp_flower_representor.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
> index 362c67f7b56d..09e0447d9268 100644
> --- a/drivers/net/nfp/flower/nfp_flower_representor.c
> +++ b/drivers/net/nfp/flower/nfp_flower_representor.c
> @@ -600,7 +600,7 @@ nfp_flower_pf_repr_init(struct rte_eth_dev *eth_dev,
>  	repr->repr_type        = init_repr_data->repr_type;
>  	repr->app_fw_flower    = init_repr_data->app_fw_flower;
>  
> -	snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name);
> +	strlcpy(repr->name, init_repr_data->name, sizeof(repr->name));
>  
>  	eth_dev->dev_ops = &nfp_flower_pf_repr_dev_ops;
>  	eth_dev->rx_pkt_burst = nfp_flower_pf_recv_pkts;
> @@ -671,7 +671,7 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
>  	repr->repr_type        = init_repr_data->repr_type;
>  	repr->app_fw_flower    = init_repr_data->app_fw_flower;
>  
> -	snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name);
> +	strlcpy(repr->name, init_repr_data->name, sizeof(repr->name));
>  
>  	eth_dev->dev_ops = &nfp_flower_repr_dev_ops;
>  	eth_dev->rx_pkt_burst = nfp_flower_repr_rx_burst;
> -- 
> 2.39.2
>
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 362c67f7b56d..09e0447d9268 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -600,7 +600,7 @@  nfp_flower_pf_repr_init(struct rte_eth_dev *eth_dev,
 	repr->repr_type        = init_repr_data->repr_type;
 	repr->app_fw_flower    = init_repr_data->app_fw_flower;
 
-	snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name);
+	strlcpy(repr->name, init_repr_data->name, sizeof(repr->name));
 
 	eth_dev->dev_ops = &nfp_flower_pf_repr_dev_ops;
 	eth_dev->rx_pkt_burst = nfp_flower_pf_recv_pkts;
@@ -671,7 +671,7 @@  nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
 	repr->repr_type        = init_repr_data->repr_type;
 	repr->app_fw_flower    = init_repr_data->app_fw_flower;
 
-	snprintf(repr->name, sizeof(repr->name), "%s", init_repr_data->name);
+	strlcpy(repr->name, init_repr_data->name, sizeof(repr->name));
 
 	eth_dev->dev_ops = &nfp_flower_repr_dev_ops;
 	eth_dev->rx_pkt_burst = nfp_flower_repr_rx_burst;