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] Code cleanup - constify struct lval_funcs


Hi,

checked in.  Modifying the vector for existing values should not be allowed.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2011-07/msg00136.html

--- src/gdb/ChangeLog	2011/07/14 04:46:42	1.13189
+++ src/gdb/ChangeLog	2011/07/14 15:00:15	1.13190
@@ -1,3 +1,21 @@
+2011-07-14  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Code cleanup - constify struct lval_funcs.
+	* dwarf2loc.c (pieced_value_funcs): Make it const.
+	* infrun.c (siginfo_value_funcs): Likewise.
+	* opencl-lang.c (opencl_value_funcs): Likewise.
+	* valops.c (value_assign, value_ind): Make the funcs variable const.
+	* value.c (struct value): Make location.computed.funcs target const.
+	Rearrange the comments.
+	(allocate_computed_value): Make the funcs parameter target const.
+	(value_computed_funcs): Return the funcs target const.
+	(value_free, value_copy, set_value_component_location): Make the funcs
+	variable const.
+	* value.h (allocate_computed_value): Make the funcs parameter target
+	const.
+	(value_computed_funcs): Return the funcs target const.
+	* windows-tdep.c (tlb_value_funcs): Make it const.
+
 2011-07-14  Hui Zhu  <teawater@gmail.com>
 
 	* remote.c (remote_get_trace_status): Initialize p.
--- src/gdb/dwarf2loc.c	2011/07/13 15:15:42	1.121
+++ src/gdb/dwarf2loc.c	2011/07/14 15:00:19	1.122
@@ -1051,7 +1051,7 @@
 }
 
 /* Functions for accessing a variable described by DW_OP_piece.  */
-static struct lval_funcs pieced_value_funcs = {
+static const struct lval_funcs pieced_value_funcs = {
   read_pieced_value,
   write_pieced_value,
   check_pieced_value_validity,
--- src/gdb/infrun.c	2011/06/23 15:08:01	1.494
+++ src/gdb/infrun.c	2011/07/14 15:00:19	1.495
@@ -6394,7 +6394,7 @@
     error (_("Unable to write siginfo"));
 }
 
-static struct lval_funcs siginfo_value_funcs =
+static const struct lval_funcs siginfo_value_funcs =
   {
     siginfo_value_read,
     siginfo_value_write
--- src/gdb/opencl-lang.c	2011/02/28 22:49:57	1.10
+++ src/gdb/opencl-lang.c	2011/07/14 15:00:20	1.11
@@ -354,7 +354,7 @@
     }
 }
 
-static struct lval_funcs opencl_value_funcs =
+static const struct lval_funcs opencl_value_funcs =
   {
     lval_func_read,
     lval_func_write,
--- src/gdb/valops.c	2011/06/30 19:29:54	1.281
+++ src/gdb/valops.c	2011/07/14 15:00:20	1.282
@@ -1377,7 +1377,7 @@
 
     case lval_computed:
       {
-	struct lval_funcs *funcs = value_computed_funcs (toval);
+	const struct lval_funcs *funcs = value_computed_funcs (toval);
 
 	funcs->write (toval, fromval);
       }
@@ -1740,7 +1740,7 @@
 
   if (VALUE_LVAL (arg1) == lval_computed)
     {
-      struct lval_funcs *funcs = value_computed_funcs (arg1);
+      const struct lval_funcs *funcs = value_computed_funcs (arg1);
 
       if (funcs->indirect)
 	{
--- src/gdb/value.c	2011/07/12 21:16:48	1.143
+++ src/gdb/value.c	2011/07/14 15:00:20	1.144
@@ -194,8 +194,11 @@
        for them to use.  */
     struct
     {
-      struct lval_funcs *funcs; /* Functions to call.  */
-      void *closure;            /* Closure for those functions to use.  */
+      /* Functions to call.  */
+      const struct lval_funcs *funcs;
+
+      /* Closure for those functions to use.  */
+      void *closure;
     } computed;
   } location;
 
@@ -716,7 +719,7 @@
 
 struct value *
 allocate_computed_value (struct type *type,
-                         struct lval_funcs *funcs,
+                         const struct lval_funcs *funcs,
                          void *closure)
 {
   struct value *v = allocate_value_lazy (type);
@@ -1059,7 +1062,7 @@
   value->pointed_to_offset = val;
 }
 
-struct lval_funcs *
+const struct lval_funcs *
 value_computed_funcs (struct value *v)
 {
   gdb_assert (VALUE_LVAL (v) == lval_computed);
@@ -1175,7 +1178,7 @@
 
       if (VALUE_LVAL (val) == lval_computed)
 	{
-	  struct lval_funcs *funcs = val->location.computed.funcs;
+	  const struct lval_funcs *funcs = val->location.computed.funcs;
 
 	  if (funcs->free_closure)
 	    funcs->free_closure (val);
@@ -1319,7 +1322,7 @@
     value_incref (val->parent);
   if (VALUE_LVAL (val) == lval_computed)
     {
-      struct lval_funcs *funcs = val->location.computed.funcs;
+      const struct lval_funcs *funcs = val->location.computed.funcs;
 
       if (funcs->copy_closure)
         val->location.computed.closure = funcs->copy_closure (val);
@@ -1359,7 +1362,7 @@
   component->location = whole->location;
   if (whole->lval == lval_computed)
     {
-      struct lval_funcs *funcs = whole->location.computed.funcs;
+      const struct lval_funcs *funcs = whole->location.computed.funcs;
 
       if (funcs->copy_closure)
         component->location.computed.closure = funcs->copy_closure (whole);
--- src/gdb/value.h	2011/07/12 21:16:48	1.182
+++ src/gdb/value.h	2011/07/14 15:00:20	1.183
@@ -204,14 +204,14 @@
    and closure CLOSURE.  */
 
 extern struct value *allocate_computed_value (struct type *type,
-                                              struct lval_funcs *funcs,
-                                              void *closure);
+					      const struct lval_funcs *funcs,
+					      void *closure);
 
 extern struct value *allocate_optimized_out_value (struct type *type);
 
 /* If VALUE is lval_computed, return its lval_funcs structure.  */
 
-extern struct lval_funcs *value_computed_funcs (struct value *value);
+extern const struct lval_funcs *value_computed_funcs (struct value *value);
 
 /* If VALUE is lval_computed, return its closure.  The meaning of the
    returned value depends on the functions VALUE uses.  */
--- src/gdb/windows-tdep.c	2011/04/19 18:04:07	1.11
+++ src/gdb/windows-tdep.c	2011/07/14 15:00:20	1.12
@@ -256,7 +256,7 @@
   error (_("Impossible to change the Thread Local Base"));
 }
 
-static struct lval_funcs tlb_value_funcs =
+static const struct lval_funcs tlb_value_funcs =
   {
     tlb_value_read,
     tlb_value_write


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