kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] hinic: Use devm_kasprintf instead of hard coding it
@ 2019-06-13 19:54 Christophe JAILLET
  2019-06-14 12:11 ` Christophe JAILLET
  2019-06-15 20:38 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2019-06-13 19:54 UTC (permalink / raw)
  To: aviad.krawczyk, davem
  Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET

'devm_kasprintf' is less verbose than:
   snprintf(NULL, 0, ...);
   devm_kzalloc(...);
   sprintf
so use it instead.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/ethernet/huawei/hinic/hinic_rx.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
index 9b4082557ad5..95b09fd110d3 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
@@ -493,7 +493,7 @@ int hinic_init_rxq(struct hinic_rxq *rxq, struct hinic_rq *rq,
 		   struct net_device *netdev)
 {
 	struct hinic_qp *qp = container_of(rq, struct hinic_qp, rq);
-	int err, pkts, irqname_len;
+	int err, pkts;
 
 	rxq->netdev = netdev;
 	rxq->rq = rq;
@@ -502,13 +502,11 @@ int hinic_init_rxq(struct hinic_rxq *rxq, struct hinic_rq *rq,
 
 	rxq_stats_init(rxq);
 
-	irqname_len = snprintf(NULL, 0, "hinic_rxq%d", qp->q_id) + 1;
-	rxq->irq_name = devm_kzalloc(&netdev->dev, irqname_len, GFP_KERNEL);
+	rxq->irq_name = devm_kasprintf(&netdev->dev, GFP_KERNEL,
+				       "hinic_rxq%d", qp->q_id);
 	if (!rxq->irq_name)
 		return -ENOMEM;
 
-	sprintf(rxq->irq_name, "hinic_rxq%d", qp->q_id);
-
 	pkts = rx_alloc_pkts(rxq);
 	if (!pkts) {
 		err = -ENOMEM;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] hinic: Use devm_kasprintf instead of hard coding it
  2019-06-13 19:54 [PATCH net-next] hinic: Use devm_kasprintf instead of hard coding it Christophe JAILLET
@ 2019-06-14 12:11 ` Christophe JAILLET
  2019-06-14 12:21   ` Julia Lawall
  2019-06-15 20:38 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2019-06-14 12:11 UTC (permalink / raw)
  To: aviad.krawczyk, davem; +Cc: netdev, linux-kernel, kernel-janitors

Hi,

I got a:

<aviad.krawczyk@huawei.com>: host huawei.com[103.218.216.136] said: 550
5.1.1 Error: invalid recipients is found from 80.12.242.127

However, MAINTAINERS has:
   HUAWEI ETHERNET DRIVER
   M:	Aviad Krawczyk <aviad.krawczyk@huawei.com>
   L:	netdev@vger.kernel.org
   S:	Supported
   F:	Documentation/networking/hinic.txt
   F:	drivers/net/ethernet/huawei/hinic/

I don't know how this should be fixed (neither if it should be...), so if s.o. knows, please do.

Best regards,
Christophe Jaillet

Le 13/06/2019 à 21:54, Christophe JAILLET a écrit :
> 'devm_kasprintf' is less verbose than:
>     snprintf(NULL, 0, ...);
>     devm_kzalloc(...);
>     sprintf
> so use it instead.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>   drivers/net/ethernet/huawei/hinic/hinic_rx.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> index 9b4082557ad5..95b09fd110d3 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> @@ -493,7 +493,7 @@ int hinic_init_rxq(struct hinic_rxq *rxq, struct hinic_rq *rq,
>   		   struct net_device *netdev)
>   {
>   	struct hinic_qp *qp = container_of(rq, struct hinic_qp, rq);
> -	int err, pkts, irqname_len;
> +	int err, pkts;
>   
>   	rxq->netdev = netdev;
>   	rxq->rq = rq;
> @@ -502,13 +502,11 @@ int hinic_init_rxq(struct hinic_rxq *rxq, struct hinic_rq *rq,
>   
>   	rxq_stats_init(rxq);
>   
> -	irqname_len = snprintf(NULL, 0, "hinic_rxq%d", qp->q_id) + 1;
> -	rxq->irq_name = devm_kzalloc(&netdev->dev, irqname_len, GFP_KERNEL);
> +	rxq->irq_name = devm_kasprintf(&netdev->dev, GFP_KERNEL,
> +				       "hinic_rxq%d", qp->q_id);
>   	if (!rxq->irq_name)
>   		return -ENOMEM;
>   
> -	sprintf(rxq->irq_name, "hinic_rxq%d", qp->q_id);
> -
>   	pkts = rx_alloc_pkts(rxq);
>   	if (!pkts) {
>   		err = -ENOMEM;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] hinic: Use devm_kasprintf instead of hard coding it
  2019-06-14 12:11 ` Christophe JAILLET
