This is the mail archive of the gdb-patches@sources.redhat.com 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]

RFA: Fix compile time warning in gdb/mips-tdep.c


Hi Guys,

  Whilst working on something else I noticed a warning from gcc about
  a variable in unpack_mips16() which was being used before it was
  initialised.  Looking at the code concerned it was obvious that it
  was wrong ('extension' is used without being initialised), but it
  was not obvious what the programmer actually intended.  Below is a
  patch that represent my best guess as to what should actually be
  happening.

  Is the patch right ?  Can I apply it ?

Cheers
	Nick


2000-08-07  Nick Clifton  <nickc@cygnus.com>

	* mips-tdep.c (unpack_mips16): Fix the initialisation of
	'extension' and 'extended'.

Index: gdb/mips-tdep.c
===================================================================
RCS file: /cvs/src//src/gdb/mips-tdep.c,v
retrieving revision 1.29
diff -p -r1.29 mips-tdep.c
*** mips-tdep.c	2000/07/30 01:48:26	1.29
--- mips-tdep.c	2000/08/07 23:53:03
*************** unpack_mips16 (CORE_ADDR pc,
*** 915,928 ****
    CORE_ADDR extpc;
    unsigned long extension;
    int extended;
!   extpc = (pc - 4) & ~0x01;	/* Extensions are 32 bit instructions */
!   /* Decrement to previous address and loose the 16bit mode flag */
!   /* return if the instruction was extendable, but not actually extended */
    extended = ((mips32_op (extension) == 30) ? 1 : 0);
!   if (extended)
!     {
!       extension = mips_fetch_instruction (extpc);
!     }
    switch (upk->fmt)
      {
      case itype:
--- 915,927 ----
    CORE_ADDR extpc;
    unsigned long extension;
    int extended;
!   
!   /* Decrement to previous address and loose the 16bit mode flag.  */
!   extpc = (pc - 4) & ~0x01;
!   /* Extensions are 32 bit instructions.  */
!   extension = mips_fetch_instruction (extpc);
    extended = ((mips32_op (extension) == 30) ? 1 : 0);
! 
    switch (upk->fmt)
      {
      case itype:

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