lkml.org 
[lkml]   [2022]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 3/3] serial: Add kserial_rs485 to avoid wasted space due to .padding
On Mon, Aug 29, 2022 at 3:09 PM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
> On Fri, 26 Aug 2022, Andy Shevchenko wrote:
> > On Fri, Aug 26, 2022 at 5:51 PM Ilpo Järvinen
> > <ilpo.jarvinen@linux.intel.com> wrote:

...

> > > + *rs485 = *((struct kserial_rs485 *)&rs485_uapi);
> >
> > So with all assets we have we can be sure that on BE64 / BE32 machines
> > this will be flawless. Is this assumption correct?
>
> I think so. At worst it could trigger a build fail assuming the kernel
> would do some really odd struct layout reordering (which, according to
> the build bot, doesn't occur for any currently tested arch).
>
> Now that you highlighted this line though, I started to wonder if it would
> be just better to use memcpy() instead as it would avoid those casts.

Actually the current version might be better since the compiler will
be aware of the types, but it still requires a proper layout of the
fields. That said, I leave it for you.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2022-08-29 14:32    [W:0.044 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site