Merge pull request #54 from google/bswap

Removed platform-specific bswap() function calls.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9651789..0fa0a45 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -33,8 +33,8 @@
 
 ### Legal Requirements
 Before we can use your code, you must sign the [Google
-Individual Contributor License Agreement]
-(https://cla.developers.google.com/about/google-individual)
+Individual Contributor License
+Agreement](https://cla.developers.google.com/about/google-individual)
 (CLA), which you can do online. The CLA is necessary mainly
 because you own the copyright to your changes, even after
 your contribution becomes part of our codebase, so we need
@@ -49,5 +49,5 @@
 ### The small print
 Contributions made by corporations are covered by a
 different agreement than the one above, the [Software Grant
-and Corporate Contributor License Agreement]
-(https://cla.developers.google.com/about/google-corporate).
+and Corporate Contributor License
+Agreement](https://cla.developers.google.com/about/google-corporate).
diff --git a/Makefile b/Makefile
index f848838..94f6cc6 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 
 # Disable -Wsign-compare because StringPiece currently unhelpfully defines
 # size() as ssize_t instad of size_t.
-CXXFLAGS=-std=c++11 -Wall -Wno-sign-compare -g -I third_party/re2 -I. -Isrc
+CXXFLAGS=-std=c++11 -W -Wall -Wno-sign-compare -g -I third_party/re2 -I. -Isrc
 RE2_H=third_party/re2/re2/re2.h
 RE2_A=third_party/re2/obj/libre2.a
 
@@ -26,7 +26,7 @@
 third%party/re2/Makefile third%party/re2/re2/re2.h third%party/googletest/CMakeLists.txt third%party/libFuzzer/build.sh: .gitmodules
 	git submodule init && git submodule update
 	@# Ensure .gitmodules cannot be newer
-	touch .gitmodules -r $@
+	touch -r .gitmodules $@
 
 clean:
 	rm -f bloaty src/*.o src/*.a
diff --git a/src/bloaty.cc b/src/bloaty.cc
index b111b92..0c28f95 100644
--- a/src/bloaty.cc
+++ b/src/bloaty.cc
@@ -84,7 +84,7 @@
 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
 
 const char* GetDataSourceLabel(DataSource source) {
-  for (int i = 0; i < ARRAY_SIZE(data_sources); i++) {
+  for (size_t i = 0; i < ARRAY_SIZE(data_sources); i++) {
     if (data_sources[i].number == source) {
       return data_sources[i].name;
     }
@@ -715,7 +715,7 @@
 std::string SiPrint(ssize_t size, bool force_sign) {
   const char *prefixes[] = {"", "Ki", "Mi", "Gi", "Ti"};
   size_t num_prefixes = 5;
-  int n = 0;
+  size_t n = 0;
   double size_d = size;
   while (fabs(size_d) > 1024 && n < num_prefixes - 2) {
     size_d /= 1024;
diff --git a/src/bloaty.h b/src/bloaty.h
index 16b906c..7f6be89 100644
--- a/src/bloaty.h
+++ b/src/bloaty.h
@@ -93,7 +93,7 @@
             const MemoryMap* translator, MemoryMap* map);
   ~RangeSink();
 
-  const DataSource data_source() const { return data_source_; }
+  DataSource data_source() const { return data_source_; }
   const InputFile& input_file() const { return *file_; }
 
   // If vmsize or filesize is zero, this mapping is presumed not to exist in
@@ -226,7 +226,7 @@
  public:
   LineIterator(LineReader* reader) : reader_(reader) {}
 
-  bool operator!=(const LineIterator& other) const {
+  bool operator!=(const LineIterator& /*other*/) const {
     // Hack for range-based for.
     return !reader_->eof();
   }
diff --git a/src/dwarf.cc b/src/dwarf.cc
index 6ffa6ce..d1ebd7f 100644
--- a/src/dwarf.cc
+++ b/src/dwarf.cc
@@ -153,7 +153,7 @@
 bool SkipLEB128(StringPiece* data) {
   size_t limit =
       std::min(static_cast<size_t>(data->size()), static_cast<size_t>(10));
-  for (int i = 0; i < limit; i++) {
+  for (size_t i = 0; i < limit; i++) {
     if (((*data)[i] & 0x80) == 0) {
       data->remove_prefix(i + 1);
       return true;
@@ -965,7 +965,7 @@
       : Base(reader, data), val_(val) {}
 
   template <class Func>
-  static bool GetFunctionForForm(const DIEReader& reader, uint8_t form,
+  static bool GetFunctionForForm(const DIEReader& /*reader*/, uint8_t form,
                                  Func func) {
     switch (form) {
       case DW_FORM_flag:
@@ -1004,7 +1004,7 @@
   typedef void type;
   using Base::data_;
 
-  FormReader(const DIEReader& reader, StringPiece data, void* val)
+  FormReader(const DIEReader& reader, StringPiece data, void* /*val*/)
       : Base(reader, data) {}
 
   template <class Func>
@@ -1244,13 +1244,13 @@
   // this class).  If we want to be more restrictive about this later, we could
   // let users specify that only certain forms should be allowed.
   template <size_t N>
-  FixedAttrReader(DIEReader* reader, const DwarfAttribute (&attributes)[N]) {
+  FixedAttrReader(DIEReader* /*reader*/, const DwarfAttribute (&attributes)[N]) {
     static_assert(N == sizeof...(Args), "must match number of template params");
     std::copy(std::begin(attributes), std::end(attributes),
               std::begin(attributes_));
   }
 
-  FixedAttrReader(DIEReader* reader,
+  FixedAttrReader(DIEReader* /*reader*/,
                   std::initializer_list<DwarfAttribute> attributes) {
     assert(attributes.size() == sizeof...(Args));
     std::copy(std::begin(attributes), std::end(attributes),
diff --git a/src/elf.cc b/src/elf.cc
index 592d826..b8fcb3f 100644
--- a/src/elf.cc
+++ b/src/elf.cc
@@ -43,8 +43,8 @@
 
 bool StringPieceToSize(StringPiece str, size_t* out) {
   char *end = nullptr;
-  *out = strtol(str.data(), &end, 10);
-  return end != str.data() && *out != LONG_MIN && *out != LONG_MAX;
+  *out = strtoul(str.data(), &end, 10);
+  return end != str.data() && *out != ULONG_MAX;
 }
 
 
@@ -127,7 +127,7 @@
         : elf_(elf), data_(data) {}
 
     template <class T32, class T64, class Munger>
-    bool Read(size_t offset, Munger munger, T64* out) const {
+    bool Read(size_t offset, Munger /*munger*/, T64* out) const {
       if (elf_.is_64bit() && elf_.is_native_endian()) {
         return Memcpy(offset, out);
       } else {
@@ -623,7 +623,7 @@
 static bool ReadELFSymbols(const InputFile& file, RangeSink* sink,
                            SymbolTable* table) {
   bool is_object = IsObjectFile(file.data());
-  return ForEachElf(file, sink, [=](const ElfFile& elf, StringPiece filename,
+  return ForEachElf(file, sink, [=](const ElfFile& elf, StringPiece /*filename*/,
                                     uint32_t index_base) {
     for (Elf64_Xword i = 1; i < elf.section_count(); i++) {
       ElfFile::Section section;
@@ -764,8 +764,8 @@
   }
 
   return ForEachElf(sink->input_file(), sink, [=](const ElfFile& elf,
-                                                  StringPiece filename,
-                                                  uint32_t index_base) {
+                                                  StringPiece /*filename*/,
+                                                  uint32_t /*index_base*/) {
     for (Elf64_Xword i = 0; i < elf.header().e_phnum; i++) {
       ElfFile::Segment segment;
       CHECK_RETURN(elf.ReadSegment(i, &segment));
diff --git a/tests/range_map_test.cc b/tests/range_map_test.cc
index ab934cd..dcfec02 100644
--- a/tests/range_map_test.cc
+++ b/tests/range_map_test.cc
@@ -23,7 +23,7 @@
 
 class RangeMapTest : public ::testing::Test {
  protected:
-  void CheckConsistencyFor(const bloaty::RangeMap& map) {
+  void CheckConsistencyFor(const bloaty::RangeMap& /*map*/) {
     uint64_t last_end = 0;
     for (const auto& entry : map_.mappings_) {
       ASSERT_GT(entry.second.end, entry.first);
diff --git a/tests/test.h b/tests/test.h
index b6900fa..5fbd5cc 100644
--- a/tests/test.h
+++ b/tests/test.h
@@ -119,7 +119,7 @@
   }
 
   void AssertBloatyFails(const std::vector<std::string>& strings,
-                         const std::string& msg_regex) {
+                         const std::string& /*msg_regex*/) {
     // TODO(haberman): verify msg_regex by making all errors logged to a
     // standard place.
     ASSERT_FALSE(TryRunBloaty(strings));