@ 2019-06-14 12:21   ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2019-06-14 12:21 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: aviad.krawczyk, davem, netdev, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2346 bytes --]



On Fri, 14 Jun 2019, Christophe JAILLET wrote:

> Hi,
>
> I got a:
>
> <aviad.krawczyk@huawei.com>: host huawei.com[103.218.216.136] said: 550
> 5.1.1 Error: invalid recipients is found from 80.12.242.127
>
> However, MAINTAINERS has:
>   HUAWEI ETHERNET DRIVER
>   M:	Aviad Krawczyk <aviad.krawczyk@huawei.com>
>   L:	netdev@vger.kernel.org
>   S:	Supported
>   F:	Documentation/networking/hinic.txt
>   F:	drivers/net/ethernet/huawei/hinic/
>
> I don't know how this should be fixed (neither if it should be...), so if s.o.
> knows, please do.

Maybe this person would know, since he is also from Huawei and has signed
off on a patch by Aviad Krawczyk:

cde66f24c3bf42123647c5233447c5790d92557f
Signed-off-by: Zhao Chen <zhaochen6@huawei.com>

julia

>
> Best regards,
> Christophe Jaillet
>
> Le 13/06/2019 à 21:54, Christophe JAILLET a écrit :
> > 'devm_kasprintf' is less verbose than:
> >     snprintf(NULL, 0, ...);
> >     devm_kzalloc(...);
> >     sprintf
> > so use it instead.
> >
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> >   drivers/net/ethernet/huawei/hinic/hinic_rx.c | 8 +++-----
> >   1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> > b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> > index 9b4082557ad5..95b09fd110d3 100644
> > --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> > +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> > @@ -493,7 +493,7 @@ int hinic_init_rxq(struct hinic_rxq *rxq, struct
> > hinic_rq *rq,
> >   		   struct net_device *netdev)
> >   {
> >   	struct hinic_qp *qp = container_of(rq, struct hinic_qp, rq);
> > -	int err, pkts, irqname_len;
> > +	int err, pkts;
> >     	rxq->netdev = netdev;
> >   	rxq->rq = rq;
> > @@ -502,13 +502,11 @@ int hinic_init_rxq(struct hinic_rxq *rxq, struct
> > hinic_rq *rq,
> >     	rxq_stats_init(rxq);
> >   -	irqname_len = snprintf(NULL, 0, "hinic_rxq%d", qp->q_id) + 1;
> > -	rxq->irq_name = devm_kzalloc(&netdev->dev, irqname_len, GFP_KERNEL);
> > +	rxq->irq_name = devm_kasprintf(&netdev->dev, GFP_KERNEL,
> > +				       "hinic_rxq%d", qp->q_id);
> >   	if (!rxq->irq_name)
> >   		return -ENOMEM;
> >   -	sprintf(rxq->irq_name, "hinic_rxq%d", qp->q_id);
> > -
> >   	pkts = rx_alloc_pkts(rxq);
> >   	if (!pkts) {
> >   		err = -ENOMEM;
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] hinic: Use devm_kasprintf instead of hard coding it
  2019-06-13 19:54 [PATCH net-next] hinic: Use devm_kasprintf instead of hard coding it Christophe JAILLET
  2019-06-14 12:11 ` Christophe JAILLET
@ 2019-06-15 20:38 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-06-15 20:38 UTC (permalink / raw)
  To: christophe.jaillet; +Cc: aviad.krawczyk, netdev, linux-kernel, kernel-janitors

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Thu, 13 Jun 2019 21:54:12 +0200

> 'devm_kasprintf' is less verbose than:
>    snprintf(NULL, 0, ...);
>    devm_kzalloc(...);
>    sprintf
> so use it instead.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-15 20:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 19:54 [PATCH net-next] hinic: Use devm_kasprintf instead of hard coding it Christophe JAILLET
2019-06-14 12:11 ` Christophe JAILLET
2019-06-14 12:21   ` Julia Lawall
2019-06-15 20:38 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).