diff options
author | arthurhsu <arthurhsu@google.com> | 2011-07-27 00:52:05 +0000 |
---|---|---|
committer | arthurhsu <arthurhsu@google.com> | 2011-07-27 00:52:05 +0000 |
commit | 2f7e98d7bfe71b69a3c0a7f7d0383f792278e72d (patch) | |
tree | 1613969b75d7638b7da4976ccb5bfc2d895b95cf | |
parent | c93f5d44001a9f7b43981b7e488eabb85ff6c253 (diff) | |
download | sfntly-2f7e98d7bfe71b69a3c0a7f7d0383f792278e72d.tar.gz |
Fix compilation warnings when used by Chrome.
Make sure the warn unused return is not disabled.
-rw-r--r-- | cpp/CMakeLists.txt | 2 | ||||
-rw-r--r-- | cpp/src/sample/subsetter/subset_util.cc | 3 | ||||
-rw-r--r-- | cpp/src/sfntly/port/file_input_stream.cc | 4 | ||||
-rw-r--r-- | cpp/src/test/file_io_test.cc | 6 | ||||
-rw-r--r-- | cpp/src/test/test_font_utils.cc | 3 |
5 files changed, 11 insertions, 7 deletions
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 3a7a2fd..3b52755 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -17,7 +17,7 @@ if(NOT CMAKE_BUILD_TYPE) endif(NOT CMAKE_BUILD_TYPE) # Uncomment the line below to simulate Chrome compilation flags - add_definitions(-DSFNTLY_NO_EXCEPTION -Wall -Werror -fno-exceptions) + add_definitions(-DSFNTLY_NO_EXCEPTION -D__wur=__attribute__\(\(warn_unused_result\)\) -Wall -Werror -fno-exceptions) set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ext/gtest/include ext/gtest) diff --git a/cpp/src/sample/subsetter/subset_util.cc b/cpp/src/sample/subsetter/subset_util.cc index 2266615..013a903 100644 --- a/cpp/src/sample/subsetter/subset_util.cc +++ b/cpp/src/sample/subsetter/subset_util.cc @@ -50,7 +50,8 @@ void SubsetUtil::subset(const char *input_file_path, size_t file_size = ftell(input_file); fseek(input_file, 0, SEEK_SET); input_buffer.resize(file_size); - fread(&(input_buffer[0]), 1, file_size, input_file); + size_t bytes_read = fread(&(input_buffer[0]), 1, file_size, input_file); + UNREFERENCED_PARAMETER(bytes_read); fclose(input_file); ByteArrayPtr ba = new MemoryByteArray(&(input_buffer[0]), file_size); diff --git a/cpp/src/sfntly/port/file_input_stream.cc b/cpp/src/sfntly/port/file_input_stream.cc index d4432bb..04a0fd6 100644 --- a/cpp/src/sfntly/port/file_input_stream.cc +++ b/cpp/src/sfntly/port/file_input_stream.cc @@ -88,8 +88,8 @@ int32_t FileInputStream::read() { #endif } byte_t value; - fread(&value, 1, 1, file_); - position_++; + size_t length = fread(&value, 1, 1, file_); + position_ += length; return value; } diff --git a/cpp/src/test/file_io_test.cc b/cpp/src/test/file_io_test.cc index 68ab4e5..1c02b0a 100644 --- a/cpp/src/test/file_io_test.cc +++ b/cpp/src/test/file_io_test.cc @@ -38,7 +38,8 @@ bool testFileInputStream() { fseek(file_handle, 0, SEEK_SET); ByteVector b1; b1.resize(length); - fread(&(b1[0]), 1, length, file_handle); + size_t bytes_read = fread(&(b1[0]), 1, length, file_handle); + EXPECT_EQ(bytes_read, length); fclose(file_handle); // Full file reading test @@ -98,7 +99,8 @@ bool testFontInputStreamBasic() { fseek(file_handle, 0, SEEK_SET); ByteVector b1; b1.resize(length); - fread(&(b1[0]), 1, length, file_handle); + size_t bytes_read = fread(&(b1[0]), 1, length, file_handle); + EXPECT_EQ(bytes_read, length); fclose(file_handle); FileInputStream is; diff --git a/cpp/src/test/test_font_utils.cc b/cpp/src/test/test_font_utils.cc index 8c3c55f..830f96e 100644 --- a/cpp/src/test/test_font_utils.cc +++ b/cpp/src/test/test_font_utils.cc @@ -63,7 +63,8 @@ void loadFile(const char* input_file_path, ByteVector* input_buffer) { size_t file_size = ftell(input_file); fseek(input_file, 0, SEEK_SET); input_buffer->resize(file_size); - fread(&((*input_buffer)[0]), 1, file_size, input_file); + size_t bytes_read = fread(&((*input_buffer)[0]), 1, file_size, input_file); + EXPECT_EQ(bytes_read, file_size); fclose(input_file); } |