All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang S <gang.chen@sunrus.com.cn>
To: Joe Perches <joe@perches.com>
Cc: marcel@holtmann.org, gustavo@padovan.org,
	johan.hedberg@gmail.com, "David S. Miller" <davem@davemloft.net>,
	linux-bluetooth@vger.kernel.org,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] net: bluetooth: hci_sock: Use 'const void *' instead of 'void *' for 2nd parameter of hci_test_bit()
Date: Tue, 03 Feb 2015 10:32:11 +0800	[thread overview]
Message-ID: <54D0332B.6050701@sunrus.com.cn> (raw)
In-Reply-To: <1422912017.30476.28.camel@perches.com>

On 2/3/15 05:20, Joe Perches wrote:
> On Tue, 2015-02-03 at 05:14 +0800, Chen Gang S wrote:
>> hci_test_bit() does not modify 2nd parameter, so it is better to let it
>> be constant, or may cause build warning. The related warning (with
>> allmodconfig under xtensa):
> []
>> diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
> []
>> @@ -46,7 +46,7 @@ struct hci_pinfo {
>>  	unsigned short    channel;
>>  };
>>  
>> -static inline int hci_test_bit(int nr, void *addr)
>> +static inline int hci_test_bit(int nr, const void *addr)
>>  {
>>  	return *((__u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31));
>>  }
> 
> It's probably better to use const __u32 * here too, but the
> real thing I wonder is whether or not there's an issue with
> one of the 2 uses of this function.
> 
> One of them passes a unsigned long *, the other a u32 *.
> 
> $ git grep -w hci_test_bit
> net/bluetooth/hci_sock.c:static inline int hci_test_bit(int nr, void *addr)
> net/bluetooth/hci_sock.c:       if (!hci_test_bit(flt_event, &flt->event_mask))
> net/bluetooth/hci_sock.c:                    !hci_test_bit(ocf & HCI_FLT_OCF_BITS,
> net/bluetooth/hci_sock.c-                                  &hci_sec_filter.ocf_mask[ogf])) &&
> 
> hci_sec_filter.ocf_mask is __u32
> but flt->event_mask is unsigned long.
> 
> Any possible issue here on 64-bit systems?
> 

For me, it can not cause issue on 64-bit systems. hci_test_bit() treats
'addr' as "__u32 *", and has to use the pointer to do something.


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

WARNING: multiple messages have this Message-ID (diff)
From: Chen Gang S <gang.chen-/B7AUNIrSHOPt1CcHtbs0g@public.gmane.org>
To: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
Cc: marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org,
	gustavo-THi1TnShQwVAfugRpC6u6w@public.gmane.org,
	johan.hedberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v2] net: bluetooth: hci_sock: Use 'const void *' instead of 'void *' for 2nd parameter of hci_test_bit()
Date: Tue, 03 Feb 2015 10:32:11 +0800	[thread overview]
Message-ID: <54D0332B.6050701@sunrus.com.cn> (raw)
In-Reply-To: <1422912017.30476.28.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>

On 2/3/15 05:20, Joe Perches wrote:
> On Tue, 2015-02-03 at 05:14 +0800, Chen Gang S wrote:
>> hci_test_bit() does not modify 2nd parameter, so it is better to let it
>> be constant, or may cause build warning. The related warning (with
>> allmodconfig under xtensa):
> []
>> diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
> []
>> @@ -46,7 +46,7 @@ struct hci_pinfo {
>>  	unsigned short    channel;
>>  };
>>  
>> -static inline int hci_test_bit(int nr, void *addr)
>> +static inline int hci_test_bit(int nr, const void *addr)
>>  {
>>  	return *((__u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31));
>>  }
> 
> It's probably better to use const __u32 * here too, but the
> real thing I wonder is whether or not there's an issue with
> one of the 2 uses of this function.
> 
> One of them passes a unsigned long *, the other a u32 *.
> 
> $ git grep -w hci_test_bit
> net/bluetooth/hci_sock.c:static inline int hci_test_bit(int nr, void *addr)
> net/bluetooth/hci_sock.c:       if (!hci_test_bit(flt_event, &flt->event_mask))
> net/bluetooth/hci_sock.c:                    !hci_test_bit(ocf & HCI_FLT_OCF_BITS,
> net/bluetooth/hci_sock.c-                                  &hci_sec_filter.ocf_mask[ogf])) &&
> 
> hci_sec_filter.ocf_mask is __u32
> but flt->event_mask is unsigned long.
> 
> Any possible issue here on 64-bit systems?
> 

For me, it can not cause issue on 64-bit systems. hci_test_bit() treats
'addr' as "__u32 *", and has to use the pointer to do something.


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

  reply	other threads:[~2015-02-03  2:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-02 21:14 [PATCH v2] net: bluetooth: hci_sock: Use 'const void *' instead of 'void *' for 2nd parameter of hci_test_bit() Chen Gang S
2015-02-02 21:14 ` Chen Gang S
2015-02-02 21:20 ` Joe Perches
2015-02-02 21:20   ` Joe Perches
2015-02-03  2:32   ` Chen Gang S [this message]
2015-02-03  2:32     ` Chen Gang S
2015-02-03  2:59     ` Chen Gang S
2015-02-04 12:13       ` David Laight
2015-02-04 12:13         ` David Laight
2015-02-04 12:13         ` David Laight
2015-02-04 11:59 ` David Laight
2015-02-04 11:59   ` David Laight
2015-02-04 11:59   ` David Laight
2015-02-04 20:13   ` Sergei Shtylyov
2015-02-04 21:09     ` Marcel Holtmann
2015-02-04 21:09       ` Marcel Holtmann
2015-02-04 21:47       ` Chen Gang S
2015-02-05 10:14         ` David Laight
2015-02-05 10:14           ` David Laight
2015-02-05 12:20           ` Chen Gang S

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=54D0332B.6050701@sunrus.com.cn \
    --to=gang.chen@sunrus.com.cn \
    --cc=davem@davemloft.net \
    --cc=gustavo@padovan.org \
    --cc=joe@perches.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.