diff options
author | Feng Xiao <xiaofeng@google.com> | 2015-09-08 22:23:03 -0700 |
---|---|---|
committer | Feng Xiao <xiaofeng@google.com> | 2015-09-08 22:23:03 -0700 |
commit | e61ff47ac30f7ce7b06d789f18439d5142ac8c97 (patch) | |
tree | 3805aec82a1be5942f4f8c47b2929841df1b8e99 | |
parent | 0e606bc2eb5258193641d58a1ee7962983b33aa3 (diff) | |
parent | 21f3d3777a921eee1cc3fed2eead0cade51eb0f1 (diff) | |
download | protobuf-e61ff47ac30f7ce7b06d789f18439d5142ac8c97.tar.gz protobuf-e61ff47ac30f7ce7b06d789f18439d5142ac8c97.tar.bz2 protobuf-e61ff47ac30f7ce7b06d789f18439d5142ac8c97.zip |
Merge pull request #802 from bsilver8192/master
Small fixes
-rw-r--r-- | src/google/protobuf/compiler/cpp/cpp_file.cc | 7 | ||||
-rw-r--r-- | src/google/protobuf/testing/googletest.cc | 7 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 5dae4cdd..8e8bd8b7 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -598,8 +598,13 @@ void FileGenerator::GenerateBuildDescriptors(io::Printer* printer) { // bytes in length". Declare a static array of characters rather than use a // string literal. if (breakdown_large_file && file_data.size() > 65535) { + // This has to be explicitly marked as a signed char because the generated + // code puts negative values in the array, and sometimes plain char is + // unsigned. That implicit narrowing conversion is not allowed in C++11. + // <http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin> + // has details on why. printer->Print( - "static const char descriptor[] = {\n"); + "static const signed char descriptor[] = {\n"); printer->Indent(); // Only write 25 bytes per line. diff --git a/src/google/protobuf/testing/googletest.cc b/src/google/protobuf/testing/googletest.cc index b8bd790b..2b9cddef 100644 --- a/src/google/protobuf/testing/googletest.cc +++ b/src/google/protobuf/testing/googletest.cc @@ -94,6 +94,13 @@ string TestSourceDir() { namespace { string GetTemporaryDirectoryName() { + // Tests run under Bazel "should not" use /tmp. Bazel sets this environment + // variable for tests to use instead. + char *from_environment = getenv("TEST_TMPDIR"); + if (from_environment != NULL && from_environment[0] != '\0') { + return string(from_environment) + "/protobuf_tmpdir"; + } + // tmpnam() is generally not considered safe but we're only using it for // testing. We cannot use tmpfile() or mkstemp() since we're creating a // directory. |