Get rid of all "make check" compile warnings, except for the ones from
fxtract.c.

Also, gets rid of some of the warnings that -Wextra finds in Massif.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9237 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/drd/tests/pth_barrier_race.c b/drd/tests/pth_barrier_race.c
index 0c09a7b..8aee90e 100644
--- a/drd/tests/pth_barrier_race.c
+++ b/drd/tests/pth_barrier_race.c
@@ -12,7 +12,7 @@
 
 #include <pthread.h>
 #include <stdlib.h>
-
+#include <unistd.h>
 
 static pthread_barrier_t* barrier;
 
diff --git a/exp-ptrcheck/tests/Makefile.am b/exp-ptrcheck/tests/Makefile.am
index 089c95f..862819b 100644
--- a/exp-ptrcheck/tests/Makefile.am
+++ b/exp-ptrcheck/tests/Makefile.am
@@ -80,7 +80,7 @@
 
 # To make it a bit more realistic, build hackedbz2.c with at 
 # least some optimisation.
-hackedbz2_CFLAGS	= $(AM_CFLAGS) -O
+hackedbz2_CFLAGS	= $(AM_CFLAGS) -O -Wno-inline
 
 # C ones
 pth_create_LDADD	= -lpthread
diff --git a/exp-ptrcheck/tests/stackerr.c b/exp-ptrcheck/tests/stackerr.c
index 9d6e35c..36b8e67 100644
--- a/exp-ptrcheck/tests/stackerr.c
+++ b/exp-ptrcheck/tests/stackerr.c
@@ -43,10 +43,11 @@
   for (i = 0; i < 7+1; i++) {
      a[i] = 0;
   }
-  char beforebuf[8];
+ {char beforebuf[8];
   char buf[8];
   char afterbuf[8];
   sprintf(buf, "%d", 123456789);
   return 1 & ((a[4] + beforea[1] + aftera[1] + beforebuf[1] 
                     + buf[2] + afterbuf[3]) / 100000) ;
+ }
 }
diff --git a/exp-ptrcheck/tests/tricky.c b/exp-ptrcheck/tests/tricky.c
index 1ac8ad6..624f9e4 100644
--- a/exp-ptrcheck/tests/tricky.c
+++ b/exp-ptrcheck/tests/tricky.c
@@ -8,10 +8,12 @@
    // to zero.
    int  u[20];
    int* p = malloc(sizeof(int) * 100);
-
+   int* n;
+   int* x;
+   
    p[0] = 0;                           // ok
-   int* n = (int*)((long)p + (long)u); // result is n, because near zero!
-   int* x = (int*)((long)n - (long)u); // x == p
+   n = (int*)((long)p + (long)u);      // result is n, because near zero!
+   x = (int*)((long)n - (long)u);      // x == p
    x[0] = 0;                           // ok, originally caused false pos.
 
    return 0;
diff --git a/massif/ms_main.c b/massif/ms_main.c
index bd8cad9..32b6eec 100644
--- a/massif/ms_main.c
+++ b/massif/ms_main.c
@@ -220,8 +220,6 @@
       VG_(message)(Vg_DebugMsg, "Massif: " format, ##args); \
    }
 
-
-
 //------------------------------------------------------------//
 //--- Statistics                                           ---//
 //------------------------------------------------------------//
@@ -358,7 +356,7 @@
    // a UInt, but this caused problems on 64-bit machines when it was
    // multiplied by a small negative number and then promoted to a
    // word-sized type -- it ended up with a value of 4.2 billion.  Sigh.
-static SizeT  clo_heap_admin      = 8;
+static SSizeT clo_heap_admin      = 8;
 static Bool   clo_stacks          = False;
 static UInt   clo_depth           = 30;
 static double clo_threshold       = 1.0;  // percentage
