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

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


The following commit(s) were added to refs/heads/releases/12.7 by this push:
     new 801805d4a2 binfmt/libelf: Fix return code
801805d4a2 is described below

commit 801805d4a2658ec7e3cb66a0813d6ba0b84d9938
Author: SPRESENSE <[email protected]>
AuthorDate: Fri Oct 11 11:31:30 2024 +0900

    binfmt/libelf: Fix return code
    
    Fix return code in case of error in loading constructor and destructor 
section.
    
    Detected by Codesonar 54667871, 54667873
---
 binfmt/libelf/libelf_ctors.c | 2 +-
 binfmt/libelf/libelf_dtors.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/binfmt/libelf/libelf_ctors.c b/binfmt/libelf/libelf_ctors.c
index 3b1834c20f..129f61cd99 100644
--- a/binfmt/libelf/libelf_ctors.c
+++ b/binfmt/libelf/libelf_ctors.c
@@ -99,7 +99,7 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
        */
 
       binfo("elf_findsection .ctors section failed: %d\n", ctoridx);
-      return ret == -ENOENT ? OK : ret;
+      return ctoridx == -ENOENT ? OK : ctoridx;
     }
 
   /* Now we can get a pointer to the .ctor section in the section header
diff --git a/binfmt/libelf/libelf_dtors.c b/binfmt/libelf/libelf_dtors.c
index 71c35280f6..8ec86982ff 100644
--- a/binfmt/libelf/libelf_dtors.c
+++ b/binfmt/libelf/libelf_dtors.c
@@ -100,7 +100,7 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
        */
 
       binfo("elf_findsection .dtors section failed: %d\n", dtoridx);
-      return ret == -ENOENT ? OK : ret;
+      return dtoridx == -ENOENT ? OK : dtoridx;
     }
 
   /* Now we can get a pointer to the .dtor section in the section header

Reply via email to