[PATCH] Fix mips-tfile.c compilation warnings

Roger Sayle roger@www.eyesopen.com
Sat Feb 8 15:11:00 GMT 2003


The following patch fixes several compilation warnings in mips-tfile.c
that occur during bootstrap of alphaev67-dec-osf5.1 causing it to fail
with the recent -Werror changes.  Several of these warnings should also
occur on mips-sgi-irix6.5, so I'm guessing this patch should also help
the bootstrap there.

In the patch below I've decided to make file_offset and max_file_offset
"unsigned long" and cast all comparisons againt them to that type.  This
avoids the system-dependent signedness of off_t and the fields of FDR,
and not introduce new warnings on any platform [fingers crossed].

The following patch has been tested during a clean bootstrap of
alphaev67-dec-osf5.1, where these changes silence the warnings and
allow the bootstrap to proceed past this failure.  Unfortunately,
the bootstrap fails yet again even later.  Hopefully the changes
are almost "obvious", so the lack of regression testing shouldn't
be too much of a concern.

Ok for mainline?


2003-02-08  Roger Sayle  <roger@eyesopen.com>

	* mips-tfile.c (init_file): Add missing initializers in the
	"#ifdef __alpha" case.
	(file_offset, max_file_offset): Declare as unsigned long.
	(write_varray): Cast to "unsigned long" in comparisons against
	either file_offset or max_file_offset.
	(write_object): Likewise.
	(read_seek): Likewise.
	(copy_object): Likewise. Declare ifd as "int" to match its use
	in add_ext_symbol, and avoid signed/unsigned conditional warning.


Index: mips-tfile.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/mips-tfile.c,v
retrieving revision 1.49
diff -c -3 -p -r1.49 mips-tfile.c
*** mips-tfile.c	7 Feb 2003 22:50:09 -0000	1.49
--- mips-tfile.c	8 Feb 2003 05:05:56 -0000
***************
*** 2,9 ****
     contain debugging information specified by the GNU compiler
     in the form of comments (the mips assembler does not support
     assembly access to debug information).
!    Copyright (C) 1991, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001
!    Free Software Foundation, Inc.
     Contributed by Michael Meissner (meissner@cygnus.com).

  This file is part of GCC.
--- 2,9 ----
     contain debugging information specified by the GNU compiler
     in the form of comments (the mips assembler does not support
     assembly access to debug information).
!    Copyright (C) 1991, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
!    2002, 2003 Free Software Foundation, Inc.
     Contributed by Michael Meissner (meissner@cygnus.com).

  This file is part of GCC.
*************** static efdr_t init_file =
*** 1099,1104 ****
--- 1099,1106 ----
      0,			/* fTrim:	whether the symbol table was trimmed */
      GLEVEL_2,		/* glevel:	level this file was compiled with */
      0,			/* reserved:	reserved for future use */
+     0,			/* cbLineOffset: byte offset from header for this file ln's */
+     0,			/* cbLine:	size of lines for this file */
  #else
      0,			/* adr:		memory address of beginning of file */
      0,			/* rss:		file name (of source, if known) */
*************** static SYMR    *cur_oproc_begin	= (SYMR
*** 1570,1577 ****
  static SYMR    *cur_oproc_end	= (SYMR *) 0;	/* original proc. sym end info */
  static PDR     *cur_oproc_ptr	= (PDR *) 0;	/* current original procedure*/
  static thead_t *cur_tag_head	= (thead_t *) 0;/* current tag head */
! static long	file_offset	= 0;		/* current file offset */
! static long	max_file_offset	= 0;		/* maximum file offset */
  static FILE    *object_stream	= (FILE *) 0;	/* file desc. to output .o */
  static FILE    *obj_in_stream	= (FILE *) 0;	/* file desc. to input .o */
  static char    *progname	= (char *) 0;	/* program name for errors */
--- 1572,1579 ----
  static SYMR    *cur_oproc_end	= (SYMR *) 0;	/* original proc. sym end info */
  static PDR     *cur_oproc_ptr	= (PDR *) 0;	/* current original procedure*/
  static thead_t *cur_tag_head	= (thead_t *) 0;/* current tag head */
! static unsigned long file_offset	= 0;	/* current file offset */
! static unsigned long max_file_offset	= 0;	/* maximum file offset */
  static FILE    *object_stream	= (FILE *) 0;	/* file desc. to output .o */
  static FILE    *obj_in_stream	= (FILE *) 0;	/* file desc. to input .o */
  static char    *progname	= (char *) 0;	/* program name for errors */
*************** write_varray (vp, offset, str)
*** 4102,4108 ****
  	       (unsigned long) offset, vp->num_allocated * vp->object_size, str);
      }

!   if (file_offset != offset
        && fseek (object_stream, (long) offset, SEEK_SET) < 0)
      pfatal_with_name (object_name);

