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]

[1/5] FYI: change value_print to return void


I'm checking this in.

Nothing uses value_print's return value.
This changes it to return void.

Tom

b/gdb/ChangeLog:
2012-03-01  Tom Tromey  <tromey@redhat.com>

	* value.h (value_print): Return void.
	* valprint.c (value_print): Return void.
	* p-valprint.c (pascal_value_print): Return void.
	* p-lang.h (pascal_value_print): Return void.
	* language.h (struct language_defn) <la_value_print>: Return
	void.
	* language.c (unk_lang_value_print): Return void.
	* jv-valprint.c (java_value_print): Return void.
	* jv-lang.h (java_value_print): Return void.
	* f-valprint.c (c_value_print): Don't declare.
	Include c-lang.h.
	* c-valprint.c (c_value_print): Return void.
	* c-lang.h (c_value_print): Return void.
	* ada-valprint.c (ada_value_print): Return void.
	* ada-lang.h (ada_value_print): Return void.

>From 74b168ece0b6f9f65e1465e32de5d669f8d19708 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Fri, 3 Feb 2012 08:31:47 -0700
Subject: [PATCH 1/5] change value_print to return void

---
 gdb/ChangeLog      |   18 ++++++++++++++++++
 gdb/ada-lang.h     |    4 ++--
 gdb/ada-valprint.c |   10 +++++-----
 gdb/c-lang.h       |    4 ++--
 gdb/c-valprint.c   |   30 ++++++++++++++++--------------
 gdb/f-lang.c       |    6 +-----
 gdb/jv-lang.h      |    4 ++--
 gdb/jv-valprint.c  |    8 ++++----
 gdb/language.c     |    6 +++---
 gdb/language.h     |    4 ++--
 gdb/p-lang.h       |    4 ++--
 gdb/p-valprint.c   |    4 ++--
 gdb/valprint.c     |   13 +++++--------
 gdb/value.h        |    4 ++--
 14 files changed, 66 insertions(+), 53 deletions(-)

diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index fd7b0df..76dca32 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -169,8 +169,8 @@ extern int ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
 			  const struct value *,
 			  const struct value_print_options *);
 
-extern int ada_value_print (struct value *, struct ui_file *,
-			    const struct value_print_options *);
+extern void ada_value_print (struct value *, struct ui_file *,
+			     const struct value_print_options *);
 
                                 /* Defined in ada-lang.c */
 
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 5cb2f98..32b85f2 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -963,7 +963,7 @@ print_variant_part (struct type *type, int field_num,
        comma_needed, outer_type, outer_offset);
 }
 
-int
+void
 ada_value_print (struct value *val0, struct ui_file *stream,
 		 const struct value_print_options *options)
 {
@@ -1003,14 +1003,14 @@ ada_value_print (struct value *val0, struct ui_file *stream,
       fprintf_filtered (stream, "(");
       type_print (type, "", stream, -1);
       fprintf_filtered (stream, ") (...?)");
-      return 0;
+      return;
     }
 
   opts = *options;
   opts.deref_ref = 1;
-  return (val_print (type, value_contents_for_printing (val),
-		     value_embedded_offset (val), address,
-		     stream, 0, val, &opts, current_language));
+  val_print (type, value_contents_for_printing (val),
+	     value_embedded_offset (val), address,
+	     stream, 0, val, &opts, current_language);
 }
 
 static void
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index e8c632f..74574e2 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -77,8 +77,8 @@ extern int c_val_print (struct type *, const gdb_byte *,
 			const struct value *,
 			const struct value_print_options *);
 
-extern int c_value_print (struct value *, struct ui_file *,
-			  const struct value_print_options *);
+extern void c_value_print (struct value *, struct ui_file *,
+			   const struct value_print_options *);
 
 /* These are in c-lang.c: */
 
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 0054dc0..98901ce 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -644,7 +644,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
   return (0);
 }
 
