]> sourceware.org Git - systemtap.git/commitdiff
Improvements to errno tapset
authorEugene Teo <eteo@redhat.com>
Fri, 3 Apr 2009 15:18:14 +0000 (23:18 +0800)
committerEugene Teo <eteo@redhat.com>
Fri, 3 Apr 2009 15:18:14 +0000 (23:18 +0800)
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.

tapset/errno.stp

index eda9bff122309b0c6cea3deec569b5e1c6b6fa04..011ff7e29cb11a09ae0fcaf15a4ed45f21559c26 100644 (file)
@@ -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) {
This page took 0.029638 seconds and 5 git commands to generate.