@@ -1262,7 +1260,7 @@
 // snapshot, or what kind of snapshot, are made elsewhere.
 static void
 take_snapshot(Snapshot* snapshot, SnapshotKind kind, Time time,
-              Bool is_detailed, Char* what)
+              Bool is_detailed)
 {
    tl_assert(!is_snapshot_in_use(snapshot));
    tl_assert(have_started_executing_code);
@@ -1348,7 +1346,7 @@
 
    // Take the snapshot.
    snapshot = & snapshots[next_snapshot_i];
-   take_snapshot(snapshot, kind, time, is_detailed, what);
+   take_snapshot(snapshot, kind, time, is_detailed);
 
    // Record if it was detailed.
    if (is_detailed) {
@@ -1465,7 +1463,7 @@
    Bool is_custom_alloc = (NULL != p);
    SizeT actual_szB, slop_szB;
 
-   if (req_szB < 0) return NULL;
+   if ((SSizeT)req_szB < 0) return NULL;
 
    // Allocate and zero if necessary
    if (!p) {
@@ -1667,7 +1665,7 @@
    return new_block( tid, NULL, szB, alignB, False );
 }
 
-static void ms_free ( ThreadId tid, void* p )
+static void ms_free ( ThreadId tid __attribute__((unused)), void* p )
 {
    die_block( p, /*custom_free*/False );
 }
@@ -1687,7 +1685,7 @@
    return renew_block(tid, p_old, new_szB);
 }
 
-static SizeT ms_malloc_usable_size ( ThreadId tid, void* p )                    
+static SizeT ms_malloc_usable_size ( ThreadId tid, void* p )
 {                                                            
    HP_Chunk* hc = VG_(HT_lookup)( malloc_list, (UWord)p );
 
@@ -1709,7 +1707,7 @@
    update_alloc_stats(stack_szB_delta);
 }
 
-static INLINE void new_mem_stack_2(Addr a, SizeT len, Char* what)
+static INLINE void new_mem_stack_2(SizeT len, Char* what)
 {
    if (have_started_executing_code) {
       VERB(3, "<<< new_mem_stack (%ld)", len);
@@ -1720,7 +1718,7 @@
    }
 }
 
-static INLINE void die_mem_stack_2(Addr a, SizeT len, Char* what)
+static INLINE void die_mem_stack_2(SizeT len, Char* what)
 {
    if (have_started_executing_code) {
       VERB(3, "<<< die_mem_stack (%ld)", -len);
@@ -1734,22 +1732,22 @@
 
 static void new_mem_stack(Addr a, SizeT len)
 {
-   new_mem_stack_2(a, len, "stk-new");
+   new_mem_stack_2(len, "stk-new");
 }
 
 static void die_mem_stack(Addr a, SizeT len)
 {
-   die_mem_stack_2(a, len, "stk-die");
+   die_mem_stack_2(len, "stk-die");
 }
 
 static void new_mem_stack_signal(Addr a, SizeT len, ThreadId tid)
 {
-   new_mem_stack_2(a, len, "sig-new");
+   new_mem_stack_2(len, "sig-new");
 }
 
 static void die_mem_stack_signal(Addr a, SizeT len)
 {
-   die_mem_stack_2(a, len, "sig-die");
+   die_mem_stack_2(len, "sig-die");
 }
 
 
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
index 8d91625..0e6f5eb 100644
--- a/memcheck/tests/Makefile.am
+++ b/memcheck/tests/Makefile.am
@@ -226,23 +226,44 @@
 	wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap7so.so wrap8 \
 	writev zeropage
 
+
 AM_CFLAGS   += $(AM_FLAG_M3264_PRI)
 AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
 
-# Extra stuff for C tests
+deep_templates_SOURCES	= deep_templates.cpp
+deep_templates_CXXFLAGS	= $(AM_CFLAGS) -O -gstabs
+
+long_namespace_xml_SOURCES = long_namespace_xml.cpp
+
 memcmptest_CFLAGS	= $(AM_CFLAGS) -fno-builtin-memcmp
+
+mismatches_SOURCES	= mismatches.cpp
+
+new_nothrow_SOURCES 	= new_nothrow.cpp
+new_override_SOURCES 	= new_override.cpp
+
+# This requires optimisation in order to get just one resulting error.
+origin4_many_CFLAGS	= $(AM_CFLAGS) -O
+
+# Apply -O so as to run in reasonable time.
+origin5_bz2_CFLAGS	= $(AM_CFLAGS) -O -Wno-inline
+origin6_fp_CFLAGS	= $(AM_CFLAGS) -O
+
+# Don't allow GCC to inline memcpy(), because then we can't intercept it
+overlap_CFLAGS		= $(AM_CFLAGS) -fno-builtin-memcpy
+
+str_tester_CFLAGS	= $(AM_CFLAGS) -Wno-shadow
+
+supp_unknown_SOURCES	= badjump.c
+supp1_SOURCES		= supp.c
+supp2_SOURCES		= supp.c
+
 vcpu_bz2_CFLAGS		= $(AM_CFLAGS) -O2
 vcpu_fbench_CFLAGS	= $(AM_CFLAGS) -O2
 vcpu_fnfns_CFLAGS	= $(AM_CFLAGS) -O2
 vcpu_fnfns_LDADD	= -lm
 wrap6_CFLAGS		= $(AM_CFLAGS) -O2
 
-# Don't allow GCC to inline memcpy(), because then we can't intercept it
-overlap_CFLAGS		= $(AM_CFLAGS) -fno-builtin-memcpy
-str_tester_CFLAGS	= $(AM_CFLAGS) -Wno-shadow
-supp_unknown_SOURCES	= badjump.c
-supp1_SOURCES		= supp.c
-supp2_SOURCES		= supp.c
 # To make it a bit more realistic, have some optimisation enabled
 # for the varinfo tests.  We still expect sane results.
 varinfo1_CFLAGS		= $(AM_CFLAGS) -O
@@ -251,19 +272,6 @@
 varinfo4_CFLAGS		= $(AM_CFLAGS) -O
 varinfo5_CFLAGS		= $(AM_CFLAGS) -O
 varinfo6_CFLAGS		= $(AM_CFLAGS) -O
-# This requires optimisation in order to get just one resulting error.
-origin4_many_CFLAGS	= $(AM_CFLAGS) -O
-# Apply -O so as to run in reasonable time.
-origin5_bz2_CFLAGS	= $(AM_CFLAGS) -O
-origin6_fp_CFLAGS	= $(AM_CFLAGS) -O
-
-# C++ tests
-mismatches_SOURCES	= mismatches.cpp
-new_nothrow_SOURCES 	= new_nothrow.cpp
-new_override_SOURCES 	= new_override.cpp
-deep_templates_SOURCES	= deep_templates.cpp
-long_namespace_xml_SOURCES = long_namespace_xml.cpp
-deep_templates_CXXFLAGS	= $(AM_CFLAGS) -O -gstabs
 
 if VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5
 if VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5
@@ -282,39 +290,6 @@
 endif
 endif
 
-# Build shared object for wrap7
-wrap7_SOURCES           = wrap7.c
-wrap7_DEPENDENCIES      = wrap7so.so
-if VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5 
- wrap7_LDADD            = `pwd`/wrap7so.so
- wrap7_LDFLAGS          = $(AM_FLAG_M3264_PRI)
-else
-if VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5
- wrap7_LDADD            = `pwd`/wrap7so.so
- wrap7_LDFLAGS          = $(AM_FLAG_M3264_PRI) -Wl,-G -Wl,-bnogc
-else
- wrap7_LDADD            = wrap7so.so
- wrap7_LDFLAGS          = $(AM_FLAG_M3264_PRI) \
-				-Wl,-rpath,$(top_builddir)/memcheck/tests
-endif
-endif
-
-wrap7so_so_SOURCES      = wrap7so.c
-wrap7so_so_LDADD        = 
-wrap7so_so_DEPENDENCIES = 
-wrap7so_so_CFLAGS       = $(AM_CFLAGS) -fpic
-if VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5
- wrap7so_so_LDFLAGS     = -fpic $(AM_FLAG_M3264_PRI) -shared
-else
-if VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5
- wrap7so_so_LDFLAGS     = -fpic $(AM_FLAG_M3264_PRI) -shared \
-				-Wl,-G -Wl,-bnogc
-else
- wrap7so_so_LDFLAGS     = -fpic $(AM_FLAG_M3264_PRI) -shared \
-				-Wl,-soname -Wl,wrap7so.so
-endif
-endif
-
 # Build shared object for varinfo5
 varinfo5_SOURCES        = varinfo5.c
 varinfo5_DEPENDENCIES   = varinfo5so.so
@@ -333,9 +308,7 @@
 endif
 
 varinfo5so_so_SOURCES   = varinfo5so.c
-varinfo5so_so_LDADD     = 
-varinfo5so_so_DEPENDENCIES = 
-varinfo5so_so_CFLAGS    = $(AM_CFLAGS) -fpic -O
+varinfo5so_so_CFLAGS    = $(AM_CFLAGS) -fpic -O -Wno-shadow
 if VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5
  varinfo5so_so_LDFLAGS  = -fpic $(AM_FLAG_M3264_PRI) -shared
 else
@@ -347,4 +320,35 @@
 				-Wl,-soname -Wl,varinfo5so.so
 endif
 endif
+# Build shared object for wrap7
+wrap7_SOURCES           = wrap7.c
+wrap7_DEPENDENCIES      = wrap7so.so
+if VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5 
+ wrap7_LDADD            = `pwd`/wrap7so.so
+ wrap7_LDFLAGS          = $(AM_FLAG_M3264_PRI)
+else
+if VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5
+ wrap7_LDADD            = `pwd`/wrap7so.so
+ wrap7_LDFLAGS          = $(AM_FLAG_M3264_PRI) -Wl,-G -Wl,-bnogc
+else
+ wrap7_LDADD            = wrap7so.so
+ wrap7_LDFLAGS          = $(AM_FLAG_M3264_PRI) \
+				-Wl,-rpath,$(top_builddir)/memcheck/tests
+endif
+endif
+
+wrap7so_so_SOURCES      = wrap7so.c
+wrap7so_so_CFLAGS       = $(AM_CFLAGS) -fpic
+if VGCONF_PLATFORMS_INCLUDE_PPC64_AIX5
+ wrap7so_so_LDFLAGS     = -fpic $(AM_FLAG_M3264_PRI) -shared
+else
+if VGCONF_PLATFORMS_INCLUDE_PPC32_AIX5
+ wrap7so_so_LDFLAGS     = -fpic $(AM_FLAG_M3264_PRI) -shared \
+				-Wl,-G -Wl,-bnogc
+else
+ wrap7so_so_LDFLAGS     = -fpic $(AM_FLAG_M3264_PRI) -shared \
+				-Wl,-soname -Wl,wrap7so.so
+endif
+endif
+
 
diff --git a/none/tests/coolo_sigaction.cpp b/none/tests/coolo_sigaction.cpp
index b41938b..7baa4ae 100644
--- a/none/tests/coolo_sigaction.cpp
+++ b/none/tests/coolo_sigaction.cpp
@@ -42,11 +42,12 @@
 {
     int i;
     char buffer[200];
+    size_t dummy_size_t;
     setupHandlers();
     FILE *p = popen("echo Hallo World", "r");
     while (!feof(p)) {
         int n = fread(buffer, 200, 1, p);
-        write(2, buffer, n);
+        dummy_size_t = write(2, buffer, n);
     }
     fclose(p);
     for (i = 0; i < 1000000; i++) ;
diff --git a/none/tests/fdleak_cmsg.c b/none/tests/fdleak_cmsg.c
index 3c7db64..a061b23 100644
--- a/none/tests/fdleak_cmsg.c
+++ b/none/tests/fdleak_cmsg.c
@@ -59,7 +59,7 @@
 
    memset(&addr, 0, sizeof(addr));
    addr.sun_family = AF_UNIX;
-   sprintf(addr.sun_path, sock);
+   sprintf(addr.sun_path, "%s", sock);
 
    unlink(addr.sun_path);
    if(bind(s, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
@@ -135,7 +135,7 @@
    }
 
    addr.sun_family = AF_UNIX;
-   sprintf(addr.sun_path, sock);
+   sprintf(addr.sun_path, "%s", sock);
 
    do {
      count++;
diff --git a/perf/Makefile.am b/perf/Makefile.am
index b9e2e81..9ea7d94 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -23,7 +23,9 @@
 AM_CXXFLAGS = $(AM_CFLAGS)
 
 # Extra stuff
-fbench_CFLAGS   = $(AM_FLAG_M3264_PRI) -g -O2
+bz2_CFLAGS	= $(AM_CFLAGS) -Wno-inline
+
+fbench_CFLAGS   = $(AM_CFLAGS) -O2
 ffbench_LDADD	= -lm
 
-tinycc_CFLAGS	= $(AM_CFLAGS) -Wno-shadow
+tinycc_CFLAGS	= $(AM_CFLAGS) -Wno-shadow -Wno-inline
diff --git a/perf/tinycc.c b/perf/tinycc.c
index c445b97..5bef066 100644
--- a/perf/tinycc.c
+++ b/perf/tinycc.c
@@ -59,6 +59,12 @@
 
 //#endif /* !CONFIG_TCCBOOT */
 
+// Dummy variables used to avoid warnings like these: 
+// warning: ignoring return value of ‘fwrite’, declared with attribute
+//    warn_unused_result
+char* dummy_char_star;
+size_t dummy_size_t;
+
 // njn: inlined elf.h
 //#include "elf.h"
 //---------------------------------------------------------------------------
@@ -14839,7 +14845,7 @@
         section_sym = put_elf_sym(symtab_section, 0, 0, 
                                   ELF32_ST_INFO(STB_LOCAL, STT_SECTION), 0, 
                                   text_section->sh_num, NULL);
-        getcwd(buf, sizeof(buf));
+        dummy_char_star = getcwd(buf, sizeof(buf));
         pstrcat(buf, sizeof(buf), "/");
         put_stabs_r(buf, N_SO, 0, 0, 
                     text_section->data_offset, text_section, section_sym);
@@ -19193,7 +19199,7 @@
                 offset++;
             }
             size = s->sh_size;
-            fwrite(s->data, 1, size, f);
+            dummy_size_t = fwrite(s->data, 1, size, f);
             offset += size;
         }
     }
@@ -19776,8 +19782,8 @@
         ehdr.e_shnum = shnum;
         ehdr.e_shstrndx = shnum - 1;
         
-        fwrite(&ehdr, 1, sizeof(Elf32_Ehdr), f);
-        fwrite(phdr, 1, phnum * sizeof(Elf32_Phdr), f);
+        dummy_size_t = fwrite(&ehdr, 1, sizeof(Elf32_Ehdr), f);
+        dummy_size_t = fwrite(phdr, 1, phnum * sizeof(Elf32_Phdr), f);
         offset = sizeof(Elf32_Ehdr) + phnum * sizeof(Elf32_Phdr);
 
         for(i=1;i<s1->nb_sections;i++) {
@@ -19788,7 +19794,7 @@
                     offset++;
                 }
                 size = s->sh_size;
-                fwrite(s->data, 1, size, f);
+                dummy_size_t = fwrite(s->data, 1, size, f);
                 offset += size;
             }
         }
@@ -19816,7 +19822,7 @@
                 sh->sh_offset = s->sh_offset;
                 sh->sh_size = s->sh_size;
             }
