Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1665709

Re: [PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use kernel container_of

Path csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use kernel container_of
Date Wed, 14 Jun 2017 13:00:02 +0200
Message-ID <tSebM-48n-33@gated-at.bofh.it> (permalink)
References <tS1oe-4EQ-17@gated-at.bofh.it> <tS1oe-4EQ-19@gated-at.bofh.it> <tSdIK-3YE-17@gated-at.bofh.it> <tSdSp-41A-1@gated-at.bofh.it> <tSe26-459-17@gated-at.bofh.it>
X-Original-To Greg Kroah-Hartman <gregkh@linuxfoundation.org>
X-Session-Marker 6A6F6540706572636865732E636F6D
X-Spam-Summary 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2553:2559:2562:2693:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:4385:5007:7903:8660:10004:10400:10848:11026:11232:11473:11657:11658:11914:12043:12296:12438:12740:12760:12895:13069:13148:13149:13230:13255:13311:13357:13439:14096:14097:14659:14721:21080:21451:21611:21627:30012:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none
X-He-Tag color78_72173b4c0674a
X-Filterd-Recvd-Size 3032
Content-Type text/plain; charset="ISO-8859-1"
X-Mailer Evolution 3.22.6-1ubuntu1
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 52
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Hans de Goede <hdegoede@redhat.com>, Larry Finger <Larry.Finger@lwfinger.net>
X-Original-Date Wed, 14 Jun 2017 03:56:22 -0700
X-Original-Message-ID <1497437782.18751.47.camel@perches.com>
X-Original-References <cover.1497388055.git.joe@perches.com> <629c18e79e3528e03deabdd1996ceb857f34aa81.1497388055.git.joe@perches.com> <20170614101853.GA8107@kroah.com> <1497436701.18751.41.camel@perches.com> <20170614104832.GA1320@kroah.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1665709

Show key headers only | View raw


On Wed, 2017-06-14 at 12:48 +0200, Greg Kroah-Hartman wrote:
> On Wed, Jun 14, 2017 at 03:38:21AM -0700, Joe Perches wrote:
> > On Wed, 2017-06-14 at 12:18 +0200, Greg Kroah-Hartman wrote:
> > > On Tue, Jun 13, 2017 at 02:12:56PM -0700, Joe Perches wrote:
> > > > These are similar macros so use the normal kernel one.
> > > > 
> > > > As well, there are odd games being played with casting a plist to
> > > > a union recv_frame by using LIST_CONTAINOR.  Just use a direct cast
> > > > to union recv_frame instead.
> > 
> > []
> > > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > 
> > []
> > > > @@ -129,7 +129,7 @@ union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
> > > >  
> > > >  		plist = get_next(phead);
> > > >  
> > > > -		precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
> > > > +		precvframe = (union recv_frame *)plist;
> > > 
> > > No, you are "assuming" that the list_head is going to stay the first
> > > object of this structure, and what if it isn't?
> > > 
> > > Just use container_of, that way at least you get the type safeness of
> > > the call, and if something changes in the future, you don't instantly
> > > break the code everywhere without knowing it.
> > 
> > It's a named union u and it's exactly at the beginning.
> > It's unlikely to change.
> > 
> > The container_of macro doesn't work here as there it has
> > a BUILD_BUG_ON_MSG and there are pointer type mismatches
> > on those uses.
> 
> Yeah, but random pointer casts like this are not good, I don't want to
> see that here, sorry.
> 
> Fix up the pointer mismatches, if there are any, as that implies there
> are bugs here...

<shrug>.

No thanks.

That's what the current code is doing now.

Ignore the whole thing if you want.

Someone else might fix it eventually, but more
likely the current rtl8723bs driver will be
dropped and completely rewritten anyway.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use kernel container_of Joe Perches <joe@perches.com> - 2017-06-13 23:20 +0200
  Re: [PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use  kernel container_of Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-14 12:30 +0200
    Re: [PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use  kernel container_of Joe Perches <joe@perches.com> - 2017-06-14 12:40 +0200
      Re: [PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use  kernel container_of Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-14 12:50 +0200
        Re: [PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use  kernel container_of Joe Perches <joe@perches.com> - 2017-06-14 13:00 +0200

csiph-web