This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Code cleanup: svr4_default_sos


Hi,

it looked too complicated for what it does.

Checked in.

Including first a diff with -b FYI where one can see the real changes.


Thanks,
Jan


 static struct so_list *
 svr4_default_sos (void)
 {
   struct svr4_info *info = get_svr4_info ();
+  struct so_list *new;
 
-  struct so_list *head = NULL;
-  struct so_list **link_ptr = &head;
+  if (!info->debug_loader_offset_p)
+    return NULL;
 
-  if (info->debug_loader_offset_p)
-    {
-      struct so_list *new = XZALLOC (struct so_list);
+  new = XZALLOC (struct so_list);
 
       new->lm_info = xmalloc (sizeof (struct lm_info));
 
       /* Nothing will ever check the cached copy of the link
 	 map if we set l_addr.  */
       new->lm_info->l_addr = info->debug_loader_offset;
       new->lm_info->lm_addr = 0;
       new->lm_info->lm = NULL;
 
-      strncpy (new->so_name, info->debug_loader_name,
-	       SO_NAME_MAX_PATH_SIZE - 1);
+  strncpy (new->so_name, info->debug_loader_name, SO_NAME_MAX_PATH_SIZE - 1);
       new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
       strcpy (new->so_original_name, new->so_name);
 
-      *link_ptr = new;
-      link_ptr = &new->next;
-    }
-
-  return head;
+  return new;
 }



http://sourceware.org/ml/gdb-cvs/2011-10/msg00006.html

--- src/gdb/ChangeLog	2011/10/02 02:13:11	1.13368
+++ src/gdb/ChangeLog	2011/10/02 21:05:58	1.13369
@@ -1,3 +1,9 @@
+2011-10-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Code cleanup.
+	* solib-svr4.c (svr4_default_sos):  Remove variables head and link_ptr.
+	Rearrange the code for it.
+
 2011-10-02  Joel Brobecker  <brobecker@adacore.com>
 
 	* breakpoint.c (bkpt_print_recreate): Add call to
--- src/gdb/solib-svr4.c	2011/08/30 02:48:05	1.154
+++ src/gdb/solib-svr4.c	2011/10/02 21:05:59	1.155
@@ -949,32 +949,26 @@
 svr4_default_sos (void)
 {
   struct svr4_info *info = get_svr4_info ();
+  struct so_list *new;
 
-  struct so_list *head = NULL;
-  struct so_list **link_ptr = &head;
+  if (!info->debug_loader_offset_p)
+    return NULL;
 
-  if (info->debug_loader_offset_p)
-    {
-      struct so_list *new = XZALLOC (struct so_list);
+  new = XZALLOC (struct so_list);
 
-      new->lm_info = xmalloc (sizeof (struct lm_info));
+  new->lm_info = xmalloc (sizeof (struct lm_info));
 
-      /* Nothing will ever check the cached copy of the link
-	 map if we set l_addr.  */
-      new->lm_info->l_addr = info->debug_loader_offset;
-      new->lm_info->lm_addr = 0;
-      new->lm_info->lm = NULL;
-
-      strncpy (new->so_name, info->debug_loader_name,
-	       SO_NAME_MAX_PATH_SIZE - 1);
-      new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
-      strcpy (new->so_original_name, new->so_name);
+  /* Nothing will ever check the cached copy of the link
+     map if we set l_addr.  */
+  new->lm_info->l_addr = info->debug_loader_offset;
+  new->lm_info->lm_addr = 0;
+  new->lm_info->lm = NULL;
 
-      *link_ptr = new;
-      link_ptr = &new->next;
-    }
+  strncpy (new->so_name, info->debug_loader_name, SO_NAME_MAX_PATH_SIZE - 1);
+  new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
+  strcpy (new->so_original_name, new->so_name);
 
-  return head;
+  return new;
 }
 
 /* Implement the "current_sos" target_so_ops method.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]