Linux SPARSE checker discussions
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Shannon Nelson <snelson@pensando.io>
Cc: linux-sparse@vger.kernel.org, Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: smatch/sparse complaints on static assertion
Date: Wed, 12 Feb 2020 01:31:28 +0100	[thread overview]
Message-ID: <20200212003128.pieng2rlw7mykhvk@ltop.local> (raw)
In-Reply-To: <ecdd10cb-0022-8f8a-ec36-9d51b3ae85ee@pensando.io>

On Tue, Feb 11, 2020 at 09:41:05AM -0800, Shannon Nelson wrote:
> Hi All,
> 
> I'm getting complaints from smatch on the ionic network driver's static
> assertions and am not sure why it was complaining.  Dan Carpenter suggested
> this might be an issue in sparse with how it is calculating the sizes of the
> unions.
> 
> I ran this at the top of a pretty recent net-next tree
> (v5.5-rc7-1839-g8192c36)
> $ ../smatch/smatch_scripts/kchecker drivers/net/ethernet/pensando/ionic/
> 
> And got several copies of this:
> 
> drivers/net/ethernet/pensando/ionic/ionic_dev.h:38:1: error: static
> assertion failed: "sizeof(union ionic_dev_regs) == 4096"

...
 
> These static assertion lines have been fine up until now and I'm pretty sure
> they are correct.
> 
> Has this issue been seen elsewhere?  Or is there something I can do in our
> code to get rid of the complaints?

This is caused by the packing of the structs. It's using
	#pragma pack(push, 1) / #pragma pack(pop)
which is not supported by Sparse. Packing via __attribute__((packed))
is incomplete but the pragmas are currently completly ignored.

-- Luc Van Oostenryck

  reply	other threads:[~2020-02-12  0:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e588417e-1bf4-35e3-d8d9-9911fe29e0f5@pensando.io>
2020-02-11 17:41 ` smatch/sparse complaints on static assertion Shannon Nelson
2020-02-12  0:31   ` Luc Van Oostenryck [this message]
2020-02-12  1:01     ` Shannon Nelson
2020-02-12  0:36   ` Linus Torvalds
2020-02-12  1:05     ` Shannon Nelson

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=20200212003128.pieng2rlw7mykhvk@ltop.local \
    --to=luc.vanoostenryck@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=snelson@pensando.io \
    /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