netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: nhs: fix 32-bit build warning
@ 2015-10-06 21:53 Arnd Bergmann
  2015-10-06 22:21 ` Sergei Shtylyov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2015-10-06 21:53 UTC (permalink / raw)
  To: netdev; +Cc: davem, huangdaode, Kenneth Lee, Yisen Zhuang

The recently added hns driver causes a build warning in ARM
allmodconfig builds:

drivers/net/ethernet/hisilicon/hns/hnae.c: In function 'handles_show':
drivers/net/ethernet/hisilicon/hns/hnae.c:452:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
          j, (u64)h->qs[i]->io_base);
             ^

This removes the pointless cast and prints the pointer address using
the "%p" format string in all three locations.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c
index 0a0a9e80dcd7..f52e99acf463 100644
--- 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,
-				     (u64)h->qs[i]->tx_ring.io_base,
+				     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,
@@ -462,8 +462,8 @@ static ssize_t handles_show(struct device *dev,
 				 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 0x%llx:%u,%u,%llu,%llu,%llu\n",
-				(u64)h->qs[i]->rx_ring.io_base,
+				"\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,

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

* Re: [PATCH] net: nhs: fix 32-bit build warning
  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
  2 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2015-10-06 22:21 UTC (permalink / raw)
  To: Arnd Bergmann, netdev; +Cc: davem, huangdaode, Kenneth Lee, Yisen Zhuang

Hello.

    Note the typo in the subject: s/nhs/hns/.

MBR, Sergei

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

* Re: [PATCH] net: nhs: fix 32-bit build warning
  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
  2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2015-10-08 11:55 UTC (permalink / raw)
  To: arnd; +Cc: netdev, huangdaode, liguozhu, Yisen.Zhuang

From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 06 Oct 2015 23:53:57 +0200

> The recently added hns driver causes a build warning in ARM
> allmodconfig builds:
> 
> drivers/net/ethernet/hisilicon/hns/hnae.c: In function 'handles_show':
> drivers/net/ethernet/hisilicon/hns/hnae.c:452:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>           j, (u64)h->qs[i]->io_base);
>              ^
> 
> This removes the pointless cast and prints the pointer address using
> the "%p" format string in all three locations.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied with subject typo fixed, thanks.

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

* Re: [PATCH] net: nhs: fix 32-bit build warning
  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
  2015-10-12  1:25   ` huangdaode
  2 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2015-10-11 20:13 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: netdev, davem, huangdaode, Kenneth Lee, Yisen Zhuang

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);

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

* Re: [PATCH] net: nhs: fix 32-bit build warning
  2015-10-11 20:13 ` Joe Perches
@ 2015-10-12  1:25   ` huangdaode
  0 siblings, 0 replies; 5+ messages in thread
From: huangdaode @ 2015-10-12  1:25 UTC (permalink / raw)
  To: Joe Perches; +Cc: Arnd Bergmann, netdev, davem, Kenneth Lee, Yisen Zhuang

On 2015/10/12 4:13, Joe Perches wrote:
> 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);
>
>
>
> .
>
thanks Joe
your suggestion is good, will send out a patch to fix it.


-- 
Best Regards
Daode Huang

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

end of thread, other threads:[~2015-10-12  1:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2015-10-12  1:25   ` huangdaode

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).