From 1a3b35f694d8a9fb1f07037f1c04220dd9806a5f Mon Sep 17 00:00:00 2001 From: liulanzheng Date: Fri, 17 Nov 2023 16:21:32 +0800 Subject: [PATCH] fix sign-compares and lz4 include Signed-off-by: liulanzheng --- src/bk_download.cpp | 4 ++-- src/image_file.cpp | 4 ++-- src/image_service.cpp | 2 +- src/overlaybd/cache/ocf_cache/CMakeLists.txt | 2 +- src/overlaybd/extfs/test/test.cpp | 2 +- src/overlaybd/gzindex/test/test.cpp | 6 +++--- src/overlaybd/zfile/compressor.h | 1 - src/prefetch.cpp | 2 +- src/test/simple_credsrv_test.cpp | 2 +- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/bk_download.cpp b/src/bk_download.cpp index f0690ed1..61179082 100644 --- a/src/bk_download.cpp +++ b/src/bk_download.cpp @@ -195,7 +195,7 @@ bool BkDownload::download_blob() { DEFER(free(buff)); LOG_INFO("download blob start. (`)", url); - while (offset < file_size) { + while (offset < (ssize_t)file_size) { if (running != 1) { LOG_INFO("image file exit when background downloading"); return false; @@ -203,7 +203,7 @@ bool BkDownload::download_blob() { if (!force_download) { // check aleady downloaded. auto hole_pos = dst->lseek(offset, SEEK_HOLE); - if (hole_pos >= offset + bs) { + if (hole_pos >= offset + (ssize_t)bs) { // alread downloaded offset += bs; continue; diff --git a/src/image_file.cpp b/src/image_file.cpp index 23e27107..7fa34e29 100644 --- a/src/image_file.cpp +++ b/src/image_file.cpp @@ -341,7 +341,7 @@ LSMT::IFileRO *ImageFile::open_lowers(std::vector &l photon::thread_join(ths[i]); } - for (int i = 0; i < files.size(); i++) { + for (size_t i = 0; i < files.size(); i++) { if (files[i] == NULL) { LOG_ERROR("layer index ` open failed, exit.", i); if (m_exception == "") @@ -367,7 +367,7 @@ LSMT::IFileRO *ImageFile::open_lowers(std::vector &l if (m_exception == "") { m_exception = "failed to create overlaybd device"; } - for (int i = 0; i < lowers.size(); i++) { + for (size_t i = 0; i < lowers.size(); i++) { if (files[i] != NULL) delete files[i]; } diff --git a/src/image_service.cpp b/src/image_service.cpp index 0075b137..d1c6f4a8 100644 --- a/src/image_service.cpp +++ b/src/image_service.cpp @@ -74,7 +74,7 @@ int parse_blob_url(const std::string &url, struct ImageRef &ref) { prev = idx + 1; } ref.seg = std::vector{words[0]}; - for (int i = 2; i + 1 < words.size(); i++) { + for (size_t i = 2; i + 1 < words.size(); i++) { ref.seg.push_back(words[i]); } } diff --git a/src/overlaybd/cache/ocf_cache/CMakeLists.txt b/src/overlaybd/cache/ocf_cache/CMakeLists.txt index 744bd99f..9bdca075 100644 --- a/src/overlaybd/cache/ocf_cache/CMakeLists.txt +++ b/src/overlaybd/cache/ocf_cache/CMakeLists.txt @@ -12,7 +12,7 @@ file(GLOB_RECURSE src_ocf ocf/src/*.c) add_library(ocf_lib STATIC ${src_ocf}) target_include_directories(ocf_lib PUBLIC include/ ease_bindings/env/) target_link_libraries(ocf_lib ocf_env_lib z) -target_compile_options(ocf_lib PUBLIC -Wno-sign-compare) +target_compile_options(ocf_lib PRIVATE -Wno-sign-compare) # ocf_cache_lib file(GLOB src_ocf_cache ocf_cache.cpp ocf_namespace.cpp ease_bindings/*.cpp) diff --git a/src/overlaybd/extfs/test/test.cpp b/src/overlaybd/extfs/test/test.cpp index 11e5b3dc..7b2057a0 100644 --- a/src/overlaybd/extfs/test/test.cpp +++ b/src/overlaybd/extfs/test/test.cpp @@ -57,7 +57,7 @@ int write_file(photon::fs::IFile *file) { while (aa.size() < FILE_SIZE) aa.append(bb); auto ret = file->pwrite(aa.data(), aa.size(), 0); - if (ret != aa.size()) { + if (ret != (ssize_t)aa.size()) { LOG_ERRNO_RETURN(0, -1, "failed write file ", VALUE(aa.size()), VALUE(ret)) } LOG_DEBUG("write ` byte", ret); diff --git a/src/overlaybd/gzindex/test/test.cpp b/src/overlaybd/gzindex/test/test.cpp index 2ef535d7..940da52c 100644 --- a/src/overlaybd/gzindex/test/test.cpp +++ b/src/overlaybd/gzindex/test/test.cpp @@ -139,7 +139,7 @@ class GzIndexTest : public ::testing::Test { if (gzdata == nullptr) { LOG_ERRNO_RETURN(0, -1, "failed to create `", fn_gzdata); } - if (gzdata->pwrite(gzbuf, gzlen, 0) != gzlen) { + if (gzdata->pwrite(gzbuf, gzlen, 0) != (ssize_t)gzlen) { LOG_ERRNO_RETURN(0, -1, "failed to pwrite `", fn_gzdata); } return 0; @@ -373,7 +373,7 @@ class GzCacheTest : public ::testing::Test { if (gzdata == nullptr) { LOG_ERRNO_RETURN(0, -1, "failed to create `", fn_gzdata); } - if (gzdata->pwrite(gzbuf, gzlen, 0) != gzlen) { + if (gzdata->pwrite(gzbuf, gzlen, 0) != (ssize_t)gzlen) { LOG_ERRNO_RETURN(0, -1, "failed to pwrite `", fn_gzdata); } return 0; @@ -446,7 +446,7 @@ TEST_F(GzCacheTest, cache_store) { fread(cbuf1, 1, vsize, fp1); fread(cbuf2, 1, vsize, fp2); // refill_size is 1MB - for (int i = 0; i < vsize; i++) { + for (size_t i = 0; i < vsize; i++) { if (check_in_interval(i, 0, 1 << 20) || check_in_interval(i, vsize - (1 << 20), vsize) || check_in_interval(i, 5 << 20, 6 << 20)) { diff --git a/src/overlaybd/zfile/compressor.h b/src/overlaybd/zfile/compressor.h index a56605b6..bb4899f4 100644 --- a/src/overlaybd/zfile/compressor.h +++ b/src/overlaybd/zfile/compressor.h @@ -20,7 +20,6 @@ #include #include #include -#include "lz4/lz4.h" namespace photon { namespace fs { diff --git a/src/prefetch.cpp b/src/prefetch.cpp index 2922558c..5facb82c 100644 --- a/src/prefetch.cpp +++ b/src/prefetch.cpp @@ -273,7 +273,7 @@ class PrefetcherImpl : public Prefetcher { // Reload content uint32_t checksum = 0; TraceFormat fmt = {}; - for (int i = 0; i < hdr.data_size / sizeof(TraceFormat); ++i) { + for (size_t i = 0; i < hdr.data_size / sizeof(TraceFormat); ++i) { n_read = m_trace_file->read(&fmt, sizeof(TraceFormat)); if (n_read != sizeof(TraceFormat)) { LOG_ERRNO_RETURN(0, -1, "Prefetch: reload content failed"); diff --git a/src/test/simple_credsrv_test.cpp b/src/test/simple_credsrv_test.cpp index 2ebd47cb..acc33934 100644 --- a/src/test/simple_credsrv_test.cpp +++ b/src/test/simple_credsrv_test.cpp @@ -64,7 +64,7 @@ class SimpleAuthHandler : public HTTPHandler { resp.keep_alive(true); photon::thread_sleep(1); auto ret_w = resp.write((void*)msg.c_str(), msg.size()); - if (ret_w != msg.size()) { + if (ret_w != (ssize_t)msg.size()) { LOG_ERRNO_RETURN(0, -1, "send body failed, target: `, `", req.target(), VALUE(ret_w)); } else {