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]

[commit] Fix broken decimal-float case of value_one


Hello,

the decimal floating point case of value_one was quite broken (a redundant
variable declaration caused the main result variable to be uninitialized,
the resulting -Wall warning was papered over instead of fixed, and the
wrong length was passed to decimal_from_integral).  I've reimplemented
this from scratch using decimal_from_string to in addition avoid use
of builtin types.

Tested on powerpc64-linux, committed to mainline.

Bye,
Ulrich

ChangeLog:

	* valops.c (value_one): Reimplement broken decimal-float case.

Index: gdb-head/gdb/valops.c
===================================================================
--- gdb-head.orig/gdb/valops.c
+++ gdb-head/gdb/valops.c
@@ -537,15 +537,12 @@ struct value *
 value_one (struct type *type, enum lval_type lv)
 {
   struct type *type1 = check_typedef (type);
-  struct value *val = NULL; /* avoid -Wall warning */
+  struct value *val;
 
   if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
     {
-      struct value *int_one = value_from_longest (builtin_type_int32, 1);
-      struct value *val;
       gdb_byte v[16];
-
-      decimal_from_integral (int_one, v, TYPE_LENGTH (builtin_type_int32));
+      decimal_from_string (v, TYPE_LENGTH (type), "1");
       val = value_from_decfloat (type, v);
     }
   else if (TYPE_CODE (type1) == TYPE_CODE_FLT)
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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