linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabian Frederick <fabf@skynet.be>
To: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, airlied@linux.ie,
	dri-devel@lists.freedesktop.org, peter@hurleysoftware.com
Subject: Re: [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible
Date: Mon, 15 Sep 2014 20:15:54 +0200 (CEST)	[thread overview]
Message-ID: <1669797975.16695.1410804954304.open-xchange@webmail.nmp.skynet.be> (raw)
In-Reply-To: <20140915001356.2e05d782@alan.etchedpixels.co.uk>



> On 15 September 2014 at 01:13 One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
> wrote:
>
>
> On Sun, 14 Sep 2014 18:40:13 +0200
> Fabian Frederick <fabf@skynet.be> wrote:
>
> > Small patchset using container_of instead of casting on first structure
> > member address.
>
> Why. Container_of is useful for random offsets but its just convoluting
> and confusing code which is designed with the fields intentionally at the
> start.
>
> Alan

What if someone doesn't know about that intention one day and inserts
some field in the structure at the "wrong place" ?
This would need at least some comment in each declaration
but once again it's hard to control.One other way is to
commonly use container_of and get rid of every casting with
some semantic script.

Peter has been asking for container_of in the following:

http://marc.info/?l=linux-arm-kernel&m=140838705729653&w=2


struct uart_amba_port *uap = (struct uart_amba_port *)port

(port/uart_port is the first field in uart_amba_port though)

Regards,
Fabian

  reply	other threads:[~2014-09-15 18:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
2014-09-14 16:40 ` [PATCH 1/9 linux-next] drm/cirrus: use container_of to resolve cirrus_fbdev from drm_fb_helper Fabian Frederick
2014-09-14 16:40 ` [PATCH 2/9 linux-next] drm/mgag200: use container_of to resolve mga_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 3/9 linux-next] drm/radeon: use container_of to resolve radeon_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 4/9 linux-next] drm/nouveau: use container_of to resolve nouveau_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 5/9 linux-next] drm/nouveau: use container_of to resolve nouveau_plane from drm_plane Fabian Frederick
2014-09-14 16:40 ` [PATCH 6/9 linux-next] drm/qxl: use container_of to resolve qxl_fbdev from drm_fb_helper Fabian Frederick
2014-09-14 16:40 ` [PATCH 7/9 linux-next] drm/gma500: use container_of to resolve psb_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 8/9 linux-next] drm/ast: use container_of to resolve ast_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 9/9 linux-next] drm/udl: use container_of to resolve udl_fbdev " Fabian Frederick
2014-09-14 23:13 ` [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible One Thousand Gnomes
2014-09-15 18:15   ` Fabian Frederick [this message]
2014-09-17 10:01     ` Daniel Vetter
2014-09-17 10:49     ` One Thousand Gnomes

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=1669797975.16695.1410804954304.open-xchange@webmail.nmp.skynet.be \
    --to=fabf@skynet.be \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    /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 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).