From: Joe Perches <joe@perches.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org,
Hans de Goede <hdegoede@redhat.com>,
Larry Finger <Larry.Finger@lwfinger.net>
Subject: Re: [PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use kernel container_of
Date: Wed, 14 Jun 2017 03:38:21 -0700 [thread overview]
Message-ID: <1497436701.18751.41.camel@perches.com> (raw)
In-Reply-To: <20170614101853.GA8107@kroah.com>
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.
next prev parent reply other threads:[~2017-06-14 10:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 21:12 [PATCH 0/2] staging: rtl8723bs: Fix LIST_CONTAINOR spelling and uses Joe Perches
2017-06-13 21:12 ` [PATCH 1/2] staging: rtl8723bs: Convert LIST_CONTAINOR to use kernel container_of Joe Perches
2017-06-14 10:18 ` Greg Kroah-Hartman
2017-06-14 10:38 ` Joe Perches [this message]
2017-06-14 10:48 ` Greg Kroah-Hartman
2017-06-14 10:56 ` Joe Perches
2017-06-13 21:12 ` [PATCH 2/2] staging: rtl8723bs: Convert LIST_CONTAINOR to container_of Joe Perches
2017-09-11 16:35 ` Greg Kroah-Hartman
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=1497436701.18751.41.camel@perches.com \
--to=joe@perches.com \
--cc=Larry.Finger@lwfinger.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@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.