gdb: fix format string warnings in f-lang.c
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 19 Nov 2020 16:31:34 +0000 (11:31 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 19 Nov 2020 16:32:26 +0000 (11:32 -0500)
I get a bunch of these warnings when compiling for i386 (32-bit):

      CXX    f-lang.o
    /home/simark/src/binutils-gdb/gdb/f-lang.c: In function 'value* fortran_value_subarray(value*, expression*, int*, int, noside)':
    /home/simark/src/binutils-gdb/gdb/f-lang.c:453:48: error: format '%ld' expects argument of type 'long int', but argument 2 has type 'LONGEST' {aka 'long long int'} [-Werror=format=]
      453 |        debug_printf ("|   |   |-> Low bound: %ld\n", lb);
          |                                              ~~^     ~~
          |                                                |     |
          |                                                |     LONGEST {aka long long int}
          |                                                long int
          |                                              %lld

Fix them by using plongest/pulongest.

gdb/ChangeLog:

* f-lang.c (fortran_value_subarray): Use plongest/pulongest.

Change-Id: I666ead5593653d5a1a3dab2ffdc72942c928c7d2

gdb/ChangeLog
gdb/f-lang.c

index d0a0031a538d35aff46f6aaf6ef64763ed0d801b..5b4844250239f65e953d117d50b7b4372a40a37e 100644 (file)
@@ -1,3 +1,7 @@
+2020-11-19  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * f-lang.c (fortran_value_subarray): Use plongest/pulongest.
+
 2020-11-19  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * gdbarch.sh (read_core_file_mappings): Remove `other` parameter
index 3c6d5a50882f971894bf18d161292856d9bb3d99..4171c96c8a9fa392d10b1d3a3bc36f30700e21ca 100644 (file)
@@ -450,21 +450,21 @@ fortran_value_subarray (struct value *array, struct expression *exp,
              std::string str = type_to_string (dim_type);
              debug_printf ("|   |-> Type: %s\n", str.c_str ());
              debug_printf ("|   |-> Array:\n");
-             debug_printf ("|   |   |-> Low bound: %ld\n", lb);
-             debug_printf ("|   |   |-> High bound: %ld\n", ub);
-             debug_printf ("|   |   |-> Bit stride: %ld\n", sd);
-             debug_printf ("|   |   |-> Byte stride: %ld\n", sd / 8);
-             debug_printf ("|   |   |-> Type size: %ld\n",
-                           TYPE_LENGTH (dim_type));
-             debug_printf ("|   |   '-> Target type size: %ld\n",
-                           TYPE_LENGTH (target_type));
+             debug_printf ("|   |   |-> Low bound: %s\n", plongest (lb));
+             debug_printf ("|   |   |-> High bound: %s\n", plongest (ub));
+             debug_printf ("|   |   |-> Bit stride: %s\n", plongest (sd));
+             debug_printf ("|   |   |-> Byte stride: %s\n", plongest (sd / 8));
+             debug_printf ("|   |   |-> Type size: %s\n",
+                           pulongest (TYPE_LENGTH (dim_type)));
+             debug_printf ("|   |   '-> Target type size: %s\n",
+                           pulongest (TYPE_LENGTH (target_type)));
              debug_printf ("|   |-> Accessing:\n");
-             debug_printf ("|   |   |-> Low bound: %ld\n",
-                           low);
-             debug_printf ("|   |   |-> High bound: %ld\n",
-                           high);
-             debug_printf ("|   |   '-> Element stride: %ld\n",
-                           stride);
+             debug_printf ("|   |   |-> Low bound: %s\n",
+                           plongest (low));
+             debug_printf ("|   |   |-> High bound: %s\n",
+                           plongest (high));
+             debug_printf ("|   |   '-> Element stride: %s\n",
+                           plongest (stride));
            }
 
          /* Check the user hasn't asked for something invalid.  */
@@ -506,13 +506,17 @@ fortran_value_subarray (struct value *array, struct expression *exp,
          if (fortran_array_slicing_debug)
            {
              debug_printf ("|   '-> Results:\n");
-             debug_printf ("|       |-> Offset = %ld\n", offset);
-             debug_printf ("|       |-> Elements = %ld\n", e_count);
-             debug_printf ("|       |-> Low bound = %ld\n", new_low);
-             debug_printf ("|       |-> High bound = %ld\n", new_high);
-             debug_printf ("|       |-> Byte stride = %ld\n", new_stride);
-             debug_printf ("|       |-> Last element = %ld\n", last_elem);
-             debug_printf ("|       |-> Remainder = %ld\n", remainder);
+             debug_printf ("|       |-> Offset = %s\n", plongest (offset));
+             debug_printf ("|       |-> Elements = %s\n", plongest (e_count));
+             debug_printf ("|       |-> Low bound = %s\n", plongest (new_low));
+             debug_printf ("|       |-> High bound = %s\n",
+                           plongest (new_high));
+             debug_printf ("|       |-> Byte stride = %s\n",
+                           plongest (new_stride));
+             debug_printf ("|       |-> Last element = %s\n",
+                           plongest (last_elem));
+             debug_printf ("|       |-> Remainder = %s\n",
+                           plongest (remainder));
              debug_printf ("|       '-> Contiguous = %s\n",
                            (is_dim_contiguous ? "Yes" : "No"));
            }
@@ -548,14 +552,16 @@ fortran_value_subarray (struct value *array, struct expression *exp,
              std::string str = type_to_string (dim_type);
              debug_printf ("|   |-> Type: %s\n", str.c_str ());
              debug_printf ("|   |-> Array:\n");
-             debug_printf ("|   |   |-> Low bound: %ld\n", lb);
-             debug_printf ("|   |   |-> High bound: %ld\n", ub);
-             debug_printf ("|   |   |-> Byte stride: %ld\n", sd);
-             debug_printf ("|   |   |-> Type size: %ld\n", TYPE_LENGTH (dim_type));
-             debug_printf ("|   |   '-> Target type size: %ld\n",
-                           TYPE_LENGTH (target_type));
+             debug_printf ("|   |   |-> Low bound: %s\n", plongest (lb));
+             debug_printf ("|   |   |-> High bound: %s\n", plongest (ub));
+             debug_printf ("|   |   |-> Byte stride: %s\n", plongest (sd));
+             debug_printf ("|   |   |-> Type size: %s\n",
+                           pulongest (TYPE_LENGTH (dim_type)));
+             debug_printf ("|   |   '-> Target type size: %s\n",
+                           pulongest (TYPE_LENGTH (target_type)));
              debug_printf ("|   '-> Accessing:\n");
-             debug_printf ("|       '-> Index: %ld\n", index);
+             debug_printf ("|       '-> Index: %s\n",
+                           plongest (index));
            }
 
          /* If the array has actual content then check the index is in
@@ -612,7 +618,8 @@ fortran_value_subarray (struct value *array, struct expression *exp,
       debug_printf ("'-> Final result:\n");
       debug_printf ("    |-> Type: %s\n",
                    type_to_string (array_slice_type).c_str ());
-      debug_printf ("    |-> Total offset: %ld\n", total_offset);
+      debug_printf ("    |-> Total offset: %s\n",
+                   plongest (total_offset));
       debug_printf ("    |-> Base address: %s\n",
                    core_addr_to_string (value_address (array)));
       debug_printf ("    '-> Contiguous = %s\n",