summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2010-05-23 12:39:27 +0200
committerAndreas Baumann <abaumann@yahoo.com>2010-05-23 12:39:27 +0200
commit08823730905d8dfefc8c8f1202dab5f28923968c (patch)
tree0e7843aadec10ed64907ed8ad25477245dea1c07
parent3b381609dddb8f4f9c3668681e4e475501b3f38f (diff)
downloadwolfbones-08823730905d8dfefc8c8f1202dab5f28923968c.tar.gz
wolfbones-08823730905d8dfefc8c8f1202dab5f28923968c.tar.bz2
better error handling in library loader
-rw-r--r--src/errors.c1
-rw-r--r--src/library/loader.c9
2 files changed, 6 insertions, 4 deletions
diff --git a/src/errors.c b/src/errors.c
index efd3f15..a453dbe 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -97,5 +97,6 @@ char *wolf_system_error_msg( char *buf, size_t buflen ) {
return buf;
#else
(void)strerror_r( errno, buf, buflen );
+ return buf;
#endif
}
diff --git a/src/library/loader.c b/src/library/loader.c
index 106df7f..93b9298 100644
--- a/src/library/loader.c
+++ b/src/library/loader.c
@@ -17,6 +17,8 @@
#include "library/loader.h"
+#include "errors.h"
+
#include "port/sys_internal.h"
#include "port/stdlib.h" /* for malloc, free */
@@ -61,7 +63,6 @@ wolf_library_p wolf_library_load( const char *name, wolf_error_t *error ) {
* also make up our mind how many flags we should "leak" to the application layer
*/
flags = RTLD_NOW | RTLD_LOCAL;
-
l->handle = dlopen( name, flags );
if( l->handle == NULL ) {
strncpy( l->errbuf, dlerror( ), INTERNAL_ERRBUF_SIZE );
@@ -72,7 +73,7 @@ wolf_library_p wolf_library_load( const char *name, wolf_error_t *error ) {
#if defined _WIN32
l->handle = LoadLibrary( name );
if( l->handle == NULL ) {
- strncpy( l->errbuf, "<TODO: GetLastError>", INTERNAL_ERRBUF_SIZE );
+ wolf_system_error_msg( l->errbuf, INTERNAL_ERRBUF_SIZE );
*error = WOLF_ERR_INTERNAL;
return l;
}
@@ -106,7 +107,7 @@ wolf_error_t wolf_library_unload( wolf_library_p l ) {
#if defined _WIN32
res = FreeLibrary( l->handle );
if( !res ) {
- strncpy( l->errbuf, "<TODO: GetLastError>", INTERNAL_ERRBUF_SIZE );
+ wolf_system_error_msg( l->errbuf, INTERNAL_ERRBUF_SIZE );
return WOLF_ERR_INTERNAL;
}
#else
@@ -144,7 +145,7 @@ WOLF_LIBRARY_FUNCPTR wolf_library_get_func( const wolf_library_p l, const char *
#if defined _WIN32
ret = GetProcAddress( l->handle, name );
if( ret == NULL ) {
- strncpy( l->errbuf, "<TODO: GetLastError>", INTERNAL_ERRBUF_SIZE );
+ wolf_system_error_msg( l->errbuf, INTERNAL_ERRBUF_SIZE );
*error = WOLF_ERR_INTERNAL;
return ret;
}