[gn][fvm-host] Suppress warnings in test code
[4118->5748/9923 ~58] CXX host-x64-linux-clang/obj/system/utest/fvm-host/fvm-host-test.main.cpp.o
../system/utest/fvm-host/main.cpp:305:5: warning: comparison of integers of different signs: 'const long' and 'const unsigned long' [-Wsign-compare]
ASSERT_EQ(emu_write(fd, data.get(), size), size, "Failed to write data to file");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../system/ulib/unittest/include/unittest/unittest.h:601:45: note: expanded from macro 'ASSERT_EQ'
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../system/ulib/unittest/include/unittest/unittest.h:599:12: note: expanded from macro 'ASSERT_CMP'
UT_CMP(op, lhs, rhs, lhs_str, rhs_str, RET_FALSE, ##__VA_ARGS__)
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../system/ulib/unittest/include/unittest/unittest.h:416:24: note: expanded from macro 'UT_CMP'
if (!(_lhs_val op _rhs_val)) { \
~~~~~~~~ ^ ~~~~~~~~
../system/utest/fvm-host/main.cpp:342:5: warning: comparison of integers of different signs: 'const long' and 'const unsigned long' [-Wsign-compare]
ASSERT_EQ(write(datafd.get(), data.get(), size), size, "Failed to write data to file");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../system/ulib/unittest/include/unittest/unittest.h:601:45: note: expanded from macro 'ASSERT_EQ'
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../system/ulib/unittest/include/unittest/unittest.h:599:12: note: expanded from macro 'ASSERT_CMP'
UT_CMP(op, lhs, rhs, lhs_str, rhs_str, RET_FALSE, ##__VA_ARGS__)
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../system/ulib/unittest/include/unittest/unittest.h:416:24: note: expanded from macro 'UT_CMP'
if (!(_lhs_val op _rhs_val)) { \
~~~~~~~~ ^ ~~~~~~~~
../system/utest/fvm-host/main.cpp:710:11: warning: implicit conversion loses integer precision: 'time_t' (aka 'long') to 'unsigned int' [-Wshorten-64-to-32]
srand(time(0));
~~~~~ ^~~~~~~
3 warnings generated.
ZX-3415 #comment [gn][fvm-host] Suppress warnings in test code
Test: CQ
Change-Id: Ia3014a4cc40fc72ca8bca7dbe55fda244b17029a
diff --git a/zircon/system/utest/fvm-host/main.cpp b/zircon/system/utest/fvm-host/main.cpp
index 5327a27..23afd9e 100644
--- a/zircon/system/utest/fvm-host/main.cpp
+++ b/zircon/system/utest/fvm-host/main.cpp
@@ -302,7 +302,9 @@
ASSERT_GT(fd, 0);
fbl::unique_ptr<uint8_t[]> data;
ASSERT_TRUE(GenerateData(size, &data));
- ASSERT_EQ(emu_write(fd, data.get(), size), size, "Failed to write data to file");
+ ssize_t result = emu_write(fd, data.get(), size);
+ ASSERT_GE(result, 0, "Failed to write data to file");
+ ASSERT_EQ(static_cast<size_t>(result), size, "Failed to write data to file");
ASSERT_EQ(emu_close(fd), 0);
END_HELPER;
}
@@ -339,7 +341,9 @@
ASSERT_TRUE(datafd, "Unable to create new file");
fbl::unique_ptr<uint8_t[]> data;
ASSERT_TRUE(GenerateData(size, &data));
- ASSERT_EQ(write(datafd.get(), data.get(), size), size, "Failed to write data to file");
+ ssize_t result = write(datafd.get(), data.get(), size);
+ ASSERT_GE(result, 0, "Failed to write data to file");
+ ASSERT_EQ(static_cast<size_t>(result), size, "Failed to write data to file");
ASSERT_EQ(blobfs::blobfs_add_blob(bs, nullptr, datafd.get()), ZX_OK, "Failed to add blob");
ASSERT_EQ(unlink(new_file), 0);
END_HELPER;
@@ -707,7 +711,7 @@
bool Setup(uint32_t num_dirs, uint32_t num_files, uint32_t max_size) {
BEGIN_HELPER;
// Generate test directory
- srand(time(0));
+ srand(static_cast<unsigned int>(time(0)));
GenerateDirectory("/tmp/", 20, test_dir);
ASSERT_EQ(mkdir(test_dir, 0755), 0, "Failed to create test path");
unittest_printf("Created test path %s\n", test_dir);