Skip to content

Commit 41cdb49

Browse files
committed
Resolve code review problems
1 parent 12578a2 commit 41cdb49

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

doc/en/nvmeof_generic_transport.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Assume the metadata service address is `http://127.0.0.1:8080/metadata` (using H
215215
```bash
216216
./build/mooncake-transfer-engine/example/transfer_engine_nvmeof_generic_bench \
217217
--local_server_name=127.0.0.1:8081 \
218-
--metadata_server=http://127.0.0.0.0:8080/metadata \
218+
--metadata_server=http://127.0.0.1:8080/metadata \
219219
--mode=target \
220220
--trtype=tcp \
221221
--traddr=127.0.0.1 \

mooncake-store/src/allocator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ CachelibBufferAllocator::CachelibBufferAllocator(std::string segment_name,
7979

8080
LOG_ASSERT(header_region_start_);
8181

82-
// Add a padding to base to support zero-based buffers.
82+
/// Zero is not a valid buffer base address for CachelibAllocator.
83+
/// Therefore, we add a padding to the base to support zero-based buffers.
8384
auto padded_base = base + facebook::cachelib::Slab::kSize;
8485

8586
// Initialize the CacheLib MemoryAllocator.

mooncake-store/src/client.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,20 @@ static size_t getFileSize(const std::string& file) {
4747
int fd = open(file.c_str(), O_RDONLY);
4848
if (fd < 0) {
4949
LOG(ERROR) << "Failed to open file " << file << ", errno=" << errno;
50-
goto out;
50+
return 0;
5151
}
5252

5353
rc = fstat(fd, &st);
5454
if (rc < 0) {
5555
LOG(ERROR) << "Failed fstat on file " << file << ", errno=" << errno;
56-
goto close_file;
56+
close(fd);
57+
return 0;
5758
}
5859

5960
if (S_ISLNK(st.st_mode)) {
6061
LOG(ERROR) << "File " << file << " is a symbolic link";
61-
goto close_file;
62+
close(fd);
63+
return 0;
6264
}
6365

6466
if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) {
@@ -72,9 +74,7 @@ static size_t getFileSize(const std::string& file) {
7274
size = st.st_size;
7375
}
7476

75-
close_file:
7677
close(fd);
77-
out:
7878
return size;
7979
}
8080

mooncake-transfer-engine/example/transfer_engine_nvmeof_generic_bench.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,17 @@ static size_t getFileSize(const std::string &file) {
268268

269269
int fd = open(file.c_str(), O_RDONLY);
270270
if (fd < 0) {
271-
goto err_out;
271+
return 0;
272272
}
273273

274274
if (fstat(fd, &st) != 0) {
275-
goto err_close_file;
275+
close(fd);
276+
return 0;
276277
}
277278

278279
if (S_ISLNK(st.st_mode)) {
279-
goto err_close_file;
280+
close(fd);
281+
return 0;
280282
}
281283

282284
if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) {
@@ -285,9 +287,7 @@ static size_t getFileSize(const std::string &file) {
285287
size = st.st_size;
286288
}
287289

288-
err_close_file:
289290
close(fd);
290-
err_out:
291291
return size;
292292
}
293293

0 commit comments

Comments
 (0)