diff mbox series

elf: avoid jumping over a needed declaration

Message ID xnfro3lq29.fsf@greed.delorie.com
State New
Headers show
Series elf: avoid jumping over a needed declaration | expand

Commit Message

DJ Delorie Nov. 7, 2024, 2:45 a.m. UTC
The declaration of found_other_class could be jumped
over via the goto just above it, but the code jumped
to uses found_other_class.  Move the declaration
up a bit to ensure it's properly declared and initialized.

Comments

Florian Weimer Nov. 7, 2024, 7:50 a.m. UTC | #1
* DJ Delorie:

> The declaration of found_other_class could be jumped
> over via the goto just above it, but the code jumped
> to uses found_other_class.  Move the declaration
> up a bit to ensure it's properly declared and initialized.
>
> diff --git a/elf/dl-load.c b/elf/dl-load.c
> index ac8e217a7f..335b34c56d 100644
> --- a/elf/dl-load.c
> +++ b/elf/dl-load.c
> @@ -1931,6 +1931,9 @@ _dl_map_object (struct link_map *loader, const char *name,
>  		      : "\nfile=%s [%lu];  dynamically loaded by %s [%lu]\n",
>  		      name, nsid, DSO_FILENAME (loader->l_name), loader->l_ns);
>  
> +  /* Will be true if we found a DSO which is of the other ELF class.  */
> +  bool found_other_class = false;
> +
>  #ifdef SHARED
>    /* Give the auditing libraries a chance to change the name before we
>       try anything.  */
> @@ -1948,9 +1951,6 @@ _dl_map_object (struct link_map *loader, const char *name,
>      }
>  #endif
>  
> -  /* Will be true if we found a DSO which is of the other ELF class.  */
> -  bool found_other_class = false;
> -
>    if (strchr (name, '/') == NULL)
>      {
>        /* Search for NAME in several places.  */

Looks okay, and this one isn't a false positive.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian
diff mbox series

Patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index ac8e217a7f..335b34c56d 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1931,6 +1931,9 @@  _dl_map_object (struct link_map *loader, const char *name,
 		      : "\nfile=%s [%lu];  dynamically loaded by %s [%lu]\n",
 		      name, nsid, DSO_FILENAME (loader->l_name), loader->l_ns);
 
+  /* Will be true if we found a DSO which is of the other ELF class.  */
+  bool found_other_class = false;
+
 #ifdef SHARED
   /* Give the auditing libraries a chance to change the name before we
      try anything.  */
@@ -1948,9 +1951,6 @@  _dl_map_object (struct link_map *loader, const char *name,
     }
 #endif
 
-  /* Will be true if we found a DSO which is of the other ELF class.  */
-  bool found_other_class = false;
-
   if (strchr (name, '/') == NULL)
     {
       /* Search for NAME in several places.  */