linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Triplett <josh@freedesktop.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-sparse <linux-sparse@vger.kernel.org>,
	Philipp Reisner <philipp.reisner@linbit.com>
Subject: Re: [PATCH] allow context attribute on variables
Date: Thu, 24 Apr 2008 19:22:17 -0700	[thread overview]
Message-ID: <48114059.6090103@freedesktop.org> (raw)
In-Reply-To: <1208955351.31429.81.camel@johannes.berg>

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

Johannes Berg wrote:
> This patch makes it possible to add the context attribute on
> variables, to warn for example in this case:
> 
>     struct something {
>         int x __attribute__((context(L,1,1)));
>     };
> 
>     extern struct something *s;
> 
>     static void warn_access13(void)
>     {
>         s->x = 7;
>     }
> 
> This is achieved by translating the context attribute on
> variables that are loaded from/stored to into a context
> expression internally. A number of tests are included,
> including tests for a struct member (as above) and array
> accesses.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> ---
> I didn't see any need for distinguishing between rd/wr nor
> for a new attribute, so I just used the one we already have.
> 
> The exact_context() attribute is also allowed so we have the
> same max/no-max semantics as functions.
> 
> If read/write is necessary to distinguish (I don't see a use
> case) then we can do that fairly easily later.

I like the idea of matching the existing attributes as closely as
possible.  However, RCU provides a use case for distinguishing readers
and writers: you might have a variable that you can read if you hold
the RCU reader "lock", but you can only write if you hold a spinlock.

- Josh Triplett


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

  reply	other threads:[~2008-04-25  2:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-23 12:55 [PATCH] allow context attribute on variables Johannes Berg
2008-04-25  2:22 ` Josh Triplett [this message]
2008-04-26 15:50   ` Johannes Berg

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=48114059.6090103@freedesktop.org \
    --to=josh@freedesktop.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-sparse@vger.kernel.org \
    --cc=philipp.reisner@linbit.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).