From 90360ef24cc75378a1e5c4f13424d5153f2691a5 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 26 Jun 2011 20:00:03 +0000 Subject: [PATCH] swallow type conversion warnings --- ChangeLog | 8 ++++++++ src/include/hash.h | 12 ++++++------ src/misc/dstring.c | 11 +++++++---- src/misc/hash.c | 4 ++-- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89f2f130a..633977b15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ +2011-06-26 Robert Larice + * src/include/hash.h , + * src/misc/dstring.c , + * src/misc/hash.c : + swallow type conversion warnings + FIXME, get rid of this homegrown printf implementation (dstring.c) + 2011-06-26 Dietmar Warning * devices/bsim4/b4temp.c: zero init with TMALLOC instead of malloc + a missing pParam->BSIM4tvoffcv = 0; is the actual culprit. * devices/bsim4/b4noi.c: correct init the correlated noise slot in noiseDens and lnNdens vector, bug should be reported to bsim4 developer team. diff --git a/src/include/hash.h b/src/include/hash.h index 8d5c1d647..87978016e 100644 --- a/src/include/hash.h +++ b/src/include/hash.h @@ -150,9 +150,9 @@ we want to intentionally assign it. The compiler is warning unnecessarily. if( c == 0) { \ break ; \ } \ - hsum += (hsum<<3) + c; \ + hsum += (hsum<<3) + (unsigned int) c; \ } \ - hsum %= (size) ; \ + hsum %= (unsigned int) (size) ; \ } while(0); #define NGHASH_NUM_TO_HASH( num, hsum, size ) \ @@ -181,8 +181,8 @@ we want to intentionally assign it. The compiler is warning unnecessarily. do { \ unsigned int temp ; \ long value = (long) ptr ; \ - temp = value ; \ - hsum = temp & (size - 1) ; \ + temp = (unsigned int) value ; \ + hsum = temp & (unsigned int) (size - 1) ; \ } while(0); @@ -226,8 +226,8 @@ we want to intentionally assign it. The compiler is warning unnecessarily. do { \ unsigned int temp ; \ long value = (long) ptr ; \ - temp = value >> 4 ; \ - hsum = temp & (size - 1) ; \ + temp = (unsigned int) (value >> 4) ; \ + hsum = temp & (unsigned int) (size - 1) ; \ } while(0); #define NGHASH_PTR_COMPARE_FUNC( p1 , p2 ) ( (p1) != (p2) ) diff --git a/src/misc/dstring.c b/src/misc/dstring.c index b2e87ffe6..9101e9a41 100644 --- a/src/misc/dstring.c +++ b/src/misc/dstring.c @@ -4,7 +4,10 @@ DESCRIPTION:This file contains the routines for manipulating dynamic strings. CONTENTS: DATE: Wed Mar 24 18:38:28 CDT 2010 REVISIONS: $Log$ -REVISIONS: Revision 1.7 2011-06-22 17:17:41 rlar +REVISIONS: Revision 1.8 2011-06-26 20:00:03 rlar +REVISIONS: swallow type conversion warnings +REVISIONS: +REVISIONS: Revision 1.7 2011/06/22 17:17:41 rlar REVISIONS: remove some useless casts REVISIONS: REVISIONS: Revision 1.6 2010/11/06 20:17:20 rlar @@ -146,7 +149,7 @@ static int spice_format_length( va_list args, char *fmt ) int size_format ; /* width of field */ int found_special ; /* look for special characters */ char *s ; /* string */ - char c ; /* character */ + double d ; /* ----------------------------------------------------------------- * First find length of buffer. @@ -190,7 +193,7 @@ static int spice_format_length( va_list args, char *fmt ) found_special = TRUE ; break ; case 'c': - c = va_arg(args, int) ; + i = va_arg(args, int) ; len++ ; found_special = TRUE ; break ; @@ -199,7 +202,7 @@ static int spice_format_length( va_list args, char *fmt ) case 'F': case 'g': case 'G': - c = va_arg(args, double) ; + d = va_arg(args, double) ; len += 35 ; found_special = TRUE ; break ; diff --git a/src/misc/hash.c b/src/misc/hash.c index f05ac18d4..1b65d41ec 100644 --- a/src/misc/hash.c +++ b/src/misc/hash.c @@ -62,8 +62,8 @@ NGHASHPTR nghash_init_with_parms(void *comp_func, nghash_func hash_func, int num hashtable->max_density = max ; hashtable->need_resize = hashtable->size * hashtable->max_density ; hashtable->growth_factor = growth ; - hashtable->unique = unique ; - hashtable->power_of_two = power_of_two ; + hashtable->unique = (unique ? 1 : 0); + hashtable->power_of_two = (power_of_two ? 1 : 0); hashtable->thread = NULL ; /* initialize list */ hashtable->last_entry = NULL ; /* end of list */ hashtable->num_entries = 0 ;