Skip to content

Commit

Permalink
Merge pull request #291 from liulanzheng/main
Browse files Browse the repository at this point in the history
fix sign-compares and lz4 include
  • Loading branch information
yuchen0cc authored Nov 17, 2023
2 parents bd41d6a + 1a3b35f commit 0ff47ea
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/bk_download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ 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;
}
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;
Expand Down
4 changes: 2 additions & 2 deletions src/image_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ LSMT::IFileRO *ImageFile::open_lowers(std::vector<ImageConfigNS::LayerConfig> &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 == "")
Expand All @@ -367,7 +367,7 @@ LSMT::IFileRO *ImageFile::open_lowers(std::vector<ImageConfigNS::LayerConfig> &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];
}
Expand Down
2 changes: 1 addition & 1 deletion src/image_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int parse_blob_url(const std::string &url, struct ImageRef &ref) {
prev = idx + 1;
}
ref.seg = std::vector<std::string>{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]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/overlaybd/cache/ocf_cache/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/overlaybd/extfs/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/overlaybd/gzindex/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down
1 change: 0 additions & 1 deletion src/overlaybd/zfile/compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <cstdlib>
#include <cstdint>
#include <memory>
#include "lz4/lz4.h"

namespace photon {
namespace fs {
Expand Down
2 changes: 1 addition & 1 deletion src/prefetch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/test/simple_credsrv_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0ff47ea

Please sign in to comment.