You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/03/26 07:51:44 UTC

[incubator-nuttx] branch master updated: libelf: Appease nxstyle complaints

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/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 8ad9d1e  libelf: Appease nxstyle complaints
8ad9d1e is described below

commit 8ad9d1e0b4804f416f8e9d7578e82b9b20633e35
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Mar 26 15:54:27 2020 +0900

    libelf: Appease nxstyle complaints
    
    Also, fix a minor typo.
---
 binfmt/libelf/libelf_addrenv.c  | 11 ++++++-----
 binfmt/libelf/libelf_bind.c     | 22 ++++++++++++----------
 binfmt/libelf/libelf_ctors.c    | 13 +++++++------
 binfmt/libelf/libelf_dtors.c    | 13 +++++++------
 binfmt/libelf/libelf_init.c     | 14 +++++++-------
 binfmt/libelf/libelf_load.c     |  6 ++++--
 binfmt/libelf/libelf_sections.c |  3 ++-
 binfmt/libelf/libelf_symbols.c  |  8 ++++----
 binfmt/libelf/libelf_verify.c   |  3 ++-
 9 files changed, 51 insertions(+), 42 deletions(-)

diff --git a/binfmt/libelf/libelf_addrenv.c b/binfmt/libelf/libelf_addrenv.c
index 4df7a3d..d05fd44 100644
--- a/binfmt/libelf/libelf_addrenv.c
+++ b/binfmt/libelf/libelf_addrenv.c
@@ -68,11 +68,12 @@
  *
  * Description:
  *   Allocate memory for the ELF image (textalloc and dataalloc). If
- *   CONFIG_ARCH_ADDRENV=n, textalloc will be allocated using kmm_zalloc() and
- *   dataalloc will be a offset from textalloc.  If CONFIG_ARCH_ADDRENV-y, then
- *   textalloc and dataalloc will be allocated using up_addrenv_create().  In
- *   either case, there will be a unique instance of textalloc and dataalloc
- *   (and stack) for each instance of a process.
+ *   CONFIG_ARCH_ADDRENV=n, textalloc will be allocated using kmm_zalloc()
+ *   and dataalloc will be a offset from textalloc.  If
+ *   CONFIG_ARCH_ADDRENV=y, then textalloc and dataalloc will be allocated
+ *   using up_addrenv_create().  In either case, there will be a unique
+ *   instance of textalloc and dataalloc (and stack) for each instance of a
+ *   process.
  *
  * Input Parameters:
  *   loadinfo - Load state information
diff --git a/binfmt/libelf/libelf_bind.c b/binfmt/libelf/libelf_bind.c
index 6eb500a..4daac9a 100644
--- a/binfmt/libelf/libelf_bind.c
+++ b/binfmt/libelf/libelf_bind.c
@@ -56,8 +56,8 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to be
- * defined or CONFIG_ELF_DUMPBUFFER does nothing.
+/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to
+ * be defined or CONFIG_ELF_DUMPBUFFER does nothing.
  */
 
 #if !defined(CONFIG_DEBUG_INFO) || !defined (CONFIG_DEBUG_BINFMT)
@@ -228,8 +228,9 @@ static int elf_relocate(FAR struct elf_loadinfo_s *loadinfo, int relidx,
                              CONFIG_ELF_RELOCATION_BUFFERCOUNT);
           if (ret < 0)
             {
-              berr("Section %d reloc %d: Failed to read relocation entry: %d\n",
-                    relidx, i, ret);
+              berr("Section %d reloc %d: "
+                   "Failed to read relocation entry: %d\n",
+                   relidx, i, ret);
               break;
             }
         }
