Fix void* arithmetic in memset/memcpy
I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
This commit is contained in:
committed by
Vitaliy Filippov
parent
dd588a0783
commit
7e7b95eeb4
@@ -1257,7 +1257,7 @@ void cluster_client_t::slice_rw(cluster_op_t *op)
|
|||||||
{
|
{
|
||||||
op->bitmap_buf = realloc_or_die(op->bitmap_buf, bitmap_mem);
|
op->bitmap_buf = realloc_or_die(op->bitmap_buf, bitmap_mem);
|
||||||
op->part_bitmaps = (uint8_t*)op->bitmap_buf + object_bitmap_size;
|
op->part_bitmaps = (uint8_t*)op->bitmap_buf + object_bitmap_size;
|
||||||
memset(op->bitmap_buf+op->bitmap_buf_size, 0, bitmap_mem-op->bitmap_buf_size);
|
memset((uint8_t*)op->bitmap_buf+op->bitmap_buf_size, 0, bitmap_mem-op->bitmap_buf_size);
|
||||||
op->bitmap_buf_size = bitmap_mem;
|
op->bitmap_buf_size = bitmap_mem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ void disk_mock_t::erase_buffers(uint64_t begin, uint64_t end)
|
|||||||
{
|
{
|
||||||
// Cut beginning & end & stop
|
// Cut beginning & end & stop
|
||||||
uint8_t *ce = (uint8_t*)malloc_or_die(be-end);
|
uint8_t *ce = (uint8_t*)malloc_or_die(be-end);
|
||||||
memcpy(ce, it->second.iov_base + (end-bs), be-end);
|
memcpy(ce, (uint8_t*)it->second.iov_base + (end-bs), be-end);
|
||||||
uint8_t *cs = (uint8_t*)realloc(it->second.iov_base, begin-bs);
|
uint8_t *cs = (uint8_t*)realloc(it->second.iov_base, begin-bs);
|
||||||
if (!cs)
|
if (!cs)
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
@@ -221,7 +221,7 @@ void disk_mock_t::erase_buffers(uint64_t begin, uint64_t end)
|
|||||||
// Cut end & stop
|
// Cut end & stop
|
||||||
assert(be > end);
|
assert(be > end);
|
||||||
uint8_t *ce = (uint8_t*)malloc_or_die(be-end);
|
uint8_t *ce = (uint8_t*)malloc_or_die(be-end);
|
||||||
memcpy(ce, it->second.iov_base + (end-bs), be-end);
|
memcpy(ce, (uint8_t*)it->second.iov_base + (end-bs), be-end);
|
||||||
buffers[be] = (iovec){ .iov_base = ce, .iov_len = be-end };
|
buffers[be] = (iovec){ .iov_base = ce, .iov_len = be-end };
|
||||||
buffers.erase(it);
|
buffers.erase(it);
|
||||||
break;
|
break;
|
||||||
@@ -308,7 +308,7 @@ void disk_mock_t::read_item(uint8_t *to, uint64_t offset, uint64_t len)
|
|||||||
last = offset;
|
last = offset;
|
||||||
}
|
}
|
||||||
uint64_t cur_end = be < offset+len ? be : offset+len;
|
uint64_t cur_end = be < offset+len ? be : offset+len;
|
||||||
memcpy(to+last-offset, it->second.iov_base+last-bs, cur_end-last);
|
memcpy(to+last-offset, (uint8_t*)it->second.iov_base+last-bs, cur_end-last);
|
||||||
last = be;
|
last = be;
|
||||||
}
|
}
|
||||||
if (last < offset+len)
|
if (last < offset+len)
|
||||||
|
|||||||
Reference in New Issue
Block a user