mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Ingo Oeser <ioe-lkml@rameria.de>,
	linux-kernel@vger.kernel.org, arjanv@redhat.com,
	Dave Jones <davej@redhat.com>, Jeff Garzik <jgarzik@pobox.com>,
	viro@parcelfarce.linux.theplanet.co.uk,
	bfennema@falcon.csc.calpoly.edu
Subject: Re: Fix UDF-FS potentially dereferencing null
Date: 22 Apr 2004 17:29:42 -0300	[thread overview]
Message-ID: <or3c6vhi2x.fsf@free.redhat.lsd.ic.unicamp.br> (raw)
In-Reply-To: <Pine.LNX.4.58.0404171009320.3947@ppc970.osdl.org>

On Apr 17, 2004, Linus Torvalds <torvalds@osdl.org> wrote:

> On Sat, 17 Apr 2004, Ingo Oeser wrote:
>> 
>> Or even call the attribute "nonnull", because this is a very obvious
>> naming, even to non-native English readers.

> I did that at first, but decided that what I really wanted was "safe".

> "nonnull" is nice for avoiding the NULL check, but it's useless for 
> anything else.

> "safe" to my mind means that not only is it not NULL, it's also safe to 
> dereference early (ie "prefetchable"), which has a lot of meaning for the 
> back-end.

And how far back can this go?

Consider, for example:

inline int foo(int *safe p) {
  return *p;
}

int bar(int *p) {
  if (p)
    return foo(p);
  return -1;
}

I suppose you'd like a compiler to remember the point at which the
pointer became safe, and avoid prefetching it before the test.  So
it's not exactly total freedom to reschedule the load.

Still, this sounds like something that might be useful, especially on
platforms that don't support (non-trapping) prefetching.

GCC's nonnull attribute is indeed useless for these purposes.  Even
though the docs say it could be used to optimize away a NULL test, its
syntax is far too cumbersome, since you apply the nonnull attribute to
the function, not to its argument, which makes it unusable for
non-argument variables.

-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

  reply	other threads:[~2004-04-22 20:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-16 21:41 Dave Jones
2004-04-16 21:58 ` Linus Torvalds
2004-04-16 22:00 ` viro
2004-04-16 23:13   ` Jeff Garzik
2004-04-16 23:18     ` Dave Jones
2004-04-16 23:34       ` viro
2004-04-17  0:44       ` Linus Torvalds
2004-04-17  9:50         ` Arjan van de Ven
2004-04-17 10:42           ` Arjan van de Ven
2004-04-17 11:12           ` Ingo Oeser
2004-04-17 17:14             ` Linus Torvalds
2004-04-22 20:29               ` Alexandre Oliva [this message]
2004-04-22 20:56                 ` Linus Torvalds
2004-04-23 14:00                   ` Alexandre Oliva

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=or3c6vhi2x.fsf@free.redhat.lsd.ic.unicamp.br \
    --to=aoliva@redhat.com \
    --cc=arjanv@redhat.com \
    --cc=bfennema@falcon.csc.calpoly.edu \
    --cc=davej@redhat.com \
    --cc=ioe-lkml@rameria.de \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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

all inboxes | Powered by JetHome®