diff options
author | Eugene Teo <eteo@redhat.com> | 2009-04-03 23:18:14 +0800 |
---|---|---|
committer | Eugene Teo <eteo@redhat.com> | 2009-04-03 23:18:14 +0800 |
commit | 08dc41a50c508544bc18d384a65a137056a98195 (patch) | |
tree | 94515f7982de2164e15d0d6ca6693d4746ee0727 | |
parent | 85cd50d2a532d78ae1b0281c4baea3c4af396e2b (diff) | |
download | systemtap-steved-08dc41a50c508544bc18d384a65a137056a98195.tar.gz systemtap-steved-08dc41a50c508544bc18d384a65a137056a98195.tar.xz systemtap-steved-08dc41a50c508544bc18d384a65a137056a98195.zip |
Improvements to errno tapset
This adds an errno_p() function that will return an absolute errno if it
is valid, or zero if it is not. It also simplifies the if statement in
the errno_str() function.
-rw-r--r-- | tapset/errno.stp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tapset/errno.stp b/tapset/errno.stp index eda9bff1..011ff7e2 100644 --- a/tapset/errno.stp +++ b/tapset/errno.stp @@ -345,12 +345,20 @@ static const int Maxerrno = sizeof(errlist)/sizeof(char *); function errno_str:string (err:long) %{ /* pure */ long e = THIS->err; - if (e < 0 && e > -Maxerrno && errlist[-e]) - strlcpy (THIS->__retvalue, errlist[-e], MAXSTRINGLEN); - else if (e > 0 && e < Maxerrno && errlist[e]) + e = (e > 0 ? e : -e); + if (e > 0 && e < Maxerrno && errlist[e]) strlcpy (THIS->__retvalue, errlist[e], MAXSTRINGLEN); %} +function errno_p:long (err:long) %{ /* pure */ + long e = THIS->err; + e = (e > 0 ? e : -e); + if (e > 0 && e < Maxerrno && errlist[e]) + THIS->__retvalue = e; + else + THIS->__retvalue = 0; +%} + %{ static long _stp_returnval(struct pt_regs *regs) { if (regs) { |