-int
+void
 c_value_print (struct value *val, struct ui_file *stream, 
 	       const struct value_print_options *options)
 {
@@ -748,10 +748,11 @@ c_value_print (struct value *val, struct ui_file *stream,
 			    full ? "" : _(" [incomplete object]"));
 	  /* Print out object: enclosing type is same as real_type if
 	     full.  */
-	  return val_print (value_enclosing_type (val),
-			    value_contents_for_printing (val), 0,
-			    value_address (val), stream, 0,
-			    val, &opts, current_language);
+	  val_print (value_enclosing_type (val),
+		     value_contents_for_printing (val), 0,
+		     value_address (val), stream, 0,
+		     val, &opts, current_language);
+	  return;
           /* Note: When we look up RTTI entries, we don't get any
              information on const or volatile attributes.  */
 	}
@@ -760,17 +761,18 @@ c_value_print (struct value *val, struct ui_file *stream,
 	  /* No RTTI information, so let's do our best.  */
 	  fprintf_filtered (stream, "(%s ?) ",
 			    TYPE_NAME (value_enclosing_type (val)));
-	  return val_print (value_enclosing_type (val),
-			    value_contents_for_printing (val), 0,
-			    value_address (val), stream, 0,
-			    val, &opts, current_language);
+	  val_print (value_enclosing_type (val),
+		     value_contents_for_printing (val), 0,
+		     value_address (val), stream, 0,
+		     val, &opts, current_language);
+	  return;
 	}
       /* Otherwise, we end up at the return outside this "if".  */
     }
 
-  return val_print (val_type, value_contents_for_printing (val),
-		    value_embedded_offset (val),
-		    value_address (val),
-		    stream, 0,
-		    val, &opts, current_language);
+  val_print (val_type, value_contents_for_printing (val),
+	     value_embedded_offset (val),
+	     value_address (val),
+	     stream, 0,
+	     val, &opts, current_language);
 }
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 805b143..ef78bc3 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -33,6 +33,7 @@
 #include "value.h"
 #include "cp-support.h"
 #include "charset.h"
+#include "c-lang.h"
 
 
 /* Following is dubious stuff that had been in the xcoff reader.  */
@@ -268,11 +269,6 @@ f_make_symbol_completion_list (char *text, char *word)
   return default_make_symbol_completion_list_break_on (text, word, ":");
 }
 
-/* This is declared in c-lang.h but it is silly to import that file for what
-   is already just a hack.  */
-extern int c_value_print (struct value *, struct ui_file *,
-			  const struct value_print_options *);
-
 const struct language_defn f_language_defn =
 {
   "fortran",
diff --git a/gdb/jv-lang.h b/gdb/jv-lang.h
index d061096..ffe25bf 100644
--- a/gdb/jv-lang.h
+++ b/gdb/jv-lang.h
@@ -47,8 +47,8 @@ extern int java_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
 			   const struct value *,
 			   const struct value_print_options *);
 
-extern int java_value_print (struct value *, struct ui_file *,
-			     const struct value_print_options *);
+extern void java_value_print (struct value *, struct ui_file *,
+			      const struct value_print_options *);
 
 extern struct value *java_class_from_object (struct value *);
 
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 7f6e931..125e611 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -33,7 +33,7 @@
 
 /* Local functions */
 
