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]

[obv] Remove unreachable code at varobj_get_handle callers


Hi,

varobj_get_handle() already contains:
  if (cv == NULL)
    error (_("Variable object not found"));
  return cv->var;

so there is no need to check it also at the callers.  Checked in as obvious
(to simplify patch dependencies).

Regression tested on x86_64-unknown-linux-gnu.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2009-05/msg00158.html

gdb/
2009-05-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Remove already unreachable code.
	* varobj.c (varobj_get_handle): Fix comment when error is called.
	All callers updated.

--- src/gdb/varobj.c	2009/05/17 07:13:18	1.128
+++ src/gdb/varobj.c	2009/05/23 15:34:36	1.129
@@ -591,8 +591,8 @@
   return obj_name;
 }
 
-/* Given an "objname", returns the pointer to the corresponding varobj
-   or NULL if not found */
+/* Given an OBJNAME, returns the pointer to the corresponding varobj.  Call
+   error if OBJNAME cannot be found.  */
 
 struct varobj *
 varobj_get_handle (char *objname)
--- src/gdb/mi/mi-cmd-var.c	2009/01/03 05:57:57	1.54
+++ src/gdb/mi/mi-cmd-var.c	2009/05/23 15:34:36	1.55
@@ -185,9 +185,6 @@
 
   var = varobj_get_handle (name);
 
-  if (var == NULL)
-    error (_("mi_cmd_var_delete: Variable object not found."));
-
   numdel = varobj_delete (var, NULL, children_only_p);
 
   ui_out_field_int (uiout, "ndeleted", numdel);
@@ -233,9 +230,6 @@
   /* Get varobj handle, if a valid var obj name was specified */
   var = varobj_get_handle (argv[0]);
 
-  if (var == NULL)
-    error (_("mi_cmd_var_set_format: Variable object not found"));
-
   format = mi_parse_format (argv[1]);
   
   /* Set the format of VAR to given format */
@@ -258,8 +252,6 @@
     error (_("-var-set-format: Usage: NAME FROZEN_FLAG."));
 
   var = varobj_get_handle (argv[0]);
-  if (var == NULL)
-    error (_("Variable object not found"));
 
   if (strcmp (argv[1], "0") == 0)
     frozen = 0;
@@ -287,8 +279,6 @@
 
   /* Get varobj handle, if a valid var obj name was specified */
   var = varobj_get_handle (argv[0]);
-  if (var == NULL)
-    error (_("mi_cmd_var_show_format: Variable object not found"));
 
   format = varobj_get_display_format (var);
 
@@ -306,8 +296,6 @@
 
   /* Get varobj handle, if a valid var obj name was specified */
   var = varobj_get_handle (argv[0]);
-  if (var == NULL)
-    error (_("mi_cmd_var_info_num_children: Variable object not found"));
 
   ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
 }
@@ -378,8 +366,6 @@
     var = varobj_get_handle (argv[0]);
   else
     var = varobj_get_handle (argv[1]);
-  if (var == NULL)
-    error (_("Variable object not found"));
 
   children = varobj_list_children (var);
   ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children));
@@ -415,8 +401,6 @@
 
   /* Get varobj handle, if a valid var obj name was specified */
   var = varobj_get_handle (argv[0]);
-  if (var == NULL)
-    error (_("mi_cmd_var_info_type: Variable object not found"));
 
   ui_out_field_string (uiout, "type", varobj_get_type (var));
 }
@@ -432,8 +416,6 @@
 
   /* Get varobj handle, if a valid var obj name was specified.  */
   var = varobj_get_handle (argv[0]);
-  if (var == NULL)
-    error (_("Variable object not found"));
   
   path_expr = varobj_get_path_expr (var);
 
@@ -451,8 +433,6 @@
 
   /* Get varobj handle, if a valid var obj name was specified */
   var = varobj_get_handle (argv[0]);
-  if (var == NULL)
-    error (_("mi_cmd_var_info_expression: Variable object not found"));
 
   lang = varobj_get_language (var);
 
@@ -472,8 +452,6 @@
 
   /* Get varobj handle, if a valid var obj name was specified */
   var = varobj_get_handle (argv[0]);
-  if (var == NULL)
-    error (_("mi_cmd_var_show_attributes: Variable object not found"));
 
   attr = varobj_get_attributes (var);
   /* FIXME: define masks for attributes */
@@ -534,8 +512,6 @@
  
      /* Get varobj handle, if a valid var obj name was specified */
   var = varobj_get_handle (argv[optind]);
-  if (var == NULL)
-    error (_("Variable object not found"));
    
   if (formatFound)
     ui_out_field_string (uiout, "value", varobj_get_formatted_value (var, format));
@@ -554,8 +530,6 @@
 
   /* Get varobj handle, if a valid var obj name was specified */
   var = varobj_get_handle (argv[0]);
-  if (var == NULL)
-    error (_("mi_cmd_var_assign: Variable object not found"));
 
   if (!varobj_editable_p (var))
     error (_("mi_cmd_var_assign: Variable object is not editable"));
@@ -634,8 +608,6 @@
     {
       /* Get varobj handle, if a valid var obj name was specified */
       var = varobj_get_handle (name);
-      if (var == NULL)
-	error (_("mi_cmd_var_update: Variable object not found"));
 
       if (mi_version (uiout) <= 1)
         cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");


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