Commit 2bee6e66 authored by liujisi@google.com's avatar liujisi@google.com

Fix build warnings for gcc 4.6

parent ed95d54e
...@@ -295,8 +295,8 @@ void Subprocess::Start(const string& program, SearchMode search_mode) { ...@@ -295,8 +295,8 @@ void Subprocess::Start(const string& program, SearchMode search_mode) {
int stdin_pipe[2]; int stdin_pipe[2];
int stdout_pipe[2]; int stdout_pipe[2];
pipe(stdin_pipe); GOOGLE_CHECK(pipe(stdin_pipe) != -1);
pipe(stdout_pipe); GOOGLE_CHECK(pipe(stdout_pipe) != -1);
char* argv[2] = { strdup(program.c_str()), NULL }; char* argv[2] = { strdup(program.c_str()), NULL };
...@@ -324,9 +324,11 @@ void Subprocess::Start(const string& program, SearchMode search_mode) { ...@@ -324,9 +324,11 @@ void Subprocess::Start(const string& program, SearchMode search_mode) {
// Write directly to STDERR_FILENO to avoid stdio code paths that may do // Write directly to STDERR_FILENO to avoid stdio code paths that may do
// stuff that is unsafe here. // stuff that is unsafe here.
write(STDERR_FILENO, argv[0], strlen(argv[0])); int ignored;
ignored = write(STDERR_FILENO, argv[0], strlen(argv[0]));
const char* message = ": program not found or is not executable\n"; const char* message = ": program not found or is not executable\n";
write(STDERR_FILENO, message, strlen(message)); ignored = write(STDERR_FILENO, message, strlen(message));
(void) ignored;
// Must use _exit() rather than exit() to avoid flushing output buffers // Must use _exit() rather than exit() to avoid flushing output buffers
// that will also be flushed by the parent. // that will also be flushed by the parent.
......
...@@ -1739,7 +1739,7 @@ TEST_F(MiscTest, DefaultValues) { ...@@ -1739,7 +1739,7 @@ TEST_F(MiscTest, DefaultValues) {
message->field(3)->default_value_uint64()); message->field(3)->default_value_uint64());
EXPECT_EQ(4.5 , message->field(4)->default_value_float ()); EXPECT_EQ(4.5 , message->field(4)->default_value_float ());
EXPECT_EQ(10e100 , message->field(5)->default_value_double()); EXPECT_EQ(10e100 , message->field(5)->default_value_double());
EXPECT_EQ(true , message->field(6)->default_value_bool ()); EXPECT_TRUE( message->field(6)->default_value_bool ());
EXPECT_EQ("hello" , message->field(7)->default_value_string()); EXPECT_EQ("hello" , message->field(7)->default_value_string());
EXPECT_EQ("\001\002\003" , message->field(8)->default_value_string()); EXPECT_EQ("\001\002\003" , message->field(8)->default_value_string());
EXPECT_EQ(enum_value_b , message->field(9)->default_value_enum ()); EXPECT_EQ(enum_value_b , message->field(9)->default_value_enum ());
...@@ -1762,7 +1762,7 @@ TEST_F(MiscTest, DefaultValues) { ...@@ -1762,7 +1762,7 @@ TEST_F(MiscTest, DefaultValues) {
EXPECT_EQ(0 , message->field(14)->default_value_uint64()); EXPECT_EQ(0 , message->field(14)->default_value_uint64());
EXPECT_EQ(0.0f , message->field(15)->default_value_float ()); EXPECT_EQ(0.0f , message->field(15)->default_value_float ());
EXPECT_EQ(0.0 , message->field(16)->default_value_double()); EXPECT_EQ(0.0 , message->field(16)->default_value_double());
EXPECT_EQ(false, message->field(17)->default_value_bool ()); EXPECT_FALSE( message->field(17)->default_value_bool ());
EXPECT_EQ("" , message->field(18)->default_value_string()); EXPECT_EQ("" , message->field(18)->default_value_string());
EXPECT_EQ("" , message->field(19)->default_value_string()); EXPECT_EQ("" , message->field(19)->default_value_string());
EXPECT_EQ(enum_value_a, message->field(20)->default_value_enum()); EXPECT_EQ(enum_value_a, message->field(20)->default_value_enum());
...@@ -2167,7 +2167,7 @@ TEST(CustomOptions, OptionTypes) { ...@@ -2167,7 +2167,7 @@ TEST(CustomOptions, OptionTypes) {
options = options =
&protobuf_unittest::CustomOptionMinIntegerValues::descriptor()->options(); &protobuf_unittest::CustomOptionMinIntegerValues::descriptor()->options();
EXPECT_EQ(false , options->GetExtension(protobuf_unittest::bool_opt)); EXPECT_FALSE( options->GetExtension(protobuf_unittest::bool_opt));
EXPECT_EQ(kint32min, options->GetExtension(protobuf_unittest::int32_opt)); EXPECT_EQ(kint32min, options->GetExtension(protobuf_unittest::int32_opt));
EXPECT_EQ(kint64min, options->GetExtension(protobuf_unittest::int64_opt)); EXPECT_EQ(kint64min, options->GetExtension(protobuf_unittest::int64_opt));
EXPECT_EQ(0 , options->GetExtension(protobuf_unittest::uint32_opt)); EXPECT_EQ(0 , options->GetExtension(protobuf_unittest::uint32_opt));
...@@ -2181,7 +2181,7 @@ TEST(CustomOptions, OptionTypes) { ...@@ -2181,7 +2181,7 @@ TEST(CustomOptions, OptionTypes) {
options = options =
&protobuf_unittest::CustomOptionMaxIntegerValues::descriptor()->options(); &protobuf_unittest::CustomOptionMaxIntegerValues::descriptor()->options();
EXPECT_EQ(true , options->GetExtension(protobuf_unittest::bool_opt)); EXPECT_TRUE( options->GetExtension(protobuf_unittest::bool_opt));
EXPECT_EQ(kint32max , options->GetExtension(protobuf_unittest::int32_opt)); EXPECT_EQ(kint32max , options->GetExtension(protobuf_unittest::int32_opt));
EXPECT_EQ(kint64max , options->GetExtension(protobuf_unittest::int64_opt)); EXPECT_EQ(kint64max , options->GetExtension(protobuf_unittest::int64_opt));
EXPECT_EQ(kuint32max, options->GetExtension(protobuf_unittest::uint32_opt)); EXPECT_EQ(kuint32max, options->GetExtension(protobuf_unittest::uint32_opt));
......
...@@ -1007,11 +1007,13 @@ class RepeatedPtrFieldPtrsIteratorTest : public testing::Test { ...@@ -1007,11 +1007,13 @@ class RepeatedPtrFieldPtrsIteratorTest : public testing::Test {
TEST_F(RepeatedPtrFieldPtrsIteratorTest, ConvertiblePtr) { TEST_F(RepeatedPtrFieldPtrsIteratorTest, ConvertiblePtr) {
RepeatedPtrField<string>::pointer_iterator iter = RepeatedPtrField<string>::pointer_iterator iter =
proto_array_.pointer_begin(); proto_array_.pointer_begin();
(void) iter;
} }
TEST_F(RepeatedPtrFieldPtrsIteratorTest, ConvertibleConstPtr) { TEST_F(RepeatedPtrFieldPtrsIteratorTest, ConvertibleConstPtr) {
RepeatedPtrField<string>::const_pointer_iterator iter = RepeatedPtrField<string>::const_pointer_iterator iter =
const_proto_array_->pointer_begin(); const_proto_array_->pointer_begin();
(void) iter;
} }
TEST_F(RepeatedPtrFieldPtrsIteratorTest, MutablePtrIteration) { TEST_F(RepeatedPtrFieldPtrsIteratorTest, MutablePtrIteration) {
...@@ -1136,8 +1138,6 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) { ...@@ -1136,8 +1138,6 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) {
proto_array_.Add()->assign("y"); proto_array_.Add()->assign("y");
{ {
RepeatedPtrField<string>::pointer_iterator iter =
proto_array_.pointer_begin();
string v = "f"; string v = "f";
RepeatedPtrField<string>::pointer_iterator it = RepeatedPtrField<string>::pointer_iterator it =
lower_bound(proto_array_.pointer_begin(), proto_array_.pointer_end(), lower_bound(proto_array_.pointer_begin(), proto_array_.pointer_end(),
...@@ -1149,8 +1149,6 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) { ...@@ -1149,8 +1149,6 @@ TEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) {
EXPECT_TRUE(it == proto_array_.pointer_begin() + 3); EXPECT_TRUE(it == proto_array_.pointer_begin() + 3);
} }
{ {
RepeatedPtrField<string>::const_pointer_iterator iter =
const_proto_array_->pointer_begin();
string v = "f"; string v = "f";
RepeatedPtrField<string>::const_pointer_iterator it = RepeatedPtrField<string>::const_pointer_iterator it =
lower_bound(const_proto_array_->pointer_begin(), lower_bound(const_proto_array_->pointer_begin(),
......
This diff is collapsed.
...@@ -858,6 +858,12 @@ TEST_F(TextFormatParserTest, ParseFieldValueFromString) { ...@@ -858,6 +858,12 @@ TEST_F(TextFormatParserTest, ParseFieldValueFromString) {
EXPECT_EQ(value, message->optional_##name()); \ EXPECT_EQ(value, message->optional_##name()); \
EXPECT_TRUE(message->has_optional_##name()); EXPECT_TRUE(message->has_optional_##name());
#define EXPECT_BOOL_FIELD(name, value, valuestring) \
EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \
valuestring, d->FindFieldByName("optional_" #name), message.get())); \
EXPECT_TRUE(message->optional_##name() == value); \
EXPECT_TRUE(message->has_optional_##name());
#define EXPECT_FLOAT_FIELD(name, value, valuestring) \ #define EXPECT_FLOAT_FIELD(name, value, valuestring) \
EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \ EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \
valuestring, d->FindFieldByName("optional_" #name), message.get())); \ valuestring, d->FindFieldByName("optional_" #name), message.get())); \
...@@ -915,12 +921,12 @@ TEST_F(TextFormatParserTest, ParseFieldValueFromString) { ...@@ -915,12 +921,12 @@ TEST_F(TextFormatParserTest, ParseFieldValueFromString) {
EXPECT_INVALID(fixed64, "1,2"); EXPECT_INVALID(fixed64, "1,2");
// bool // bool
EXPECT_FIELD(bool, true, "true"); EXPECT_BOOL_FIELD(bool, true, "true");
EXPECT_FIELD(bool, false, "false"); EXPECT_BOOL_FIELD(bool, false, "false");
EXPECT_FIELD(bool, true, "1"); EXPECT_BOOL_FIELD(bool, true, "1");
EXPECT_FIELD(bool, true, "t"); EXPECT_BOOL_FIELD(bool, true, "t");
EXPECT_FIELD(bool, false, "0"); EXPECT_BOOL_FIELD(bool, false, "0");
EXPECT_FIELD(bool, false, "f"); EXPECT_BOOL_FIELD(bool, false, "f");
EXPECT_INVALID(bool, "2"); EXPECT_INVALID(bool, "2");
EXPECT_INVALID(bool, "-0"); EXPECT_INVALID(bool, "-0");
EXPECT_INVALID(bool, "on"); EXPECT_INVALID(bool, "on");
...@@ -962,6 +968,7 @@ TEST_F(TextFormatParserTest, ParseFieldValueFromString) { ...@@ -962,6 +968,7 @@ TEST_F(TextFormatParserTest, ParseFieldValueFromString) {
EXPECT_INVALID(nested_message, "any"); EXPECT_INVALID(nested_message, "any");
#undef EXPECT_FIELD #undef EXPECT_FIELD
#undef EXPECT_BOOL_FIELD
#undef EXPECT_FLOAT_FIELD #undef EXPECT_FLOAT_FIELD
#undef EXPECT_DOUBLE_FIELD #undef EXPECT_DOUBLE_FIELD
#undef EXPECT_INVALID #undef EXPECT_INVALID
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment