public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>,
	David Howells <dhowells@redhat.com>,
	keyrings@linux-nfs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Keys: Add possessor permissions to keys
Date: Thu, 22 Sep 2005 11:00:24 +0100	[thread overview]
Message-ID: <27186.1127383224@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0509211154210.2553@g5.osdl.org>

Linus Torvalds <torvalds@osdl.org> wrote:

> > hrmph.  Of course it's a reasonable trick from a performance and
> > convenience and resource consumption POV.  But it's a new idiom and the
> > threshold for new idioms is non-zero.  We use it in struct page, but struct
> > page is special.
> 
> Hmm.. I don't feel it is that new, but maybe that's because I've used that 
> trick in other places. I think it's pretty common in a "type-safe C" way, 
> and it should probably be encouraged. A unique pointer type for special 
> usages, that you can't dereference even by mistake..

It's something that C isn't particularly good at. C++ is better at this as you
can define a class and overload the -> operator and the unary * operator if
you're feeling particularly evil or adventurous. But C it is...

> But adding a few comments might certainly be worth it. If only to teach 
> others the trick.

Maybe there should be some naming convention for quasi-pointers like this? I
could typedef it, for instance, and hang comments appropriate to its nature of
the typedef. Perhaps:

	typedef struct __key_ref_with_possession_attribute *key_ref;

And then give its accessor functions capital letters to make them stand out,
though that might give the false impression that they're actually preprocessor
macros.

Or perhaps I should rename two of the functions:

	key_mkref() -> construct_key_ref()
	key_deref() -> convert_key_ref_to_ptr() or extract_key_ptr()

Would that serve in lieu of commenting every time I use these things?

David

  reply	other threads:[~2005-09-22 10:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5378.1127211442@warthog.cambridge.redhat.com>
2005-09-21 14:48 ` [PATCH] Keys: Add possessor permissions to keys David Howells
2005-09-21 15:05   ` Linus Torvalds
2005-09-21 15:44     ` David Howells
2005-09-21 17:15   ` Andrew Morton
2005-09-21 17:47     ` Trond Myklebust
2005-09-21 18:36       ` David Howells
2005-09-21 18:29     ` David Howells
2005-09-21 18:45       ` Andrew Morton
2005-09-21 18:56         ` Linus Torvalds
2005-09-22 10:00           ` David Howells [this message]
2005-10-03  4:43       ` [Keyrings] " Kyle Moffett
2005-09-21 18:33   ` [PATCH] Keys: Add possessor permissions to keys [try #2] David Howells
2005-09-28 16:03     ` [PATCH] Keys: Add possessor permissions to keys [try #3] David Howells
2005-09-21 19:23   ` [PATCH] Keys: Add possessor permissions to keys James Morris

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=27186.1127383224@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=keyrings@linux-nfs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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