-            fwrite(sh, 1, sizeof(Elf32_Shdr), f);
+            dummy_size_t = fwrite(sh, 1, sizeof(Elf32_Shdr), f);
         }
     } else {
         tcc_output_binary(s1, f, section_order);
@@ -19838,7 +19844,7 @@
 
     data = tcc_malloc(size);
     lseek(fd, file_offset, SEEK_SET);
-    read(fd, data, size);
+    dummy_size_t = read(fd, data, size);
     return data;
 }
 
@@ -19975,7 +19981,7 @@
             unsigned char *ptr;
             lseek(fd, file_offset + sh->sh_offset, SEEK_SET);
             ptr = section_ptr_add(s, size);
-            read(fd, ptr, size);
+            dummy_size_t = read(fd, ptr, size);
         } else {
             s->data_offset += size;
         }
@@ -20157,7 +20163,7 @@
     unsigned long file_offset;
 
     /* skip magic which was already checked */
-    read(fd, magic, sizeof(magic));
+    dummy_size_t = read(fd, magic, sizeof(magic));
     
     for(;;) {
         len = read(fd, &hdr, sizeof(hdr));
@@ -20212,7 +20218,7 @@
     const char *name, *soname, *p;
     DLLReference *dllref;
     
-    read(fd, &ehdr, sizeof(ehdr));
+    dummy_size_t = read(fd, &ehdr, sizeof(ehdr));
 
     /* test CPU specific stuff */
     if (ehdr.e_ident[5] != ELFDATA2LSB ||