This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: kread() and NULL pointers
- From: Roland McGrath <roland at redhat dot com>
- To: Mike Mason <mmlnx at us dot ibm dot com>
- Cc: systemtap at sourceware dot org
- Date: Mon, 16 Jul 2007 16:52:35 -0700 (PDT)
- Subject: Re: kread() and NULL pointers
> Roland McGrath wrote:
> >> Does kread() generate an error if you pass it a NULL pointer?
> >
> > Yes. It's safely caught like all errors, but it only returns successfully
> > when given a valid pointer.
>
> So should the following generate an error? It doesn't. It just prints "ptr = 0" and exits.
>
> function test_addr:long () %{
> void *nullptr = NULL;
> THIS->__retvalue = (long) kread(&(nullptr));
> CATCH_DEREF_FAULT();
> %}
As noted, this is not kread(NULL). As to the question, CATCH_DEREF_FAULT
is the code that constitutes what "generate an error" means. kread is a
macro using deref, which does "goto deref_fault" for errors. And then:
#define CATCH_DEREF_FAULT() \
if (0) { \
deref_fault: \
CONTEXT->last_error = "pointer dereference fault"; \
}