mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-25 18:40:19 -04:00
Fixed false positive warnings from static analysis
The number of buffer and the hash size are always a small number. It never reash the 4 GB limit.
This commit is contained in:
parent
bbfb3415dc
commit
4653dde7c5
2 changed files with 11 additions and 9 deletions
|
|
@ -41,18 +41,19 @@ struct snapraid_hash* hash_alloc(struct snapraid_state* state, struct snapraid_d
|
|||
struct snapraid_hash* hash;
|
||||
block_off_t i;
|
||||
unsigned char* buf;
|
||||
size_t hash_size = BLOCK_HASH_SIZE;
|
||||
|
||||
hash = malloc_nofail(sizeof(struct snapraid_hash));
|
||||
hash->disk = disk;
|
||||
hash->file = file;
|
||||
|
||||
buf = malloc_nofail(file->blockmax * BLOCK_HASH_SIZE);
|
||||
buf = malloc_nofail(file->blockmax * hash_size);
|
||||
|
||||
/* set the back pointer */
|
||||
for (i = 0; i < file->blockmax; ++i) {
|
||||
struct snapraid_block* block = fs_file2block_get(file, i);
|
||||
|
||||
memcpy(buf + i * BLOCK_HASH_SIZE, block->hash, BLOCK_HASH_SIZE);
|
||||
memcpy(buf + i * hash_size, block->hash, hash_size);
|
||||
|
||||
if (!block_has_updated_hash(block)) {
|
||||
free(buf);
|
||||
|
|
@ -61,7 +62,7 @@ struct snapraid_hash* hash_alloc(struct snapraid_state* state, struct snapraid_d
|
|||
}
|
||||
}
|
||||
|
||||
memhash(state->besthash, state->hashseed, hash->hash, buf, file->blockmax * BLOCK_HASH_SIZE);
|
||||
memhash(state->besthash, state->hashseed, hash->hash, buf, file->blockmax * hash_size);
|
||||
|
||||
free(buf);
|
||||
|
||||
|
|
|
|||
13
cmdline/io.c
13
cmdline/io.c
|
|
@ -872,7 +872,8 @@ void io_init(struct snapraid_io* io, struct snapraid_state* state,
|
|||
struct snapraid_parity_handle* parity_handle_map, unsigned parity_handle_max)
|
||||
{
|
||||
unsigned i;
|
||||
size_t allocated;
|
||||
size_t allocated_size;
|
||||
size_t block_size = state->block_size;
|
||||
|
||||
io->state = state;
|
||||
|
||||
|
|
@ -898,18 +899,18 @@ void io_init(struct snapraid_io* io, struct snapraid_state* state,
|
|||
assert(io->io_max == 1 || (io->io_max >= IO_MIN && io->io_max <= IO_MAX));
|
||||
|
||||
io->buffer_max = buffer_max;
|
||||
allocated = 0;
|
||||
allocated_size = 0;
|
||||
for (i = 0; i < io->io_max; ++i) {
|
||||
if (state->file_mode != ADVISE_DIRECT)
|
||||
io->buffer_map[i] = malloc_nofail_vector_align(handle_max, buffer_max, state->block_size, &io->buffer_alloc_map[i]);
|
||||
io->buffer_map[i] = malloc_nofail_vector_align(handle_max, buffer_max, block_size, &io->buffer_alloc_map[i]);
|
||||
else
|
||||
io->buffer_map[i] = malloc_nofail_vector_direct(handle_max, buffer_max, state->block_size, &io->buffer_alloc_map[i]);
|
||||
io->buffer_map[i] = malloc_nofail_vector_direct(handle_max, buffer_max, block_size, &io->buffer_alloc_map[i]);
|
||||
if (!state->opt.skip_self)
|
||||
mtest_vector(io->buffer_max, state->block_size, io->buffer_map[i]);
|
||||
allocated += state->block_size * buffer_max;
|
||||
allocated_size += block_size * buffer_max;
|
||||
}
|
||||
|
||||
msg_progress("Using %u MiB of memory for %u cached blocks.\n", (unsigned)(allocated / MEBI), io->io_max);
|
||||
msg_progress("Using %u MiB of memory for %u cached blocks.\n", (unsigned)(allocated_size / MEBI), io->io_max);
|
||||
|
||||
if (parity_writer) {
|
||||
io->reader_max = handle_max;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue