加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0011-thin_show_duplicates-Fix-potential-errors.patch 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
wangzhiqiang 提交于 2024-07-31 10:43 . backport bugfix patch from community
From 759407445f4e1c31cc0d7bff2881ebd981e2d8fe Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 2 Jun 2021 01:23:13 +0800
Subject: [PATCH] [thin_show_duplicates] Fix potential errors
- Fix error if no --block-sector provided
- Fix errors on pools without mappings, or zero-length file
---
thin-provisioning/thin_show_duplicates.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/thin-provisioning/thin_show_duplicates.cc b/thin-provisioning/thin_show_duplicates.cc
index b1eebb74..f7354eb4 100644
--- a/thin-provisioning/thin_show_duplicates.cc
+++ b/thin-provisioning/thin_show_duplicates.cc
@@ -56,7 +56,7 @@ using namespace thin_provisioning;
namespace {
bool factor_of(block_address f, block_address n) {
- return (n % f) == 0;
+ return f && (n % f) == 0;
}
uint64_t parse_int(string const &str, string const &desc) {
@@ -132,11 +132,15 @@ namespace {
class duplicate_detector {
public:
void scan_with_variable_sized_chunks(chunk_stream &stream) {
+ if (!stream.size())
+ return;
variable_chunk_stream vstream(stream, 4096);
scan(vstream);
}
void scan_with_fixed_sized_chunks(chunk_stream &stream, block_address chunk_size) {
+ if (!stream.size())
+ return;
fixed_chunk_stream fstream(stream, chunk_size);
scan(fstream);
}
@@ -222,7 +226,7 @@ namespace {
if (fs.content_based_chunks)
detector.scan_with_variable_sized_chunks(pstream);
else {
- if (*fs.block_size) {
+ if (!!fs.block_size) {
if (factor_of(*fs.block_size, block_size))
block_size = *fs.block_size;
else
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化