This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: egcs CVS 19980621, warning patch part 5/7


 > From: Jeffrey A Law <law@hurl.cygnus.com>
 > 
 >   In message <199806220158.VAA15094@caip.rutgers.edu>you write:
 >   > 	This is warning patch part 5/7.  Okay to install?
 >   > 
 >   > Sun Jun 21 16:39:30 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 >   > 
 >   > 	* mips-tfile.c (add_local_symbol): Cast width format specifier to int.
 >   > 	(add_ext_symbol): Likewise.
 >   > 	(add_file): Likewise.
 >   > 	(parse_def): Likewise.
 >   > 	(write_varray): Use HOST_PTR_PRINTF to print a pointer.  Fix
 >   > 	remaining format specifiers and arguments.
 >   > 	(write_object): Likewise, several times.
 >   > 	(read_seek): Likewise.
 >   > 	(out_of_bounds): Likewise.
 >   > 	(allocate_cluster): Likewise.
 >   > 	(xmalloc): Likewise.
 >   > 	(xcalloc): Likewise.
 >   > 	(xrealloc): Likewise.
 >   > 	(xfree): Likewise.
 >   > 
 >   > 	* mips-tdump.c (print_symbol): Likewise.
 > 
 > Lots of icky-casts.  I guess it's OK though.
 > jeff


	Okay, I installed it.


BTW, yes casts are icky. :-)  However I ran into several situations
here where I felt casts were the best option:

1.  Pointer or long arithmetic passed as a "width" specifier to printf. 
This may resolve to a long int (and gcc says it requires an int.)

2.  Printf'ing structure members defined in system headers where the
same member is sometimes long and sometimes int depending on compile
time macros or which OS platform we are on. 

3.  Printf'ing "sizeof" something which can resolve to unsigned long or
unsigned int. 

So, in case #1 I casted them all to int, and for cases #2 and #3 I
casted them all to long and matched the specifier using `l'. 


--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		Icon CMT Corp.


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