-int
+void
 java_value_print (struct value *val, struct ui_file *stream, 
 		  const struct value_print_options *options)
 {
@@ -205,7 +205,7 @@ java_value_print (struct value *val, struct ui_file *stream,
 
       fprintf_filtered (stream, "}");
 
-      return 0;
+      return;
     }
 
   /* If it's type String, print it.  */
@@ -245,12 +245,12 @@ java_value_print (struct value *val, struct ui_file *stream,
       val_print_string (char_type, NULL, data + boffset, count, stream,
 			options);
 
-      return 0;
+      return;
     }
 
   opts = *options;
   opts.deref_ref = 1;
-  return common_val_print (val, stream, 0, &opts, current_language);
+  common_val_print (val, stream, 0, &opts, current_language);
 }
 
 /* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
diff --git a/gdb/language.c b/gdb/language.c
index 49ba21a..f312a16 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -66,8 +66,8 @@ static void unk_lang_printchar (int c, struct type *type,
 static void unk_lang_print_type (struct type *, const char *, struct ui_file *,
 				 int, int);
 
-static int unk_lang_value_print (struct value *, struct ui_file *,
-				 const struct value_print_options *);
+static void unk_lang_value_print (struct value *, struct ui_file *,
+				  const struct value_print_options *);
 
 static CORE_ADDR unk_lang_trampoline (struct frame_info *, CORE_ADDR pc);
 
@@ -858,7 +858,7 @@ unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
 	   "function unk_lang_val_print called."));
 }
 
-static int
+static void
 unk_lang_value_print (struct value *val, struct ui_file *stream,
 		      const struct value_print_options *options)
 {
diff --git a/gdb/language.h b/gdb/language.h
index a47a44d..3156f27 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -249,8 +249,8 @@ struct language_defn
 
     /* Print a top-level value using syntax appropriate for this language.  */
 
-    int (*la_value_print) (struct value *, struct ui_file *,
-			   const struct value_print_options *);
+    void (*la_value_print) (struct value *, struct ui_file *,
+			    const struct value_print_options *);
 
     /* PC is possibly an unknown languages trampoline.
        If that PC falls in a trampoline belonging to this language,
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index 180c544..5b0691b 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -40,8 +40,8 @@ extern int pascal_val_print (struct type *, const gdb_byte *, int,
 			     const struct value *,
 			     const struct value_print_options *);
 
-extern int pascal_value_print (struct value *, struct ui_file *,
-			       const struct value_print_options *);
+extern void pascal_value_print (struct value *, struct ui_file *,
+				const struct value_print_options *);
 
 extern void pascal_type_print_method_args (const char *, const char *,
 					   struct ui_file *);
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 39eff10..6b22754 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -579,7 +579,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
   return (0);
 }
 
-int
+void
 pascal_value_print (struct value *val, struct ui_file *stream,
 		    const struct value_print_options *options)
 {
@@ -613,7 +613,7 @@ pascal_value_print (struct value *val, struct ui_file *stream,
 	  fprintf_filtered (stream, ") ");
 	}
     }
-  return common_val_print (val, stream, 0, &opts, current_language);
+  common_val_print (val, stream, 0, &opts, current_language);
 }
 
 
diff --git a/gdb/valprint.c b/gdb/valprint.c
index a348cf4..9ff0f27 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -460,17 +460,14 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
 }
 
 /* Print on stream STREAM the value VAL according to OPTIONS.  The value
-   is printed using the current_language syntax.
+   is printed using the current_language syntax.  */
 
-   If the object printed is a string pointer, return the number of string
-   bytes printed.  */
-
-int
+void
 value_print (struct value *val, struct ui_file *stream,
 	     const struct value_print_options *options)
 {
   if (!value_check_printable (val, stream, options))
-    return 0;
+    return;
 
   if (!options->raw)
     {
@@ -482,10 +479,10 @@ value_print (struct value *val, struct ui_file *stream,
 					val, options, current_language);
 
       if (r)
-	return r;
+	return;
     }
 
-  return LA_VALUE_PRINT (val, stream, options);
+  LA_VALUE_PRINT (val, stream, options);
 }
 
 /* Called by various <lang>_val_print routines to print
diff --git a/gdb/value.h b/gdb/value.h
index d4c4a83..9706e70 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -808,8 +808,8 @@ extern void print_floating (const gdb_byte *valaddr, struct type *type,
 extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
 				    struct ui_file *stream);
 
-extern int value_print (struct value *val, struct ui_file *stream,
-			const struct value_print_options *options);
+extern void value_print (struct value *val, struct ui_file *stream,
+			 const struct value_print_options *options);
 
 extern void value_print_array_elements (struct value *val,
 					struct ui_file *stream, int format,
-- 
1.7.7.6


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