public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches•com>
To: Arnd Bergmann <arnd@arndb•de>
Cc: netdev@vger•kernel.org, davem@davemloft•net,
	huangdaode <huangdaode@hisilicon•com>,
	Kenneth Lee <liguozhu@huawei•com>,
	Yisen Zhuang <Yisen.Zhuang@huawei•com>
Subject: Re: [PATCH] net: nhs: fix 32-bit build warning
Date: Sun, 11 Oct 2015 13:13:40 -0700	[thread overview]
Message-ID: <1444594420.8012.34.camel@perches.com> (raw)
In-Reply-To: <8581924.9CPedieySC@wuerfel>

On Tue, 2015-10-06 at 23:53 +0200, Arnd Bergmann wrote:
> diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
[]
> @@ -448,12 +448,12 @@ static ssize_t handles_show(struct device *dev,
>  		s += sprintf(buf + s, "handle %d (eport_id=%u from %s):\n",
>  			    i++, h->eport_id, h->dev->name);
>  		for (j = 0; j < h->q_num; j++) {
> -			s += sprintf(buf + s, "\tqueue[%d] on 0x%llx\n",
> -				     j, (u64)h->qs[i]->io_base);
> -#define HANDEL_TX_MSG "\t\ttx_ring on 0x%llx:%u,%u,%u,%u,%u,%llu,%llu\n"
> +			s += sprintf(buf + s, "\tqueue[%d] on %p\n",
> +				     j, h->qs[i]->io_base);
> +#define HANDEL_TX_MSG "\t\ttx_ring on %p:%u,%u,%u,%u,%u,%llu,%llu\n"
>  			s += sprintf(buf + s,
>  				     HANDEL_TX_MSG,

Maybe one day remove the misspelled and
used once HANDEL_TX_MSG macro too.

Another possibility is to use a generally
smaller object code style like:

	char *s = buf;
	...
	s += sprintf(s, ...)
	...
	return s - buf;

instead of

	ssize_t s = 0;
	...
	s += sprintf(buf + s, ...)
	...
	return s;
---
 drivers/net/ethernet/hisilicon/hns/hnae.c | 35 +++++++++++++++----------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index f52e99a..d2af46f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -439,40 +439,39 @@ EXPORT_SYMBOL(hnae_ae_unregister);
 static ssize_t handles_show(struct device *dev,
 			    struct device_attribute *attr, char *buf)
 {
-	ssize_t s = 0;
+	char *s = buf;
 	struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
 	struct hnae_handle *h;
 	int i = 0, j;
 
 	list_for_each_entry_rcu(h, &hdev->handle_list, node) {
-		s += sprintf(buf + s, "handle %d (eport_id=%u from %s):\n",
-			    i++, h->eport_id, h->dev->name);
+		s += sprintf(s, "handle %d (eport_id=%u from %s):\n",
+			     i++, h->eport_id, h->dev->name);
 		for (j = 0; j < h->q_num; j++) {
-			s += sprintf(buf + s, "\tqueue[%d] on %p\n",
+			s += sprintf(s, "\tqueue[%d] on %p\n",
 				     j, h->qs[i]->io_base);
-#define HANDEL_TX_MSG "\t\ttx_ring on %p:%u,%u,%u,%u,%u,%llu,%llu\n"
-			s += sprintf(buf + s,
-				     HANDEL_TX_MSG,
+			s += sprintf(s,
+				     "\t\ttx_ring on %p:%u,%u,%u,%u,%u,%llu,%llu\n",
 				     h->qs[i]->tx_ring.io_base,
 				     h->qs[i]->tx_ring.buf_size,
 				     h->qs[i]->tx_ring.desc_num,
 				     h->qs[i]->tx_ring.max_desc_num_per_pkt,
 				     h->qs[i]->tx_ring.max_raw_data_sz_per_desc,
 				     h->qs[i]->tx_ring.max_pkt_size,
-				 h->qs[i]->tx_ring.stats.sw_err_cnt,
-				 h->qs[i]->tx_ring.stats.io_err_cnt);
-			s += sprintf(buf + s,
-				"\t\trx_ring on %p:%u,%u,%llu,%llu,%llu\n",
-				h->qs[i]->rx_ring.io_base,
-				h->qs[i]->rx_ring.buf_size,
-				h->qs[i]->rx_ring.desc_num,
-				h->qs[i]->rx_ring.stats.sw_err_cnt,
-				h->qs[i]->rx_ring.stats.io_err_cnt,
-				h->qs[i]->rx_ring.stats.seg_pkt_cnt);
+				     h->qs[i]->tx_ring.stats.sw_err_cnt,
+				     h->qs[i]->tx_ring.stats.io_err_cnt);
+			s += sprintf(s,
+				     "\t\trx_ring on %p:%u,%u,%llu,%llu,%llu\n",
+				     h->qs[i]->rx_ring.io_base,
+				     h->qs[i]->rx_ring.buf_size,
+				     h->qs[i]->rx_ring.desc_num,
+				     h->qs[i]->rx_ring.stats.sw_err_cnt,
+				     h->qs[i]->rx_ring.stats.io_err_cnt,
+				     h->qs[i]->rx_ring.stats.seg_pkt_cnt);
 		}
 	}
 
-	return s;
+	return s - buf;
 }
 
 static DEVICE_ATTR_RO(handles);

  parent reply	other threads:[~2015-10-11 20:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06 21:53 [PATCH] net: nhs: fix 32-bit build warning Arnd Bergmann
2015-10-06 22:21 ` Sergei Shtylyov
2015-10-08 11:55 ` David Miller
2015-10-11 20:13 ` Joe Perches [this message]
2015-10-12  1:25   ` huangdaode

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444594420.8012.34.camel@perches.com \
    --to=joe@perches$(echo .)com \
    --cc=Yisen.Zhuang@huawei$(echo .)com \
    --cc=arnd@arndb$(echo .)de \
    --cc=davem@davemloft$(echo .)net \
    --cc=huangdaode@hisilicon$(echo .)com \
    --cc=liguozhu@huawei$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox