This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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";	\
	  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]