This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: [PATCH/RFC] NULL terminate mips dis options


Hello!

On Mon, Feb 10, 2003 at 10:14:29AM -0800, cgd@broadcom.com wrote:
> At Mon, 10 Feb 2003 10:40:47 +0000 (UTC), "Elias Athanasopoulos" wrote:
> > objdump --help may crash if mips_abi_choices[] and mips_arch_choices[] do
> > not end in a record with a NULL name. I verified this in a Linux i586 host
> > configured with --enable-targets=all --enable-64-bit-bfd, using gcc 3.3.
> 
> You should convert the uses of them in print_mips_disassembler_options
> to use ARRAY_SIZE as other uses do.  That would be the correct patch.

Thanx. I'm attaching a new patch. 

Regards,
Elias

opcodes/ChangeLog

2003-02-10  Elias Athanasopoulos  <elathan@phys.uoa.gr>

	* mip-dis.c (print_mips_disassembler_options): Make 'i' usnigned,
	use the size of mips_abi_choices, mips_arch_choices in loops.


===================================================================
RCS file: /home/anteater/bucvs/src/opcodes/mips-dis.c,v
retrieving revision 1.1
diff -bu -r1.1 /home/anteater/bucvs/src/opcodes/mips-dis.c
--- /home/anteater/bucvs/src/opcodes/mips-dis.c	2003/02/10 09:37:54	1.1
+++ /home/anteater/bucvs/src/opcodes/mips-dis.c	2003/02/10 19:07:29
@@ -1758,7 +1758,7 @@
 print_mips_disassembler_options (stream)
      FILE *stream;
 {
-  int i;
+  unsigned int i;
 
   fprintf (stream, _("\n\
 The following MIPS specific disassembler options are supported for use\n\
@@ -1793,14 +1793,14 @@
   fprintf (stream, _("\n\
   For the options above, the following values are supported for \"ABI\":\n\
    "));
-  for (i = 0; mips_abi_choices[i].name != NULL; i++)
+  for (i = 0; i < (sizeof (mips_abi_choices) / sizeof (mips_abi_choices[0])); i++)
     fprintf (stream, " %s", mips_abi_choices[i].name);
   fprintf (stream, _("\n"));
 
   fprintf (stream, _("\n\
   For the options above, The following values are supported for \"ARCH\":\n\
    "));
-  for (i = 0; mips_arch_choices[i].name != NULL; i++)
+  for (i = 0; i < (sizeof (mips_arch_choices) / sizeof (mips_arch_choices[0])); i++)
     if (*mips_arch_choices[i].name != '\0')
       fprintf (stream, " %s", mips_arch_choices[i].name);
   fprintf (stream, _("\n"));

	


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