All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	kernel test robot <lkp@intel.com>,
	Nick Desaulniers <nick.desaulniers@gmail.com>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	kbuild-all@lists.01.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
Date: Thu, 26 Aug 2021 15:22:51 +0200	[thread overview]
Message-ID: <YSeVq7nvVKgCL4HL@alley> (raw)
In-Reply-To: <20210819081053.GW3@paasikivi.fi.intel.com>

On Thu 2021-08-19 11:10:53, Sakari Ailus wrote:
> On Fri, Jul 16, 2021 at 03:12:11PM +0300, Andy Shevchenko wrote:
> > On Fri, Jul 16, 2021 at 02:41:05PM +0300, Sakari Ailus wrote:
> > > On Wed, Jul 14, 2021 at 10:45:26PM +0300, Andy Shevchenko wrote:
> > > > > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > > > 

Is there any plan to fix this, please?


> > > > Why is it packed in the first place? Is it used on unaligned addresses
> > > > in other structures? But even so, why should it matter?
> > > 
> > > It's packed since we wanted to avoid having holes in the structs. There are
> > > other ways to do that but it's ABI dependent and is prone to human errors,
> > > too.

> > What holes can you think about in the above mention structure?
> 
> Probably not that one but it has happened in the past that the struct
> memory layout has been unintentionally different in different ABIs and that
> has not been the intention, but rather a bug.

What kind of bugs did the different ABI caused, please? Incompatibly
between 3rd party drivers that were built with different compilers?

I am not familiar with these problems. I wonder if there is a better
solution. I guess that it might be a common problem affecting most
drivers.

Anyway, the non-aligned struct members might create slower code.

> Packing has been added in newer structs to avoid that.

And this smells with cargo-cult programming. People might make all new
structures packed even when it is not really needed.

Best Regards,
Petr

WARNING: multiple messages have this Message-ID (diff)
From: Petr Mladek <pmladek@suse.com>
To: kbuild-all@lists.01.org
Subject: Re: drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value
Date: Thu, 26 Aug 2021 15:22:51 +0200	[thread overview]
Message-ID: <YSeVq7nvVKgCL4HL@alley> (raw)
In-Reply-To: <20210819081053.GW3@paasikivi.fi.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]

On Thu 2021-08-19 11:10:53, Sakari Ailus wrote:
> On Fri, Jul 16, 2021 at 03:12:11PM +0300, Andy Shevchenko wrote:
> > On Fri, Jul 16, 2021 at 02:41:05PM +0300, Sakari Ailus wrote:
> > > On Wed, Jul 14, 2021 at 10:45:26PM +0300, Andy Shevchenko wrote:
> > > > > >> drivers/media/v4l2-core/v4l2-ioctl.c:347:37: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_sdr_format' may result in an unaligned pointer value [-Waddress-of-packed-member]
> > > > 

Is there any plan to fix this, please?


> > > > Why is it packed in the first place? Is it used on unaligned addresses
> > > > in other structures? But even so, why should it matter?
> > > 
> > > It's packed since we wanted to avoid having holes in the structs. There are
> > > other ways to do that but it's ABI dependent and is prone to human errors,
> > > too.

> > What holes can you think about in the above mention structure?
> 
> Probably not that one but it has happened in the past that the struct
> memory layout has been unintentionally different in different ABIs and that
> has not been the intention, but rather a bug.

What kind of bugs did the different ABI caused, please? Incompatibly
between 3rd party drivers that were built with different compilers?

I am not familiar with these problems. I wonder if there is a better
solution. I guess that it might be a common problem affecting most
drivers.

Anyway, the non-aligned struct members might create slower code.

> Packing has been added in newer structs to avoid that.

And this smells with cargo-cult programming. People might make all new
structures packed even when it is not really needed.

Best Regards,
Petr

  reply	other threads:[~2021-08-26 13:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 17:55 drivers/media/v4l2-core/v4l2-ioctl.c:303:28: warning: taking address of packed member 'pixelformat' of class or structure 'v4l2_pix_format_mplane' may result in an unaligned pointer value kernel test robot
2021-07-14 17:55 ` kernel test robot
2021-07-14 19:45 ` Andy Shevchenko
2021-07-14 19:45   ` Andy Shevchenko
2021-07-16 11:41   ` Sakari Ailus
2021-07-16 11:41     ` Sakari Ailus
2021-07-16 12:12     ` Andy Shevchenko
2021-07-16 12:12       ` Andy Shevchenko
2021-08-19  8:10       ` Sakari Ailus
2021-08-19  8:10         ` Sakari Ailus
2021-08-26 13:22         ` Petr Mladek [this message]
2021-08-26 13:22           ` Petr Mladek
2021-11-04 22:21 kernel test robot
2021-11-04 22:21 ` kernel test robot
2021-11-05 10:21 ` Andy Shevchenko
2021-11-05 10:21   ` Andy Shevchenko
2022-01-08 10:33 kernel test robot
2022-01-08 10:33 ` kernel test robot
2022-01-09 14:26 ` Andy Shevchenko
2022-01-09 14:26   ` Andy Shevchenko
2022-01-10 19:44   ` Nick Desaulniers
2022-01-10 19:44     ` Nick Desaulniers
2022-01-10 20:49     ` Andy Shevchenko
2022-01-10 20:49       ` Andy Shevchenko
2022-01-10 21:22       ` Nick Desaulniers
2022-01-10 21:22         ` Nick Desaulniers
2022-01-17  3:40 kernel test robot
2022-01-17  3:40 ` kernel test robot

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=YSeVq7nvVKgCL4HL@alley \
    --to=pmladek@suse.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=nick.desaulniers@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tzimmermann@suse.de \
    /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.