Hello,

On 09/10/2012 03:09 PM, Enlightenment SVN wrote:
> Log:
> eina/module: Rephrase warnings message on module init.
>   
>   Thsi will also fail if the symbol is there but the init function just fails
>   to deliver EINA_TRUE. After to much digging and wondering why dlsymb and
>   dlopen don't behave Daniel was able to point out to me that this warning 
> also
>   gets shown if init fails.

I found more. Wrote a patch and attached it. Then I had an idea and
checked the documentation. From the documentation it sounds like
providing an init function with EINA_MODULE_INIT() is optional. The
current code (the check after dlsym()) seems to agree.

However, the WRN("") suggests that the code will and should fail if the
module initialization symbol is not found.

Either the log message or the documentation is wrong. I would guess it
is the log message because I actually spent time fixing the other
possibility.


Regards,
Daniel Willmann

From 056e2ce0d76205861351c78aca69b1ce56401362 Mon Sep 17 00:00:00 2001
From: Daniel Willmann <d.willm...@samsung.com>
Date: Mon, 10 Sep 2012 15:25:19 +0100
Subject: [PATCH] eina_module: Fix eina_module_load() error handling

dlsym() will return NULL if EINA_MODULE_INIT() is not used inside the
module. We don't need to check both initcall and *initcall. Err out
correctly and clarify the log message.

Signed-off-by: Daniel Willmann <d.willm...@samsung.com>
---
 trunk/eina/AUTHORS               |    1 +
 trunk/eina/ChangeLog             |    4 ++++
 trunk/eina/NEWS                  |   12 ++++++++++++
 trunk/eina/src/lib/eina_module.c |   14 ++++++++++----
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/trunk/eina/AUTHORS b/trunk/eina/AUTHORS
index ef0d3cc..5790825 100644
--- a/trunk/eina/AUTHORS
+++ b/trunk/eina/AUTHORS
@@ -25,3 +25,4 @@ Jonas M. Gastal <jgas...@profusion.mobi>
 Raphael Kubo da Costa <rak...@freebsd.org>
 J챕r척me Pinot <ngc...@gmail.com>
 Mike Blumenkrantz <michael.blumenkra...@gmail.com>
+Daniel Willmann <d.willm...@samsung.com>
diff --git a/trunk/eina/ChangeLog b/trunk/eina/ChangeLog
index b27fa05..40a018d 100644
--- a/trunk/eina/ChangeLog
+++ b/trunk/eina/ChangeLog
@@ -337,3 +337,7 @@
 
         * Fix EINA_INLIST_FOREACH_SAFE macro to work when inlist is not the
         first item in the struct.
+
+2012-09-10	Daniel Willmann
+        * Fix eina_module_load() error handling when EINA_MODULE_INIT() is not
+				used in the module
diff --git a/trunk/eina/NEWS b/trunk/eina/NEWS
index 2c364ce..e035187 100644
--- a/trunk/eina/NEWS
+++ b/trunk/eina/NEWS
@@ -1,3 +1,15 @@
+Eina 1.8.0
+Changes since Eina 1.2.0:
+-------------------------
+
+Additions:
+
+Fixes:
+    * Fix eina_module_load() error handling when EINA_MODULE_INIT() is not used
+      in the module
+
+Removal:
+
 Eina 1.7.0
 
 Changes since Eina 1.2.0:
diff --git a/trunk/eina/src/lib/eina_module.c b/trunk/eina/src/lib/eina_module.c
index 736df0d..7b04964 100644
--- a/trunk/eina/src/lib/eina_module.c
+++ b/trunk/eina/src/lib/eina_module.c
@@ -342,14 +342,20 @@ EAPI Eina_Bool eina_module_load(Eina_Module *m)
      }
 
    initcall = dlsym(dl_handle, EINA_MODULE_SYMBOL_INIT);
-   if ((!initcall) || (!(*initcall)))
-      goto ok;
+   if (!initcall)
+     {
+        WRN("could not find eina's entry symbol %s inside module %s",
+            EINA_MODULE_SYMBOL_INIT, m->file);
+        eina_error_set(EINA_ERROR_MODULE_INIT_FAILED);
+        dlclose(dl_handle);
+        return EINA_FALSE;
+     }
 
    if ((*initcall)() == EINA_TRUE)
       goto ok;
 
-   WRN("could not find eina's entry symbol %s inside module %s, or the init function failed",
-       EINA_MODULE_SYMBOL_INIT, m->file);
+   WRN("Initialization of module %s failed",
+       m->file);
    eina_error_set(EINA_ERROR_MODULE_INIT_FAILED);
    dlclose(dl_handle);
    return EINA_FALSE;
-- 
1.7.9.5


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to