[3/3] x86: limit data passed to i386_dis_printf()

Message ID b3511736-584c-6c99-9046-331a18c60417@suse.com
State Unresolved
Headers
Series x86: further disassembler tweaks |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Jan Beulich April 24, 2023, 7:35 a.m. UTC
  The function doesn't use "ins" for other than retrieving "info". Remove
a thus pointless level of indirection.
  

Patch

--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -114,7 +114,7 @@  static bool MOVSXD_Fixup (instr_info *,
 static bool DistinctDest_Fixup (instr_info *, int, int);
 static bool PREFETCHI_Fixup (instr_info *, int, int);
 
-static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const instr_info *,
+static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const disassemble_info *,
 						enum disassembler_style,
 						const char *, ...);
 
@@ -359,12 +359,12 @@  fetch_error (const instr_info *ins)
     name = prefix_name (ins->address_mode, priv->the_buffer[0],
 			priv->orig_sizeflag);
   if (name != NULL)
-    i386_dis_printf (ins, dis_style_mnemonic, "%s", name);
+    i386_dis_printf (ins->info, dis_style_mnemonic, "%s", name);
   else
     {
       /* Just print the first byte as a .byte instruction.  */
-      i386_dis_printf (ins, dis_style_assembler_directive, ".byte ");
-      i386_dis_printf (ins, dis_style_immediate, "%#x",
+      i386_dis_printf (ins->info, dis_style_assembler_directive, ".byte ");
+      i386_dis_printf (ins->info, dis_style_immediate, "%#x",
 		       (unsigned int) priv->the_buffer[0]);
     }
 
@@ -9528,7 +9528,7 @@  oappend_register (instr_info *ins, const
    used in the next fprintf_styled_func call.  */
 
 static void ATTRIBUTE_PRINTF_3
-i386_dis_printf (const instr_info *ins, enum disassembler_style style,
+i386_dis_printf (const disassemble_info *info, enum disassembler_style style,
 		 const char *fmt, ...)
 {
   va_list ap;
@@ -9569,9 +9569,8 @@  i386_dis_printf (const instr_info *ins,
 	{
 	  /* Output content between our START position and CURR.  */
 	  int len = curr - start;
-	  int n = (*ins->info->fprintf_styled_func) (ins->info->stream,
-						     curr_style,
-						     "%.*s", len, start);
+	  int n = (*info->fprintf_styled_func) (info->stream, curr_style,
+						"%.*s", len, start);
 	  if (n < 0)
 	    break;
 
@@ -9722,7 +9721,7 @@  print_insn (bfd_vma pc, disassemble_info
 
   if (ins.address_mode == mode_64bit && sizeof (bfd_vma) < 8)
     {
-      i386_dis_printf (&ins, dis_style_text, _("64-bit address is disabled"));
+      i386_dis_printf (info, dis_style_text, _("64-bit address is disabled"));
       return -1;
     }
 
@@ -9767,7 +9766,7 @@  print_insn (bfd_vma pc, disassemble_info
       for (i = 0;
 	   i < (int) ARRAY_SIZE (ins.all_prefixes) && ins.all_prefixes[i];
 	   i++)
-	i386_dis_printf (&ins, dis_style_mnemonic, "%s%s",
+	i386_dis_printf (info, dis_style_mnemonic, "%s%s",
 			 (i == 0 ? "" : " "),
 			 prefix_name (ins.address_mode, ins.all_prefixes[i],
 				      sizeflag));
@@ -9790,10 +9789,10 @@  print_insn (bfd_vma pc, disassemble_info
       /* Handle ins.prefixes before fwait.  */
       for (i = 0; i < ins.fwait_prefix && ins.all_prefixes[i];
 	   i++)
-	i386_dis_printf (&ins, dis_style_mnemonic, "%s ",
+	i386_dis_printf (info, dis_style_mnemonic, "%s ",
 			 prefix_name (ins.address_mode, ins.all_prefixes[i],
 				      sizeflag));
-      i386_dis_printf (&ins, dis_style_mnemonic, "fwait");
+      i386_dis_printf (info, dis_style_mnemonic, "fwait");
       return i + 1;
     }
 
@@ -9939,14 +9938,14 @@  print_insn (bfd_vma pc, disassemble_info
      are all 0s in inverted form.  */
   if (ins.need_vex && ins.vex.register_specifier != 0)
     {
-      i386_dis_printf (&ins, dis_style_text, "(bad)");
+      i386_dis_printf (info, dis_style_text, "(bad)");
       return ins.end_codep - priv.the_buffer;
     }
 
   /* If EVEX.z is set, there must be an actual mask register in use.  */
   if (ins.vex.zeroing && ins.vex.mask_register_specifier == 0)
     {
-      i386_dis_printf (&ins, dis_style_text, "(bad)");
+      i386_dis_printf (info, dis_style_text, "(bad)");
       return ins.end_codep - priv.the_buffer;
     }
 
@@ -9957,7 +9956,7 @@  print_insn (bfd_vma pc, disassemble_info
 	 the encoding invalid.  Most other PREFIX_OPCODE rules still apply.  */
       if (ins.need_vex ? !ins.vex.prefix : !(ins.prefixes & PREFIX_DATA))
 	{
-	  i386_dis_printf (&ins, dis_style_text, "(bad)");
+	  i386_dis_printf (info, dis_style_text, "(bad)");
 	  return ins.end_codep - priv.the_buffer;
 	}
       ins.used_prefixes |= PREFIX_DATA;
@@ -9984,7 +9983,7 @@  print_insn (bfd_vma pc, disassemble_info
 	  || (ins.vex.evex && dp->prefix_requirement != PREFIX_DATA
 	      && !ins.vex.w != !(ins.used_prefixes & PREFIX_DATA)))
 	{
-	  i386_dis_printf (&ins, dis_style_text, "(bad)");
+	  i386_dis_printf (info, dis_style_text, "(bad)");
 	  return ins.end_codep - priv.the_buffer;
 	}
       break;
@@ -10035,13 +10034,13 @@  print_insn (bfd_vma pc, disassemble_info
 	if (name == NULL)
 	  abort ();
 	prefix_length += strlen (name) + 1;
-	i386_dis_printf (&ins, dis_style_mnemonic, "%s ", name);
+	i386_dis_printf (info, dis_style_mnemonic, "%s ", name);
       }
 
   /* Check maximum code length.  */
   if ((ins.codep - ins.start_codep) > MAX_CODE_LENGTH)
     {
-      i386_dis_printf (&ins, dis_style_text, "(bad)");
+      i386_dis_printf (info, dis_style_text, "(bad)");
       return MAX_CODE_LENGTH;
     }
 
@@ -10065,7 +10064,7 @@  print_insn (bfd_vma pc, disassemble_info
     i = 0;
 
   /* Print the instruction mnemonic along with any trailing whitespace.  */
-  i386_dis_printf (&ins, dis_style_mnemonic, "%s%*s", ins.obuf, i, "");
+  i386_dis_printf (info, dis_style_mnemonic, "%s%*s", ins.obuf, i, "");
 
   /* The enter and bound instructions are printed with operands in the same
      order as the intel book; everything else is printed in reverse order.  */
@@ -10120,7 +10119,7 @@  print_insn (bfd_vma pc, disassemble_info
 	    break;
 	  }
 	if (needcomma)
-	  i386_dis_printf (&ins, dis_style_text, ",");
+	  i386_dis_printf (info, dis_style_text, ",");
 	if (ins.op_index[i] != -1 && !ins.op_riprel[i])
 	  {
 	    bfd_vma target = (bfd_vma) ins.op_address[ins.op_index[i]];
@@ -10136,14 +10135,14 @@  print_insn (bfd_vma pc, disassemble_info
 	    (*info->print_address_func) (target, info);
 	  }
 	else
-	  i386_dis_printf (&ins, dis_style_text, "%s", op_txt[i]);
+	  i386_dis_printf (info, dis_style_text, "%s", op_txt[i]);
 	needcomma = 1;
       }
 
   for (i = 0; i < MAX_OPERANDS; i++)
     if (ins.op_index[i] != -1 && ins.op_riprel[i])
       {
-	i386_dis_printf (&ins, dis_style_comment_start, "        # ");
+	i386_dis_printf (info, dis_style_comment_start, "        # ");
 	(*info->print_address_func)
 	  ((bfd_vma)(ins.start_pc + (ins.codep - ins.start_codep)
 		     + ins.op_address[ins.op_index[i]]),