Author: thiru Date: Wed Oct 12 15:58:17 2011 New Revision: 1182454 URL: http://svn.apache.org/viewvc?rev=1182454&view=rev Log: AVRO-915. Large number of warnings in C++ buildsc
Modified: avro/trunk/CHANGES.txt avro/trunk/lang/c++/CMakeLists.txt avro/trunk/lang/c++/api/Stream.hh avro/trunk/lang/c++/impl/DataFile.cc avro/trunk/lang/c++/impl/Generic.cc avro/trunk/lang/c++/impl/Resolver.cc avro/trunk/lang/c++/impl/avrogencpp.cc avro/trunk/lang/c++/impl/parsing/JsonCodec.cc avro/trunk/lang/c++/impl/parsing/ResolvingDecoder.cc avro/trunk/lang/c++/impl/parsing/Symbol.hh avro/trunk/lang/c++/test/CodecTests.cc avro/trunk/lang/c++/test/SpecificTests.cc avro/trunk/lang/c++/test/StreamTests.cc Modified: avro/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/CHANGES.txt (original) +++ avro/trunk/CHANGES.txt Wed Oct 12 15:58:17 2011 @@ -113,6 +113,8 @@ Avro 1.6.0 (unreleased) AVRO-840. C++ generate nullable types for optional fields int the schema. (thiru) + AVRO-915. Large number of warnings in C++ builds. (thiru) + BUG FIXES AVRO-824. Java: Fix usage message of BinaryFragmentToJsonTool. Modified: avro/trunk/lang/c++/CMakeLists.txt URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/CMakeLists.txt?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/CMakeLists.txt (original) +++ avro/trunk/lang/c++/CMakeLists.txt Wed Oct 12 15:58:17 2011 @@ -18,6 +18,8 @@ # cmake_minimum_required (VERSION 2.6) +set (CMAKE_LEGACY_CYGWIN_WIN32 0) + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt) file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" AVRO_VERSION) else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt) @@ -34,6 +36,10 @@ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BU project (Avro-cpp) +if (CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "-Wall") +endif () + find_package (Boost 1.38 REQUIRED COMPONENTS regex filesystem system program_options) Modified: avro/trunk/lang/c++/api/Stream.hh URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/api/Stream.hh?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/api/Stream.hh (original) +++ avro/trunk/lang/c++/api/Stream.hh Wed Oct 12 15:58:17 2011 @@ -170,7 +170,7 @@ struct StreamReader { } void skipBytes(size_t n) { - if (n > (end_ - next_)) { + if (n > static_cast<size_t>(end_ - next_)) { n -= end_ - next_; next_ = end_; in_->skip(n); Modified: avro/trunk/lang/c++/impl/DataFile.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/impl/DataFile.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/impl/DataFile.cc (original) +++ avro/trunk/lang/c++/impl/DataFile.cc Wed Oct 12 15:58:17 2011 @@ -131,7 +131,7 @@ DataFileSync DataFileWriterBase::makeSyn } typedef array<uint8_t, 4> Magic; -static Magic magic = { 'O', 'b', 'j', '\x01' }; +static Magic magic = { { 'O', 'b', 'j', '\x01' } }; void DataFileWriterBase::writeHeader() { Modified: avro/trunk/lang/c++/impl/Generic.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/impl/Generic.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/impl/Generic.cc (original) +++ avro/trunk/lang/c++/impl/Generic.cc Wed Oct 12 15:58:17 2011 @@ -286,20 +286,12 @@ static void assertType(const GenericDatu case AVRO_ENUM: assertSameType<GenericEnum>(datum, n); return; - case AVRO_NULL: - case AVRO_BOOL: - case AVRO_INT: - case AVRO_LONG: - case AVRO_FLOAT: - case AVRO_DOUBLE: - case AVRO_STRING: - case AVRO_BYTES: - case AVRO_ARRAY: - case AVRO_MAP: + default: return; } + } else { + typeMismatch(datum.type(), n->type()); } - typeMismatch(datum.type(), n->type()); } GenericWriter::GenericWriter(const ValidSchema& s, const EncoderPtr& encoder) : Modified: avro/trunk/lang/c++/impl/Resolver.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/impl/Resolver.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/impl/Resolver.cc (original) +++ avro/trunk/lang/c++/impl/Resolver.cc Wed Oct 12 15:58:17 2011 @@ -555,7 +555,7 @@ class ResolverFactory : private boost::n Resolver* constructPrimitive(const NodePtr &writer, const NodePtr &reader, const Layout &offset) { - Resolver *instruction; + Resolver *instruction = 0; SchemaResolution match = writer->resolve(*reader); @@ -839,8 +839,10 @@ NonUnionToUnionParser::NonUnionToUnionPa choiceOffset_(offsets.at(0).offset()), setFuncOffset_(offsets.at(1).offset()) { - - SchemaResolution bestMatch = checkUnionMatch(writer, reader, choice_); +#ifndef NDEBUG + SchemaResolution bestMatch = +#endif + checkUnionMatch(writer, reader, choice_); assert(bestMatch != RESOLVE_NO_MATCH); resolver_.reset(factory.construct(writer, reader->leafAt(choice_), offsets.at(choice_+2))); } Modified: avro/trunk/lang/c++/impl/avrogencpp.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/impl/avrogencpp.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/impl/avrogencpp.cc (original) +++ avro/trunk/lang/c++/impl/avrogencpp.cc Wed Oct 12 15:58:17 2011 @@ -73,8 +73,8 @@ class CodeGen { std::ostream& os_; bool inNamespace_; const std::string ns_; - const std::string headerFile_; const std::string schemaFile_; + const std::string headerFile_; const std::string includePrefix_; const bool noUnion_; boost::mt19937 random_; @@ -120,7 +120,7 @@ string CodeGen::generateEnumType(const N { os_ << "enum " << n->name() << " {\n"; size_t c = n->names(); - for (int i = 0; i < c; ++i) { + for (size_t i = 0; i < c; ++i) { os_ << " " << n->nameAt(i) << ",\n"; } os_ << "};\n\n"; @@ -199,7 +199,7 @@ string CodeGen::generateRecordType(const { size_t c = n->leaves(); vector<string> types; - for (int i = 0; i < c; ++i) { + for (size_t i = 0; i < c; ++i) { types.push_back(generateType(n->leafAt(i))); } @@ -210,14 +210,14 @@ string CodeGen::generateRecordType(const os_ << "struct " << n->name() << " {\n"; if (! noUnion_) { - for (int i = 0; i < c; ++i) { + for (size_t i = 0; i < c; ++i) { if (n->leafAt(i)->type() == avro::AVRO_UNION) { os_ << " typedef " << types[i] << ' ' << n->nameAt(i) << "_t;\n"; } } } - for (int i = 0; i < c; ++i) { + for (size_t i = 0; i < c; ++i) { if (! noUnion_ && n->leafAt(i)->type() == avro::AVRO_UNION) { os_ << " " << n->nameAt(i) << "_t"; } else { @@ -395,6 +395,8 @@ string CodeGen::doGenerateType(const Nod return generateEnumType(n); case avro::AVRO_UNION: return generateUnionType(n); + default: + break; } return "$Undefuned$"; } @@ -426,6 +428,8 @@ string CodeGen::generateDeclaration(cons case avro::AVRO_UNION: // FIXME: When can this happen? return generateUnionType(nn); + default: + break; } return "$Undefuned$"; } @@ -446,7 +450,7 @@ void CodeGen::generateEnumTraits(const N void CodeGen::generateRecordTraits(const NodePtr& n) { size_t c = n->leaves(); - for (int i = 0; i < c; ++i) { + for (size_t i = 0; i < c; ++i) { generateTraits(n->leafAt(i)); } @@ -553,6 +557,8 @@ void CodeGen::generateTraits(const NodeP break; case avro::AVRO_FIXED: break; + default: + break; } } Modified: avro/trunk/lang/c++/impl/parsing/JsonCodec.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/impl/parsing/JsonCodec.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/impl/parsing/JsonCodec.cc (original) +++ avro/trunk/lang/c++/impl/parsing/JsonCodec.cc Wed Oct 12 15:58:17 2011 @@ -114,7 +114,7 @@ Production JsonGrammarGenerator::doGener vector<string> nn; size_t c = n->names(); nn.reserve(c); - for (int i = 0; i < c; ++i) { + for (size_t i = 0; i < c; ++i) { nn.push_back(n->nameAt(i)); } Symbol r[] = { @@ -543,7 +543,7 @@ JsonParser::Token JsonParser::tryLiteral { char c[100]; in_.readBytes(reinterpret_cast<uint8_t*>(c), n); - for (int i = 0; i < n; ++i) { + for (size_t i = 0; i < n; ++i) { if (c[i] != exp[i]) { unexpected(c[i]); } @@ -587,6 +587,8 @@ public: throw Exception("Incorrect field"); } break; + default: + break; } return 0; } @@ -1071,6 +1073,8 @@ public: case Symbol::sField: generator_.encodeString(s.extra<string>()); break; + default: + break; } return 0; } Modified: avro/trunk/lang/c++/impl/parsing/ResolvingDecoder.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/impl/parsing/ResolvingDecoder.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/impl/parsing/ResolvingDecoder.cc (original) +++ avro/trunk/lang/c++/impl/parsing/ResolvingDecoder.cc Wed Oct 12 15:58:17 2011 @@ -138,6 +138,8 @@ int ResolvingGrammarGenerator::bestBranc return j; } break; + default: + break; } } return -1; @@ -401,8 +403,9 @@ public: switch (s.kind()) { case Symbol::sWriterUnion: return base_.decodeUnionIndex(); + default: + return 0; } - return 0; } }; Modified: avro/trunk/lang/c++/impl/parsing/Symbol.hh URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/impl/parsing/Symbol.hh?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/impl/parsing/Symbol.hh (original) +++ avro/trunk/lang/c++/impl/parsing/Symbol.hh Wed Oct 12 15:58:17 2011 @@ -319,6 +319,8 @@ void fixup(Symbol& s, const std::map<T, case Symbol::sUnionAdjust: fixup(s.extrap<std::pair<size_t, Production> >()->second, m); break; + default: + break; } } Modified: avro/trunk/lang/c++/test/CodecTests.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/test/CodecTests.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/test/CodecTests.cc (original) +++ avro/trunk/lang/c++/test/CodecTests.cc Wed Oct 12 15:58:17 2011 @@ -341,6 +341,7 @@ static vector<string>::const_iterator sk } } BOOST_FAIL("End reached while trying to skip"); + throw 0; // Just to keep the compiler happy. } static void check(Decoder& d, unsigned int skipLevel, Modified: avro/trunk/lang/c++/test/SpecificTests.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/test/SpecificTests.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/test/SpecificTests.cc (original) +++ avro/trunk/lang/c++/test/SpecificTests.cc Wed Oct 12 15:58:17 2011 @@ -144,7 +144,7 @@ void testBytes() void testFixed() { - array<uint8_t, 5> n = { 1, 7, 23, 47, 83 }; + array<uint8_t, 5> n = { { 1, 7, 23, 47, 83 } }; array<uint8_t, 5> b = encodeAndDecode(n); BOOST_CHECK_EQUAL_COLLECTIONS(b.begin(), b.end(), n.begin(), n.end()); } Modified: avro/trunk/lang/c++/test/StreamTests.cc URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/test/StreamTests.cc?rev=1182454&r1=1182453&r2=1182454&view=diff ============================================================================== --- avro/trunk/lang/c++/test/StreamTests.cc (original) +++ avro/trunk/lang/c++/test/StreamTests.cc Wed Oct 12 15:58:17 2011 @@ -50,7 +50,7 @@ struct Fill1 { void operator()(OutputStream& os, size_t len) { StreamWriter w; w.reset(os); - for (int i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) { w.write(i % 10 + '0'); } w.flush(); @@ -59,7 +59,7 @@ struct Fill1 { struct Fill2 { void operator()(OutputStream& os, size_t len) { - for (int i = 0; i < len;) { + for (size_t i = 0; i < len;) { uint8_t *b; size_t n; os.next(&b, &n); @@ -79,7 +79,7 @@ struct Verify1 { void operator()(InputStream& is, size_t dataSize) { StreamReader r; r.reset(is); - for (int i = 0; i < dataSize; ++i) { + for (size_t i = 0; i < dataSize; ++i) { BOOST_CHECK_EQUAL(i % 10 + '0', r.read()); } BOOST_CHECK_THROW(r.read(), Exception); @@ -91,7 +91,7 @@ struct Verify2 { const uint8_t *b; size_t n; - for (int i = 0; i < len;) { + for (size_t i = 0; i < len;) { BOOST_REQUIRE(is.next(&b, &n)); size_t j = 0; for (; i < len && j < n; ++j, ++i, ++b) { @@ -122,7 +122,7 @@ void testNonEmpty_memoryStream(const Tes void testNonEmpty2(const TestData& td) { std::vector<uint8_t> v; - for (int i = 0; i < td.dataSize; ++i) { + for (size_t i = 0; i < td.dataSize; ++i) { v.push_back(i % 10 + '0'); }