]> git.puffer.fish Git - matthieu/frr.git/commitdiff
2004-11-19 David Young <dyoung@pobox.com>
authorajs <ajs>
Fri, 19 Nov 2004 23:40:16 +0000 (23:40 +0000)
committerajs <ajs>
Fri, 19 Nov 2004 23:40:16 +0000 (23:40 +0000)
* log.c: (safe_strerror) New function: safe wrapper for strerror.

lib/ChangeLog
lib/log.c
lib/log.h

index 06b46258b10bdbc5786024915a91940b85373704..75cf84498b8677cf449061a58defac13ba062d69 100644 (file)
@@ -1,3 +1,7 @@
+2004-11-19 David Young <dyoung@pobox.com>
+
+       * log.c: (safe_strerror) New function: safe wrapper for strerror.
+
 2004-11-19 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
 
        * sockopt.c: (setsockopt_so_recvbuf) Stop error message from being
index 375730f2263730cf135c22934089a3bf287c1b6e..b24dacd89f802db5679ea181961b2ec98e889c1c 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -498,3 +498,11 @@ mes_lookup (struct message *meslist, int max, int index)
     }
   return meslist[index].str;
 }
+
+/* Wrapper around strerror to handle case where it returns NULL. */
+const char *
+safe_strerror(int errnum)
+{
+  const char *s = strerror(errnum);
+  return (s != NULL) ? s : "Unknown error";
+}
index 9f6ec3bec4d18a47d45ccdb5fc413feef1f18ec1..b5dbdfe1c84b18afc40c8a4bf8e907463d1ccede 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -126,4 +126,7 @@ const char *mes_lookup (struct message *meslist, int max, int index);
 
 extern const char *zlog_priority[];
 
+/* Safe version of strerror -- never returns NULL. */
+extern const char *safe_strerror(int errnum);
+
 #endif /* _ZEBRA_LOG_H */