From: Julian Seward Date: Sun, 18 May 2003 10:05:38 +0000 (+0000) Subject: gcc-3.3 as supplied with SuSE 8.2 ("gcc version 3.3 20030226 X-Git-Tag: svn/VALGRIND_2_0_0~146 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=07258f73de220c30cc8db51e31e6c2cf9e82a20e;p=thirdparty%2Fvalgrind.git gcc-3.3 as supplied with SuSE 8.2 ("gcc version 3.3 20030226 (prerelease) (SuSE Linux)") seems to complain about signed-vs-unsigned comparisons, when -Wall is on. This commit fixes (most of) those complaints. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1638 --- diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index 84f6fb4dc6..b5bb940577 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -1006,7 +1006,7 @@ static cache_t clo_L2_cache = UNDEFINED_CACHE; * them. */ -static __inline__ void cpuid(Int n, Int *a, Int *b, Int *c, Int *d) +static __inline__ void cpuid(Int n, UInt *a, UInt *b, UInt *c, UInt *d) { __asm__ __volatile__ ( "cpuid" @@ -1181,7 +1181,8 @@ Int Intel_cache_info(Int level, cache_t* I1c, cache_t* D1c, cache_t* L2c) static Int AMD_cache_info(cache_t* I1c, cache_t* D1c, cache_t* L2c) { - Int dummy, model, ext_level; + UInt ext_level; + Int dummy, model; Int I1i, D1i, L2i; cpuid(0x80000000, &ext_level, &dummy, &dummy, &dummy); diff --git a/coregrind/demangle/cplus-dem.c b/coregrind/demangle/cplus-dem.c index 4f708e6b6d..ed16d24190 100644 --- a/coregrind/demangle/cplus-dem.c +++ b/coregrind/demangle/cplus-dem.c @@ -1776,7 +1776,7 @@ demangle_expression (work, mangled, s, tk) len = strlen (*mangled); - for (i = 0; i < ARRAY_SIZE (optable); ++i) + for (i = 0; i < (size_t)ARRAY_SIZE (optable); ++i) { size_t l = strlen (optable[i].in); @@ -4683,7 +4683,7 @@ demangle_function_name (work, mangled, declp, scan) if (declp->p - declp->b >= 10 /* op$assign_ */ && memcmp (declp->b + 3, "assign_", 7) == 0) { - for (i = 0; i < ARRAY_SIZE (optable); i++) + for (i = 0; i < (size_t)ARRAY_SIZE (optable); i++) { int len = declp->p - declp->b - 10; if ((int) strlen (optable[i].in) == len @@ -4699,7 +4699,7 @@ demangle_function_name (work, mangled, declp, scan) } else { - for (i = 0; i < ARRAY_SIZE (optable); i++) + for (i = 0; i < (size_t)ARRAY_SIZE (optable); i++) { int len = declp->p - declp->b - 3; if ((int) strlen (optable[i].in) == len @@ -4747,7 +4747,7 @@ demangle_function_name (work, mangled, declp, scan) if (declp->b[4] == '\0') { /* Operator. */ - for (i = 0; i < ARRAY_SIZE (optable); i++) + for (i = 0; i < (size_t)ARRAY_SIZE (optable); i++) { if (strlen (optable[i].in) == 2 && memcmp (optable[i].in, declp->b + 2, 2) == 0) @@ -4764,7 +4764,7 @@ demangle_function_name (work, mangled, declp, scan) if (declp->b[2] == 'a' && declp->b[5] == '\0') { /* Assignment. */ - for (i = 0; i < ARRAY_SIZE (optable); i++) + for (i = 0; i < (size_t)ARRAY_SIZE (optable); i++) { if (strlen (optable[i].in) == 3 && memcmp (optable[i].in, declp->b + 2, 3) == 0) diff --git a/coregrind/vg_errcontext.c b/coregrind/vg_errcontext.c index 509215220b..8b953d75d6 100644 --- a/coregrind/vg_errcontext.c +++ b/coregrind/vg_errcontext.c @@ -204,7 +204,7 @@ void construct_error ( Error* err, ThreadState* tst, ErrorKind ekind, Addr a, void VG_(gen_suppression)(Error* err) { - UInt i; + Int i; UChar buf[M_VG_ERRTXT]; ExeContext* ec = VG_(get_error_where)(err); Int stop_at = VG_(clo_backtrace_size); diff --git a/coregrind/vg_from_ucode.c b/coregrind/vg_from_ucode.c index db3d8bde12..b285e1db0c 100644 --- a/coregrind/vg_from_ucode.c +++ b/coregrind/vg_from_ucode.c @@ -164,7 +164,7 @@ void VG_(print_UInstr_histogram)(void) histogram[i].counts, count_pc, avg_size, size_pc); - for (j = 0; j < size_pc; j++) VG_(printf)("O"); + for (j = 0; j < (Int)size_pc; j++) VG_(printf)("O"); VG_(printf)("\n"); } else { @@ -1883,7 +1883,7 @@ void VG_(emit_AMD_prefetch_reg) ( Int reg ) * Searches through compacts first, then non-compacts. */ Int VG_(helper_offset)(Addr a) { - Int i; + UInt i; Char buf[100]; for (i = 0; i < VG_(n_compact_helpers); i++) diff --git a/coregrind/vg_intercept.c b/coregrind/vg_intercept.c index 1d99d33675..1f810e822d 100644 --- a/coregrind/vg_intercept.c +++ b/coregrind/vg_intercept.c @@ -266,8 +266,8 @@ typedef unsigned long int nfds_t; int VGR_(poll) (struct pollfd *__fds, nfds_t __nfds, int __timeout) { - unsigned int ms_now, ms_end; - int res, i; + unsigned int ms_now, ms_end, i; + int res; struct vki_timespec nanosleep_interval; __my_pthread_testcancel(); diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 2331ec25ec..960fa75730 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -177,10 +177,12 @@ void VG_(register_noncompact_helper)(Addr a) } /* Allocate offsets in baseBlock for the skin helpers */ -static void assign_helpers_in_baseBlock(UInt n, Int offsets[], Addr addrs[]) +static +void assign_helpers_in_baseBlock(UInt n, Int offsets[], Addr addrs[]) { - Int i; - for (i = 0; i < n; i++) offsets[i] = alloc_BaB_1_set( addrs[i] ); + UInt i; + for (i = 0; i < n; i++) + offsets[i] = alloc_BaB_1_set( addrs[i] ); } Bool VG_(need_to_handle_esp_assignment)(void) @@ -708,7 +710,7 @@ static void vg_findstack_callback ( Addr start, UInt size, static void process_cmd_line_options ( void ) { Char* argv[M_VG_CMDLINE_OPTS]; - UInt argc; + Int argc; Char* p; Char* str; Int i, eventually_logfile_fd, ctr; @@ -732,7 +734,7 @@ static void process_cmd_line_options ( void ) envc & envp. It is not fool-proof, but these structures should change less often than the libc ones. */ { - UInt* sp; + Int* sp; /* Look for the stack segment by parsing /proc/self/maps and looking for a section bracketing VG_(esp_at_startup) which diff --git a/coregrind/vg_malloc2.c b/coregrind/vg_malloc2.c index bf9c8d0617..9b6af79e21 100644 --- a/coregrind/vg_malloc2.c +++ b/coregrind/vg_malloc2.c @@ -629,8 +629,9 @@ void unlinkBlock ( Arena* a, UInt* b, Int listno ) static void splitChunk ( Arena* a, UInt* b, Int b_listno, UInt req_bszW ) { - Int b_bszW, frag_bszW; - b_bszW = mk_plain_bszW(get_bszW_lo(b)); + UInt b_bszW; + Int frag_bszW; + b_bszW = (UInt)mk_plain_bszW(get_bszW_lo(b)); vg_assert(req_bszW < b_bszW); frag_bszW = b_bszW - req_bszW; vg_assert(frag_bszW >= overhead_szW(a)); diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c index b81e36ce69..ef06526a02 100644 --- a/coregrind/vg_mylibc.c +++ b/coregrind/vg_mylibc.c @@ -168,7 +168,7 @@ Bool VG_(kisfullsigset)( vki_ksigset_t* set ) Int i; vg_assert(set != NULL); for (i = 0; i < VKI_KNSIG_WORDS; i++) - if (set->ws[i] != ~0x0) return False; + if (set->ws[i] != (UInt)(~0x0)) return False; return True; } @@ -664,7 +664,7 @@ UInt VG_(printf) ( const char *format, ... ) /* A general replacement for sprintf(). */ UInt VG_(sprintf) ( Char* buf, Char *format, ... ) { - UInt ret; + Int ret; va_list vargs; Char *ptr = buf; static void add_to_vg_sprintf_buf ( Char c ) @@ -753,15 +753,18 @@ Long VG_(atoll36) ( UInt base, Char* str ) vg_assert(base >= 2 && base <= 36); if (*str == '-') { str++; neg = True; }; while (True) { - if (*str >= '0' && *str <=('9' - (10 - base))) { + if (*str >= '0' + && *str <= (Char)('9' - (10 - base))) { n = base*n + (Long)(*str - '0'); } else - if (base > 10 && *str >= 'A' && *str <= ('Z' - (36 - base))) { + if (base > 10 && *str >= 'A' + && *str <= (Char)('Z' - (36 - base))) { n = base*n + (Long)((*str - 'A') + 10); } else - if (base > 10 && *str >= 'a' && *str <= ('z' - (36 - base))) { + if (base > 10 && *str >= 'a' + && *str <= (Char)('z' - (36 - base))) { n = base*n + (Long)((*str - 'a') + 10); } else { diff --git a/coregrind/vg_replace_malloc.c b/coregrind/vg_replace_malloc.c index 2299fad68e..28068c2754 100644 --- a/coregrind/vg_replace_malloc.c +++ b/coregrind/vg_replace_malloc.c @@ -422,7 +422,7 @@ struct mallinfo { struct mallinfo mallinfo ( void ) { /* Should really try to return something a bit more meaningful */ - Int i; + UInt i; struct mallinfo mi; UChar* pmi = (UChar*)(&mi); for (i = 0; i < sizeof(mi); i++) diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 04c4933cac..ed4fcba83e 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -125,7 +125,7 @@ typedef /* File descriptor waited for. -1 means this slot is not in use */ Int fd; /* The syscall number the fd is used in. */ - Int syscall_no; + UInt syscall_no; /* False => still waiting for select to tell us the fd is ready to go. True => the fd is ready, but the results have not yet @@ -1134,7 +1134,8 @@ void poll_for_ready_fds ( void ) static void complete_blocked_syscalls ( void ) { - Int fd, i, res, syscall_no; + Int fd, i, res; + UInt syscall_no; void* pre_res; ThreadId tid; Char msg_buf[100]; @@ -1200,7 +1201,8 @@ void complete_blocked_syscalls ( void ) static void check_for_pthread_cond_timedwait ( void ) { - Int i, now; + Int i; + UInt now; for (i = 1; i < VG_N_THREADS; i++) { if (VG_(threads)[i].status != VgTs_WaitCV) continue; @@ -3621,7 +3623,7 @@ void scheduler_sanity ( void ) /* 1 */ vg_assert(mx != NULL); /* 2 */ vg_assert(mx->__m_count > 0); /* 3 */ vg_assert(VG_(is_valid_tid)((ThreadId)mx->__m_owner)); - /* 4 */ vg_assert(i != (ThreadId)mx->__m_owner); + /* 4 */ vg_assert((UInt)i != (ThreadId)mx->__m_owner); } else if (VG_(threads)[i].status == VgTs_WaitCV) { vg_assert(cv != NULL); diff --git a/coregrind/vg_symtab2.c b/coregrind/vg_symtab2.c index 304e9b97c0..3de0293319 100644 --- a/coregrind/vg_symtab2.c +++ b/coregrind/vg_symtab2.c @@ -161,7 +161,8 @@ Int addStr ( SegInfo* si, Char* str ) static SegInfo* curr_si = NULL; Char* new_tab; - Int new_sz, i, space_needed; + Int space_needed, i; + UInt new_sz, u; /* Avoid gratuitous duplication: if we saw `str' within the last NN, * within this segment, return that index. Saves about 200KB in glibc, @@ -192,8 +193,8 @@ Int addStr ( SegInfo* si, Char* str ) if (new_sz == 0) new_sz = 5000; new_tab = VG_(arena_malloc)(VG_AR_SYMTAB, new_sz); if (si->strtab != NULL) { - for (i = 0; i < si->strtab_used; i++) - new_tab[i] = si->strtab[i]; + for (u = 0; u < si->strtab_used; u++) + new_tab[u] = si->strtab[u]; VG_(arena_free)(VG_AR_SYMTAB, si->strtab); } si->strtab = new_tab; @@ -214,7 +215,7 @@ Int addStr ( SegInfo* si, Char* str ) static __inline__ void addSym ( SegInfo* si, RiSym* sym ) { - Int new_sz, i; + UInt new_sz, i; RiSym* new_tab; /* Ignore zero-sized syms. */ @@ -243,7 +244,7 @@ void addSym ( SegInfo* si, RiSym* sym ) static __inline__ void addLoc ( SegInfo* si, RiLoc* loc ) { - Int new_sz, i; + UInt new_sz, i; RiLoc* new_tab; /* Zero-sized locs should have been ignored earlier */ @@ -482,7 +483,7 @@ void canonicaliseSymtab ( SegInfo* si ) /* Detect and "fix" overlapping address ranges. */ n_truncated = 0; - for (i = 0; i < si->symtab_used-1; i++) { + for (i = 0; i < ((Int)si->symtab_used) -1; i++) { vg_assert(si->symtab[i].addr <= si->symtab[i+1].addr); @@ -529,7 +530,7 @@ void canonicaliseSymtab ( SegInfo* si ) /* It may be that the i+1 entry now needs to be moved further along to maintain the address order requirement. */ j = i+1; - while (j < si->symtab_used-1 + while (j < ((Int)si->symtab_used)-1 && si->symtab[j].addr > si->symtab[j+1].addr) { SWAP(RiSym,si->symtab[j],si->symtab[j+1]); j++; @@ -540,7 +541,7 @@ void canonicaliseSymtab ( SegInfo* si ) if (n_truncated > 0) goto cleanup_more; /* Ensure relevant postconditions hold. */ - for (i = 0; i < si->symtab_used-1; i++) { + for (i = 0; i < ((Int)si->symtab_used)-1; i++) { /* No zero-sized symbols. */ vg_assert(si->symtab[i].size > 0); /* In order. */ @@ -598,7 +599,7 @@ void canonicaliseLoctab ( SegInfo* si ) } /* If two adjacent entries overlap, truncate the first. */ - for (i = 0; i < si->loctab_used-1; i++) { + for (i = 0; i < ((Int)si->loctab_used)-1; i++) { vg_assert(si->loctab[i].size < 10000); if (si->loctab[i].addr + si->loctab[i].size > si->loctab[i+1].addr) { /* Do this in signed int32 because the actual .size fields @@ -618,7 +619,7 @@ void canonicaliseLoctab ( SegInfo* si ) /* Zap any zero-sized entries resulting from the truncation process. */ j = 0; - for (i = 0; i < si->loctab_used; i++) { + for (i = 0; i < (Int)si->loctab_used; i++) { if (si->loctab[i].size > 0) { si->loctab[j] = si->loctab[i]; j++; @@ -627,7 +628,7 @@ void canonicaliseLoctab ( SegInfo* si ) si->loctab_used = j; /* Ensure relevant postconditions hold. */ - for (i = 0; i < si->loctab_used-1; i++) { + for (i = 0; i < ((Int)si->loctab_used)-1; i++) { /* VG_(printf)("%d (%d) %d 0x%x\n", i, si->loctab[i+1].confident, @@ -1102,7 +1103,7 @@ void read_debuginfo_dwarf2 ( SegInfo* si, UChar* dwarf2, Int dwarf2_sz ) break; } - if (info.li_length + sizeof (external->li_length) > dwarf2_sz) + if (info.li_length + sizeof (external->li_length) > (UInt)dwarf2_sz) { vg_symerr("DWARF line info appears to be corrupt " "- the section is too small"); @@ -1393,7 +1394,7 @@ Bool vg_read_lib_symbols ( SegInfo* si ) Int i; Bool ok; Addr oimage; - Int n_oimage; + UInt n_oimage; struct vki_stat stat_buf; oimage = (Addr)NULL; @@ -1645,7 +1646,7 @@ Bool vg_read_lib_symbols ( SegInfo* si ) /* Perhaps should start at i = 1; ELF docs suggest that entry 0 always denotes `unknown symbol'. */ - for (i = 1; i < o_symtab_sz/sizeof(Elf32_Sym); i++){ + for (i = 1; i < (Int)(o_symtab_sz/sizeof(Elf32_Sym)); i++){ # if 1 if (VG_(clo_trace_symtab)) { VG_(printf)("raw symbol [%d]: ", i); @@ -2149,7 +2150,7 @@ Bool get_fnname ( Bool demangle, Addr a, Char* buf, Int nbuf, len = VG_(sprintf)(buf2, "%c%d", offset < 0 ? '-' : '+', offset < 0 ? -offset : offset); - vg_assert(len < sizeof(buf2)); + vg_assert(len < (Int)sizeof(buf2)); if (len < (end - symend)) { Char *cp = buf2; @@ -2342,7 +2343,7 @@ void VG_(mini_stack_dump) ( ExeContext* ec ) VG_(message)(Vg_UserMsg, "%s", buf); i++; - } while (i < stop_at && ec->eips[i] != 0); + } while (i < (UInt)stop_at && ec->eips[i] != 0); } #undef APPEND diff --git a/coregrind/vg_syscalls.c b/coregrind/vg_syscalls.c index 00786bafb9..57ef09ed77 100644 --- a/coregrind/vg_syscalls.c +++ b/coregrind/vg_syscalls.c @@ -1363,7 +1363,7 @@ void VG_(perform_assumed_nonblocking_syscall) ( ThreadId tid ) MAYBE_PRINTF("close ( %d )\n",arg1); /* Detect and negate attempts by the client to close Valgrind's logfile fd ... */ - if (arg1 == VG_(clo_logfile_fd)) { + if (arg1 == (UInt)VG_(clo_logfile_fd)) { VG_(message)(Vg_UserMsg, "Warning: client attempted to close " "Valgrind's logfile fd (%d).", @@ -2655,7 +2655,7 @@ void VG_(perform_assumed_nonblocking_syscall) ( ThreadId tid ) arg1, arg2 * sizeof(struct pollfd) ); KERNEL_DO_SYSCALL(tid,res); if (!VG_(is_kerror)(res) && res > 0) { - Int i; + UInt i; struct pollfd * arr = (struct pollfd *)arg1; for (i = 0; i < arg2; i++) VG_TRACK( post_mem_write, (Addr)(&arr[i].revents), diff --git a/coregrind/vg_translate.c b/coregrind/vg_translate.c index 56f94b0ed4..0010807602 100644 --- a/coregrind/vg_translate.c +++ b/coregrind/vg_translate.c @@ -1662,7 +1662,7 @@ UCodeBlock* vg_ESP_update_pass(UCodeBlock* cb_in) UInstr* u; Int delta = 0; UInt t_ESP = INVALID_TEMPREG; - UInt i; + Int i; cb = VG_(setup_UCodeBlock)(cb_in); diff --git a/coregrind/vg_transtab.c b/coregrind/vg_transtab.c index 5c33fabfa6..c35cdcfa5e 100644 --- a/coregrind/vg_transtab.c +++ b/coregrind/vg_transtab.c @@ -599,7 +599,7 @@ void VG_(invalidate_translations) ( Addr start, UInt range, Bool unchain_blocks /* make sure no other blocks chain to the one we just discarded */ for(j = 0; j < VG_TC_N_SECTORS; j++) { if (vg_tc[j] != NULL) - unchain_sector(j, tce->payload, tce->trans_size); + unchain_sector(j, (Addr)tce->payload, tce->trans_size); } } diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index dc887f57ad..e016f1757d 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -144,7 +144,7 @@ typedef struct _HG_Chunk { struct _HG_Chunk* next; Addr data; /* ptr to actual block */ - UInt size; /* size requested */ + Int size; /* size requested */ ExeContext* where; /* where it was allocated */ ThreadId tid; /* allocating thread */ } @@ -642,7 +642,7 @@ static inline Int mutex_cmp(const Mutex *a, const Mutex *b) } struct _LockSet { - UInt setsize; /* number of members */ + Int setsize; /* number of members */ UInt hash; /* hash code */ LockSet *next; /* next in hash chain */ const Mutex *mutex[0]; /* locks */ @@ -676,8 +676,7 @@ static inline const LockSet *unpackLockSet(UInt id) static void pp_LockSet(const LockSet* p) { - int i; - + Int i; VG_(printf)("{ "); for(i = 0; i < p->setsize; i++) { const Mutex *mx = p->mutex[i]; @@ -699,7 +698,7 @@ static inline UInt hash_LockSet_w_wo(const LockSet *ls, const Mutex *with, const Mutex *without) { - UInt i; + Int i; UInt hash = ls->setsize + (with != NULL) - (without != NULL); sk_assert(with == NULL || with != without); @@ -978,7 +977,7 @@ void sanity_check_locksets ( const Char* caller ) badness = "mismatched hash"; goto bad; } - if (ls->hash != i) { + if (ls->hash != (UInt)i) { badness = "wrong bucket"; goto bad; } @@ -1956,7 +1955,7 @@ void* SK_(realloc) ( ThreadState* tst, void* p, Int new_size ) { HG_Chunk *hc; HG_Chunk **prev_chunks_next_ptr; - UInt i; + Int i; /* First try and find the block. */ hc = (HG_Chunk*)VG_(HT_get_node) ( hg_malloc_list, (UInt)p, diff --git a/memcheck/mac_needs.c b/memcheck/mac_needs.c index 1531f38c8d..874a6da792 100644 --- a/memcheck/mac_needs.c +++ b/memcheck/mac_needs.c @@ -520,7 +520,7 @@ Bool SK_(read_extra_suppression_info) ( Int fd, Char* buf, Int nBuf, Supp *su ) Bool SK_(error_matches_suppression)(Error* err, Supp* su) { - UInt su_size; + Int su_size; MAC_Error* err_extra = VG_(get_error_extra)(err); ErrorKind ekind = VG_(get_error_kind )(err); diff --git a/memcheck/mc_clientreqs.c b/memcheck/mc_clientreqs.c index 1ba3abf5aa..58c9b0e68a 100644 --- a/memcheck/mc_clientreqs.c +++ b/memcheck/mc_clientreqs.c @@ -75,7 +75,7 @@ static UInt vg_cgb_search = 0; /* Number of searches. */ static Int vg_alloc_client_block ( void ) { - Int i, sz_new; + UInt i, sz_new; CGenBlock* cgbs_new; vg_cgb_allocs++; @@ -126,7 +126,7 @@ void MC_(show_client_block_stats) ( void ) Bool MC_(client_perm_maybe_describe)( Addr a, AddrInfo* ai ) { - Int i; + UInt i; /* VG_(printf)("try to identify %d\n", a); */ /* Perhaps it's a general block ? */ diff --git a/memcheck/mc_replace_strmem.c b/memcheck/mc_replace_strmem.c index 4dca714338..cbe1ad8b91 100644 --- a/memcheck/mc_replace_strmem.c +++ b/memcheck/mc_replace_strmem.c @@ -51,8 +51,8 @@ Bool is_overlap ( void* dst, const void* src, UInt len ) if (diff < 0) diff = -diff; - - return (diff < len); + /* Now we have diff >= 0, so a cast to UInt is harmless. */ + return ( ((UInt)diff) < len); } static __inline__