@@ -296,8 +297,8 @@ static int elf_relocate(FAR struct elf_loadinfo_s *loadinfo, int relidx,
           ret = elf_symvalue(loadinfo, sym, exports, nexports);
           if (ret < 0)
             {
-              /* The special error -ESRCH is returned only in one condition:  The
-               * symbol has no name.
+              /* The special error -ESRCH is returned only in one condition:
+               * The symbol has no name.
                *
                * There are a few relocations for a few architectures that do
                * no depend upon a named symbol.  We don't know if that is the
@@ -411,8 +412,9 @@ static int elf_relocateadd(FAR struct elf_loadinfo_s *loadinfo, int relidx,
                               CONFIG_ELF_RELOCATION_BUFFERCOUNT);
           if (ret < 0)
             {
-              berr("Section %d reloc %d: Failed to read relocation entry: %d\n",
-                    relidx, i, ret);
+              berr("Section %d reloc %d: "
+                   "Failed to read relocation entry: %d\n",
+                   relidx, i, ret);
               break;
             }
         }
@@ -479,8 +481,8 @@ static int elf_relocateadd(FAR struct elf_loadinfo_s *loadinfo, int relidx,
           ret = elf_symvalue(loadinfo, sym, exports, nexports);
           if (ret < 0)
             {
-              /* The special error -ESRCH is returned only in one condition:  The
-               * symbol has no name.
+              /* The special error -ESRCH is returned only in one condition:
+               * The symbol has no name.
                *
                * There are a few relocations for a few architectures that do
                * no depend upon a named symbol.  We don't know if that is the
diff --git a/binfmt/libelf/libelf_ctors.c b/binfmt/libelf/libelf_ctors.c
index 3715e3c..b5d5c4f 100644
--- a/binfmt/libelf/libelf_ctors.c
+++ b/binfmt/libelf/libelf_ctors.c
@@ -110,8 +110,8 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
   /* Find the index to the section named ".ctors."  NOTE:  On old ABI system,
    * .ctors is the name of the section containing the list of constructors;
    * On newer systems, the similar section is called .init_array.  It is
-   * expected that the linker script will force the section name to be ".ctors"
-   * in either case.
+   * expected that the linker script will force the section name to be
+   * ".ctors" in either case.
    */
 
   ctoridx = elf_findsection(loadinfo, ".ctors");
@@ -189,7 +189,8 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
 
           for (i = 0; i < loadinfo->nctors; i++)
             {
-              FAR uintptr_t *ptr = (uintptr_t *)((FAR void *)(&loadinfo->ctors)[i]);
+              FAR uintptr_t *ptr = (uintptr_t *)
+                   ((FAR void *)(&loadinfo->ctors)[i]);
 
               binfo("ctor %d: %08lx + %08lx = %08lx\n",
                     i, *ptr, (unsigned long)loadinfo->textalloc,
@@ -200,9 +201,9 @@ int elf_loadctors(FAR struct elf_loadinfo_s *loadinfo)
         }
       else
         {
-          /* Save the address of the .ctors (actually, .init_array) where it was
-           * loaded into memory.  Since the .ctors lie in allocated memory, they
-           * will be relocated via the normal mechanism.
+          /* Save the address of the .ctors (actually, .init_array) where
+           * it was loaded into memory.  Since the .ctors lie in allocated
+           * memory, they will be relocated via the normal mechanism.
            */
 
           loadinfo->ctors = (binfmt_ctor_t *)shdr->sh_addr;
diff --git a/binfmt/libelf/libelf_dtors.c b/binfmt/libelf/libelf_dtors.c
index 62cb343..f7004d1 100644
--- a/binfmt/libelf/libelf_dtors.c
+++ b/binfmt/libelf/libelf_dtors.c
@@ -110,8 +110,8 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
   /* Find the index to the section named ".dtors."  NOTE:  On old ABI system,
    * .dtors is the name of the section containing the list of destructors;
    * On newer systems, the similar section is called .fini_array.  It is
-   * expected that the linker script will force the section name to be ".dtors"
-   * in either case.
+   * expected that the linker script will force the section name to be
+   * ".dtors" in either case.
    */
 
   dtoridx = elf_findsection(loadinfo, ".dtors");
@@ -189,7 +189,8 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
 
           for (i = 0; i < loadinfo->ndtors; i++)
             {
-              FAR uintptr_t *ptr = (uintptr_t *)((FAR void *)(&loadinfo->dtors)[i]);
+              FAR uintptr_t *ptr = (uintptr_t *)
+                  ((FAR void *)(&loadinfo->dtors)[i]);
 
               binfo("dtor %d: %08lx + %08lx = %08lx\n",
                     i, *ptr, (unsigned long)loadinfo->textalloc,
@@ -200,9 +201,9 @@ int elf_loaddtors(FAR struct elf_loadinfo_s *loadinfo)
         }
       else
         {
-          /* Save the address of the .dtors (actually, .init_array) where it was
-           * loaded into memory.  Since the .dtors lie in allocated memory, they
-           * will be relocated via the normal mechanism.
+          /* Save the address of the .dtors (actually, .init_array) where
+           * it was loaded into memory.  Since the .dtors lie in allocated
+           * memory, they will be relocated via the normal mechanism.
            */
 
           loadinfo->dtors = (binfmt_dtor_t *)shdr->sh_addr;
diff --git a/binfmt/libelf/libelf_init.c b/binfmt/libelf/libelf_init.c
index 81bf664..063faea 100644
--- a/binfmt/libelf/libelf_init.c
+++ b/binfmt/libelf/libelf_init.c
@@ -56,8 +56,8 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to be
- * defined or CONFIG_ELF_DUMPBUFFER does nothing.
+/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_BINFMT have to
+ * be defined or CONFIG_ELF_DUMPBUFFER does nothing.
  */
 
 #if !defined(CONFIG_DEBUG_INFO) || !defined (CONFIG_DEBUG_BINFMT)
@@ -189,11 +189,11 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo)
   ret = elf_verifyheader(&loadinfo->ehdr);
   if (ret < 0)
     {
-      /* This may not be an error because we will be called to attempt loading
-       * EVERY binary.  If elf_verifyheader() does not recognize the ELF header,
-       * it will -ENOEXEC which simply informs the system that the file is not an
-       * ELF file.  elf_verifyheader() will return other errors if the ELF header
-       * is not correctly formed.
+      /* This may not be an error because we will be called to attempt
+       * loading EVERY binary.  If elf_verifyheader() does not recognize
+       * the ELF header, it will -ENOEXEC which simply informs the system
+       * that the file is not an ELF file.  elf_verifyheader() will return
+       * other errors if the ELF header is not correctly formed.
        */
 
       berr("Bad ELF header: %d\n", ret);
diff --git a/binfmt/libelf/libelf_load.c b/binfmt/libelf/libelf_load.c
index e3bff22..5eaf8d3 100644
--- a/binfmt/libelf/libelf_load.c
+++ b/binfmt/libelf/libelf_load.c
@@ -346,11 +346,13 @@ int elf_load(FAR struct elf_loadinfo_s *loadinfo)
   exidx = elf_findsection(loadinfo, CONFIG_ELF_EXIDX_SECTNAME);
   if (exidx < 0)
     {
-      binfo("elf_findsection: Exception Index section not found: %d\n", exidx);
+      binfo("elf_findsection: Exception Index section not found: %d\n",
+            exidx);
     }
   else
     {
-      up_init_exidx(loadinfo->shdr[exidx].sh_addr, loadinfo->shdr[exidx].sh_size);
+      up_init_exidx(loadinfo->shdr[exidx].sh_addr,
+                    loadinfo->shdr[exidx].sh_size);
     }
 #endif
 
diff --git a/binfmt/libelf/libelf_sections.c b/binfmt/libelf/libelf_sections.c
index a5fe2f1..ac0c9dc 100644
--- a/binfmt/libelf/libelf_sections.c
+++ b/binfmt/libelf/libelf_sections.c
@@ -201,7 +201,8 @@ int elf_loadshdrs(FAR struct elf_loadinfo_s *loadinfo)
 
   /* Get the total size of the section header table */
 
-  shdrsize = (size_t)loadinfo->ehdr.e_shentsize * (size_t)loadinfo->ehdr.e_shnum;
+  shdrsize = (size_t)loadinfo->ehdr.e_shentsize *
+             (size_t)loadinfo->ehdr.e_shnum;
   if (loadinfo->ehdr.e_shoff + shdrsize > loadinfo->filelen)
     {
       berr("Insufficient space in file for section header table\n");
diff --git a/binfmt/libelf/libelf_symbols.c b/binfmt/libelf/libelf_symbols.c
index 695fefa..373bd06 100644
--- a/binfmt/libelf/libelf_symbols.c
+++ b/binfmt/libelf/libelf_symbols.c
@@ -71,8 +71,8 @@
  *   0 (OK) is returned on success and a negated errno is returned on
  *   failure.
  *
- *   EINVAL - There is something inconsistent in the symbol table (should only
- *            happen if the file is corrupted).
+ *   EINVAL - There is something inconsistent in the symbol table (should
+ *            only happen if the file is corrupted).
  *   ESRCH - Symbol has no name
  *
  ****************************************************************************/
@@ -252,8 +252,8 @@ int elf_readsym(FAR struct elf_loadinfo_s *loadinfo, int index,
  *   0 (OK) is returned on success and a negated errno is returned on
  *   failure.
  *
- *   EINVAL - There is something inconsistent in the symbol table (should only
- *            happen if the file is corrupted).
+ *   EINVAL - There is something inconsistent in the symbol table (should
+ *            only happen if the file is corrupted).
  *   ENOSYS - Symbol lies in common
  *   ESRCH  - Symbol has no name
  *   ENOENT - Symbol undefined and not provided via a symbol table
diff --git a/binfmt/libelf/libelf_verify.c b/binfmt/libelf/libelf_verify.c
index 186d212..2a03e55 100644
--- a/binfmt/libelf/libelf_verify.c
+++ b/binfmt/libelf/libelf_verify.c
@@ -97,7 +97,8 @@ int elf_verifyheader(FAR const Elf_Ehdr *ehdr)
   if (memcmp(ehdr->e_ident, g_elfmagic, EI_MAGIC_SIZE) != 0)
     {
       binfo("Not ELF magic {%02x, %02x, %02x, %02x}\n",
-            ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2], ehdr->e_ident[3]);
+            ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2],
+            ehdr->e_ident[3]);
       return -ENOEXEC;
     }