lkml.org 
[lkml]   [2014]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] drivers: staging: lustre: lustre: include: add "__attribute__((packed))" for the related union
Hi Dan,

On 20/01/14 21:13, Dan Carpenter wrote:
> I made a quick and dirty sparse patch to check for this. I don't think
> I will bother trying to send it to sparse upstream, but you can if you
> want to.
>
> It found 289 unions which might need a __packed added. The lustre
> unions were not in my allmodconfig so they're not listed.

Thanks a lot for this, it seems to be useful. I'm adapting it to reduce
false negatives (e.g. omitting the check if the struct/union is already
packed), and I imagine it could be made to only warn about padded
unpacked structs/unions which are used as nested members of packed
structs/unions. It wouldn't catch everything but would probably catch a
lot of cases that are most likely to be genuine since they would have
been packed at the outer level for a reason.

> Perhaps there could be a command line option or a pragma so that unions
> will work in the kernel. We don't care about linking to outside
> libraries.

We still interact with userland via structs and unions, so it would
probably have to exclude anything in uapi/.

Cheers
James

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2014-01-21 12:21    [W:0.094 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site