summaryrefslogtreecommitdiffstats
path: root/cpukit/libdl/rtl-error.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2017-03-28 17:23:05 +1100
committerChris Johns <chrisj@rtems.org>2017-04-04 13:26:01 +1000
commitd2e31f70c12f6363cef79ffad781df6ec0acdfb5 (patch)
tree3ebf30b9233ccfbff397ef245f3b74f1f2bd69dd /cpukit/libdl/rtl-error.c
parentdosfs: Fix file name search (diff)
downloadrtems-d2e31f70c12f6363cef79ffad781df6ec0acdfb5.tar.bz2
libdl: Back port C++ exception throw and catch from 4.12.
Closes #2956.
Diffstat (limited to 'cpukit/libdl/rtl-error.c')
-rw-r--r--cpukit/libdl/rtl-error.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/cpukit/libdl/rtl-error.c b/cpukit/libdl/rtl-error.c
index 3251fa5392..5ec4b26ef7 100644
--- a/cpukit/libdl/rtl-error.c
+++ b/cpukit/libdl/rtl-error.c
@@ -17,6 +17,7 @@
#include "config.h"
#endif
+#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
@@ -39,9 +40,15 @@ int
rtems_rtl_get_error (char* message, size_t max_message)
{
rtems_rtl_data_t* rtl = rtems_rtl_lock ();
- int last_errno = rtl->last_errno;
- strncpy (message, rtl->last_error, sizeof (rtl->last_error));
- rtems_rtl_unlock ();
- return last_errno;
-}
+ if (rtl != NULL)
+ {
+ int last_errno = rtl->last_errno;
+ strncpy (message, rtl->last_error, sizeof (rtl->last_error));
+ rtems_rtl_unlock ();
+ return last_errno;
+ }
+ strncpy(message, "RTL init error", max_message);
+
+ return EIO;
+}