提交 930cfe0f 编写于 作者: C Christophe JAILLET 提交者: David S. Miller

hinic: Use devm_kasprintf instead of hard coding it

'devm_kasprintf' is less verbose than:
   snprintf(NULL, 0, ...);
   devm_kzalloc(...);
   sprintf
so use it instead.
Signed-off-by: NChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: NZhao Chen <zhaochen6@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 407308f6
......@@ -502,7 +502,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;
......@@ -511,13 +511,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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册