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]

[PATCH] 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.
---
 tapset/errno.stp |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tapset/errno.stp b/tapset/errno.stp
index eda9bff..a1a1a72 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) {
-- 
1.6.0.6


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