--- 4104,4110 ----
  	       (unsigned long) offset, vp->num_allocated * vp->object_size, str);
      }

!   if (file_offset != (unsigned long) offset
        && fseek (object_stream, (long) offset, SEEK_SET) < 0)
      pfatal_with_name (object_name);

*************** write_object ()
*** 4165,4171 ****
      {
        long sys_write;

!       if (file_offset != symbolic_header.cbLineOffset
  	  && fseek (object_stream, symbolic_header.cbLineOffset, SEEK_SET) != 0)
  	pfatal_with_name (object_name);

--- 4167,4173 ----
      {
        long sys_write;

!       if (file_offset != (unsigned long) symbolic_header.cbLineOffset
  	  && fseek (object_stream, symbolic_header.cbLineOffset, SEEK_SET) != 0)
  	pfatal_with_name (object_name);

*************** write_object ()
*** 4200,4206 ****
        long sys_write;
        long num_write = symbolic_header.ioptMax * sizeof (OPTR);

!       if (file_offset != symbolic_header.cbOptOffset
  	  && fseek (object_stream, symbolic_header.cbOptOffset, SEEK_SET) != 0)
  	pfatal_with_name (object_name);

--- 4202,4208 ----
        long sys_write;
        long num_write = symbolic_header.ioptMax * sizeof (OPTR);

!       if (file_offset != (unsigned long) symbolic_header.cbOptOffset
  	  && fseek (object_stream, symbolic_header.cbOptOffset, SEEK_SET) != 0)
  	pfatal_with_name (object_name);

*************** write_object ()
*** 4287,4293 ****
    if (symbolic_header.ifdMax > 0)		/* file tables */
      {
        offset = symbolic_header.cbFdOffset;
!       if (file_offset != offset
  	  && fseek (object_stream, (long) offset, SEEK_SET) < 0)
  	pfatal_with_name (object_name);

--- 4289,4295 ----
    if (symbolic_header.ifdMax > 0)		/* file tables */
      {
        offset = symbolic_header.cbFdOffset;
!       if (file_offset != (unsigned long) offset
  	  && fseek (object_stream, (long) offset, SEEK_SET) < 0)
  	pfatal_with_name (object_name);

*************** write_object ()
*** 4328,4334 ****
        long sys_write;
        symint_t num_write = symbolic_header.crfd * sizeof (symint_t);

!       if (file_offset != symbolic_header.cbRfdOffset
  	  && fseek (object_stream, symbolic_header.cbRfdOffset, SEEK_SET) != 0)
  	pfatal_with_name (object_name);

--- 4330,4336 ----
        long sys_write;
        symint_t num_write = symbolic_header.crfd * sizeof (symint_t);

!       if (file_offset != (unsigned long) symbolic_header.cbRfdOffset
  	  && fseek (object_stream, symbolic_header.cbRfdOffset, SEEK_SET) != 0)
  	pfatal_with_name (object_name);

*************** read_seek (size, offset, str)
*** 4393,4399 ****

    /* If we need to seek, and the distance is nearby, just do some reads,
       to speed things up.  */
!   if (file_offset != offset)
      {
        symint_t difference = offset - file_offset;

--- 4395,4401 ----

    /* If we need to seek, and the distance is nearby, just do some reads,
       to speed things up.  */
!   if (file_offset != (unsigned long) offset)
      {
        symint_t difference = offset - file_offset;

*************** copy_object ()
*** 4571,4577 ****


    /* Abort if the symbol table is not last.  */
!   if (max_file_offset != stat_buf.st_size)
      fatal ("symbol table is not last (symbol table ends at %ld, .o ends at %ld",
  	   max_file_offset,
  	   (long) stat_buf.st_size);
--- 4573,4579 ----


    /* Abort if the symbol table is not last.  */
!   if (max_file_offset != (unsigned long) stat_buf.st_size)
      fatal ("symbol table is not last (symbol table ends at %ld, .o ends at %ld",
  	   max_file_offset,
  	   (long) stat_buf.st_size);
*************** copy_object ()
*** 4625,4631 ****
    for (es = 0; es < orig_sym_hdr.iextMax; es++)
      {
        EXTR *eptr = orig_ext_syms + es;
!       unsigned ifd = eptr->ifd;

        (void) add_ext_symbol (eptr, ((long) ifd < orig_sym_hdr.ifdMax)
  			     ? remap_file_number[ ifd ] : ifd );
--- 4627,4633 ----
    for (es = 0; es < orig_sym_hdr.iextMax; es++)
      {
        EXTR *eptr = orig_ext_syms + es;
!       int ifd = eptr->ifd;

        (void) add_ext_symbol (eptr, ((long) ifd < orig_sym_hdr.ifdMax)
  			     ? remap_file_number[ ifd ] : ifd );

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833



More information about the Gcc-patches mailing list