This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit db13ff2dd584b9c61e5c8ad4522534972c6b0ba5
Author: dongjiuzhu1 <[email protected]>
AuthorDate: Thu Oct 5 19:42:23 2023 +0800

    libs/libc: fix compile warning about modlib_depend when 
CONFIG_MODLIB_MAXDEPEND = 0
    
    modlib/modlib_symbols.c: In function ‘modlib_symcallback’:
    modlib/modlib_symbols.c:215:13: warning: implicit declaration of function 
‘modlib_depend’; did you mean ‘modlib_read’? [-Wimplicit-function-declaration]
      215 |       ret = modlib_depend(exportinfo->modp, modp);
          |             ^~~~~~~~~~~~~
          |             modlib_read
    
    Signed-off-by: dongjiuzhu1 <[email protected]>
---
 libs/libc/modlib/modlib_depend.c  | 11 ++++-------
 libs/libc/modlib/modlib_symbols.c |  5 +++--
 sched/module/mod_insmod.c         |  2 ++
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libs/libc/modlib/modlib_depend.c b/libs/libc/modlib/modlib_depend.c
index eaa453d007..0f7eaf40e3 100644
--- a/libs/libc/modlib/modlib_depend.c
+++ b/libs/libc/modlib/modlib_depend.c
@@ -31,6 +31,8 @@
 
 #include <nuttx/lib/modlib.h>
 
+#if CONFIG_MODLIB_MAXDEPEND > 0
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -55,7 +57,6 @@
 int modlib_depend(FAR struct module_s *importer,
                   FAR struct module_s *exporter)
 {
-#if CONFIG_MODLIB_MAXDEPEND > 0
   int freendx = -1;
   int i;
 
@@ -127,10 +128,6 @@ int modlib_depend(FAR struct module_s *importer,
 
   DEBUGPANIC();
   return -ENFILE;
-
-#else
-  return OK;
-#endif
 }
 
 /****************************************************************************
@@ -152,7 +149,6 @@ int modlib_depend(FAR struct module_s *importer,
 
 int modlib_undepend(FAR struct module_s *importer)
 {
-#if CONFIG_MODLIB_MAXDEPEND > 0
   FAR struct module_s *exporter;
   int i;
 
@@ -178,7 +174,8 @@ int modlib_undepend(FAR struct module_s *importer)
           importer->dependencies[i] = NULL;
         }
     }
-#endif
 
   return OK;
 }
+
+#endif
diff --git a/libs/libc/modlib/modlib_symbols.c 
b/libs/libc/modlib/modlib_symbols.c
index 6e4e59bc03..078e276d00 100644
--- a/libs/libc/modlib/modlib_symbols.c
+++ b/libs/libc/modlib/modlib_symbols.c
@@ -198,7 +198,6 @@ static int modlib_symcallback(FAR struct module_s *modp, 
FAR void *arg)
 {
   FAR struct mod_exportinfo_s *exportinfo = (FAR struct mod_exportinfo_s *)
                                             arg;
-  int ret;
 
   /* Check if this module exports a symbol of that name */
 
@@ -212,12 +211,14 @@ static int modlib_symcallback(FAR struct module_s *modp, 
FAR void *arg)
        * stop the traversal.
        */
 
-      ret = modlib_depend(exportinfo->modp, modp);
+#if CONFIG_MODLIB_MAXDEPEND > 0
+      int ret = modlib_depend(exportinfo->modp, modp);
       if (ret < 0)
         {
           berr("ERROR: modlib_depend failed: %d\n", ret);
           return ret;
         }
+#endif
 
       return SYM_FOUND;
     }
diff --git a/sched/module/mod_insmod.c b/sched/module/mod_insmod.c
index b8ad7443dc..86b0f017a5 100644
--- a/sched/module/mod_insmod.c
+++ b/sched/module/mod_insmod.c
@@ -282,7 +282,9 @@ FAR void *insmod(FAR const char *filename, FAR const char 
*modname)
 
 errout_with_load:
   modlib_unload(&loadinfo);
+#if CONFIG_MODLIB_MAXDEPEND > 0
   modlib_undepend(modp);
+#endif
 errout_with_registry_entry:
   kmm_free(modp);
 errout_with_loadinfo:

Reply via email to