Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965188AbbBBVUZ (ORCPT ); Mon, 2 Feb 2015 16:20:25 -0500 Received: from smtprelay0231.hostedemail.com ([216.40.44.231]:54009 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754763AbbBBVUW (ORCPT ); Mon, 2 Feb 2015 16:20:22 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1801:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3150:3353:3622:3865:3866:3867:3871:3872:4321:4605:5007:6261:7904:10004:10400:10450:10455:10471:10848:11026:11473:11658:11914:12043:12296:12517:12519:12740:13069:13255:13311:13357:19904:19999:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: route32_2cc72f0f1d40 X-Filterd-Recvd-Size: 2838 Message-ID: <1422912017.30476.28.camel@perches.com> Subject: Re: [PATCH v2] net: bluetooth: hci_sock: Use 'const void *' instead of 'void *' for 2nd parameter of hci_test_bit() From: Joe Perches To: Chen Gang S Cc: marcel@holtmann.org, gustavo@padovan.org, johan.hedberg@gmail.com, "David S. Miller" , linux-bluetooth@vger.kernel.org, "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Date: Mon, 02 Feb 2015 13:20:17 -0800 In-Reply-To: <54CFE8BE.5030700@sunrus.com.cn> References: <54CFE8BE.5030700@sunrus.com.cn> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2005 Lines: 58 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? --- $ git grep -A4 "struct hci_filter {" include/net/bluetooth/hci_sock.h:struct hci_filter { include/net/bluetooth/hci_sock.h- unsigned long type_mask; include/net/bluetooth/hci_sock.h- unsigned long event_mask[2]; include/net/bluetooth/hci_sock.h- __le16 opcode; include/net/bluetooth/hci_sock.h-}; --- static bool is_filtered_packet(struct sock *sk, struct sk_buff *skb) { struct hci_filter *flt; [...] if (!hci_test_bit(flt_event, &flt->event_mask)) return true; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/