[Open-FCoE] [PATCH] Bug # 6 - Modification to sa_log_err function

Balaji Biradar biradar.balaji at gmail.com
Mon Apr 7 06:38:26 UTC 2008


Patch for Bug#6 is modified to work with both the versions of strerror_r
function (XSI-compliant & GNU).

---

 usr/common/libsa/src/sa_log.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)


diff --git a/usr/common/libsa/src/sa_log.c b/usr/common/libsa/src/sa_log.c
index f7c5ce1..d4a78b8 100644
--- a/usr/common/libsa/src/sa_log.c
+++ b/usr/common/libsa/src/sa_log.c
@@ -101,14 +101,24 @@ void sa_log_func(const char *func, const char *format,
...)
 void sa_log_err(int error, const char *func, const char *format, ...)
 {
       va_list arg;
-       char buf[SA_LOG_BUF_LEN];
+       char buf[SA_LOG_BUF_LEN]="unknown",*error_str;
+
+       error_str = (char*) strerror_r(error, buf, sizeof(buf));
+
+       /*
+       *Handling multiple versions of strerror_r. XSI compliant version
returns
+       *status (int) and GNU version returns error string (char *).
+       */
+
+       if (error_str == (char *) -1)
+               error_str = "unknown";
+       else if (error_str == NULL)
+               error_str = buf;

       if (func) {
-               sa_log("%s: error %d %s", func, error,
-                      strerror_r(error, buf, sizeof(buf)));
+               sa_log("%s: error %d %s", func, error,error_str);
       } else {
-               sa_log("error %d %s", error,
-                      strerror_r(error, buf, sizeof(buf)));
+               sa_log("error %d %s", error,error_str);
       }
       va_start(arg, format);
       sa_log_va(func, format, arg);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.open-fcoe.org/pipermail/fcoe-devel/attachments/20080407/9d2c4c37/attachment.html>


More information about the devel mailing list