Beautifies the code.

This commit is contained in:
Andrea Mazzoleni 2014-09-27 00:32:39 +02:00
parent 0583799ad0
commit 876bddcf4c
30 changed files with 649 additions and 630 deletions

View file

@ -102,10 +102,10 @@ static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned d
hash_checked = 0; /* keep track if we check at least one block */
/* check if the recovered blocks are OK */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
/* if we are expected to recover this block */
if (!failed[failed_map[j]].is_outofdate
/* if the block has a hash to check */
/* if the block has a hash to check */
&& block_has_updated_hash(failed[failed_map[j]].block)
) {
/* if a hash doesn't match, fail the check */
@ -142,7 +142,7 @@ static int is_parity_matching(struct snapraid_state* state, unsigned diskmax, un
raid_gen(diskmax, i + 1, state->block_size, buffer);
/* if the recovered parity block matches */
if (memcmp(buffer[diskmax+i], buffer_recov[i], state->block_size) == 0) {
if (memcmp(buffer[diskmax + i], buffer_recov[i], state->block_size) == 0) {
/* recompute all the redundancy information */
raid_gen(diskmax, state->level, state->block_size, buffer);
return 1;
@ -177,16 +177,16 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
error = 0;
/* setup vector of failed disk indexes */
for(i=0;i<failed_count;++i)
for (i = 0; i < failed_count; ++i)
id[i] = failed[failed_map[i]].index;
/* check if there is at least a failed block that can be checked for correctness using the hash */
/* if there isn't, we have to sacrifice a parity block to check that the result is correct */
has_hash = 0;
for(i=0;i<failed_count;++i) {
for (i = 0; i < failed_count; ++i) {
/* if we are expected to recover this block */
if (!failed[failed_map[i]].is_outofdate
/* if the block has a hash to check */
/* if the block has a hash to check */
&& block_has_updated_hash(failed[failed_map[i]].block)
)
has_hash = 1;
@ -202,7 +202,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
combination_first(r, n, ip);
do {
/* if a parity is missing, do nothing */
for(i=0;i<r;++i) {
for (i = 0; i < r; ++i) {
if (buffer_recov[ip[i]] == 0)
break;
}
@ -210,19 +210,19 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
continue;
/* copy the parities to use, one less because the last is used for checking */
for(i=0;i<r-1;++i)
memcpy(buffer[diskmax+ip[i]], buffer_recov[ip[i]], state->block_size);
for (i = 0; i < r - 1; ++i)
memcpy(buffer[diskmax + ip[i]], buffer_recov[ip[i]], state->block_size);
/* recover using one less parity, the ip[r-1] one */
raid_rec_dataonly(r-1, id, ip, diskmax, state->block_size, buffer);
raid_rec_dataonly(r - 1, id, ip, diskmax, state->block_size, buffer);
/* use the remaining ip[r-1] parity to check the result */
if (is_parity_matching(state, diskmax, ip[r-1], buffer, buffer_recov))
if (is_parity_matching(state, diskmax, ip[r - 1], buffer, buffer_recov))
return 0;
/* log */
fprintf(stdlog, "parity_error:%u:", pos);
for(i=0;i<r;++i) {
for (i = 0; i < r; ++i) {
if (i != 0)
fprintf(stdlog, "/");
fprintf(stdlog, "%s", lev_config_name(ip[i]));
@ -242,7 +242,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
combination_first(r, n, ip);
do {
/* if a parity is missing, do nothing */
for(i=0;i<r;++i) {
for (i = 0; i < r; ++i) {
if (buffer_recov[ip[i]] == 0)
break;
}
@ -250,8 +250,8 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
continue;
/* copy the parities to use */
for(i=0;i<r;++i)
memcpy(buffer[diskmax+ip[i]], buffer_recov[ip[i]], state->block_size);
for (i = 0; i < r; ++i)
memcpy(buffer[diskmax + ip[i]], buffer_recov[ip[i]], state->block_size);
/* recover */
raid_rec_dataonly(r, id, ip, diskmax, state->block_size, buffer);
@ -262,7 +262,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
/* log */
fprintf(stdlog, "parity_error:%u:", pos);
for(i=0;i<r;++i) {
for (i = 0; i < r; ++i) {
if (i != 0)
fprintf(stdlog, "/");
fprintf(stdlog, "%s", lev_config_name(ip[i]));
@ -299,7 +299,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
}
/* logs the status */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
const char* state;
const char* hash;
const char* data;
@ -312,8 +312,8 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
case BLOCK_STATE_REP : state = "replace"; break;
case BLOCK_STATE_BLK : state = "block"; break;
/* LCOV_EXCL_START */
default: state = "unknown"; break;
/* LCOV_EXCL_STOP */
default : state = "unknown"; break;
/* LCOV_EXCL_STOP */
}
if (hash_is_invalid(block->hash)) {
@ -360,7 +360,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
n = 0;
something_to_recover = 0; /* keep track if there is at least one block to fix */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
if (failed[j].is_bad) {
unsigned block_state = block_state_get(failed[j].block);
@ -368,7 +368,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* if we have the hash for it */
if ((block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP)
/* try to fetch the block using the known hash */
/* try to fetch the block using the known hash */
&& state_import_fetch(state, rehash, failed[j].block->hash, buffer[failed[j].index]) == 0
) {
/* we already have corrected it! */
@ -399,7 +399,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* if they were BAD we have to use some euristics to ensure that we have recovered */
/* the state after the sync. If unsure, we assume the worst case */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
/* we take care only of BAD blocks we have to write back */
if (failed[j].is_bad) {
unsigned block_state = block_state_get(failed[j].block);
@ -470,7 +470,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
n = 0;
something_to_recover = 0; /* keep track if there is at least one block to fix */
something_unsynced = 0; /* keep track if we have some unsynced info to process */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
unsigned block_state = block_state_get(failed[j].block);
if (block_state == BLOCK_STATE_DELETED
@ -541,7 +541,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* that we don't want to save into disk */
/* we have already marked them, but we redo it for logging */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
/* we take care only of BAD blocks we have to write back */
if (failed[j].is_bad) {
unsigned block_state = block_state_get(failed[j].block);
@ -611,8 +611,8 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
mtest_vector(buffermax, state->block_size, buffer);
/* fill up the zero buffer */
memset(buffer[buffermax-1], 0, state->block_size);
raid_zero(buffer[buffermax-1]);
memset(buffer[buffermax - 1], 0, state->block_size);
raid_zero(buffer[buffermax - 1]);
failed = malloc_nofail(diskmax * sizeof(struct failed_struct));
failed_map = malloc_nofail(diskmax * sizeof(unsigned));
@ -623,12 +623,12 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* first count the number of blocks to process */
countmax = 0;
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
int one_tocheck;
/* for each disk */
one_tocheck = 0;
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
struct snapraid_block* block = BLOCK_EMPTY;
if (handle[j].disk)
block = disk_block_get(handle[j].disk, i);
@ -654,7 +654,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
countsize = 0;
countpos = 0;
state_progress_begin(state, blockstart, blockmax, countmax);
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
unsigned failed_count;
int one_tocheck;
int valid_parity;
@ -663,7 +663,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* for each disk */
one_tocheck = 0;
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
struct snapraid_block* block = BLOCK_EMPTY;
if (handle[j].disk)
block = disk_block_get(handle[j].disk, i);
@ -699,7 +699,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
rehash = info_get_rehash(info);
/* for each disk, process the block */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
int read_size;
unsigned char hash[HASH_SIZE];
struct snapraid_block* block;
@ -913,16 +913,16 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
void* buffer_zero;
/* buffers for parity read and not computed */
for(l=0;l<state->level;++l)
for (l = 0; l < state->level; ++l)
buffer_recov[l] = buffer[diskmax + state->level + l];
for(;l<LEV_MAX;++l)
for (; l < LEV_MAX; ++l)
buffer_recov[l] = 0;
/* the zero buffer is the last one */
buffer_zero = buffer[buffermax-1];
buffer_zero = buffer[buffermax - 1];
/* read the parity */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (parity[l]) {
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, stdlog);
if (ret == -1) {
@ -945,13 +945,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
++unrecoverable_error;
/* print a list of all the errors in files */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
if (failed[j].is_bad)
fprintf(stdlog, "unrecoverable:%u:%s:%s: Unrecoverable error at position %u\n", i, failed[j].handle->disk->name, block_file_get(failed[j].block)->sub, block_file_pos(failed[j].block));
}
/* keep track of damaged files */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
if (failed[j].is_bad)
file_flag_set(block_file_get(failed[j].block), FILE_IS_DAMAGED);
}
@ -962,7 +962,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
int partial_recover_error = 0;
/* print a list of all the errors in files */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
if (failed[j].is_bad && failed[j].is_outofdate) {
++partial_recover_error;
fprintf(stdlog, "unrecoverable:%u:%s:%s: Unrecoverable unsynced error at position %u\n", i, failed[j].handle->disk->name, block_file_get(failed[j].block)->sub, block_file_pos(failed[j].block));
@ -978,7 +978,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* and doesn't make sense to try to fix it */
if (valid_parity) {
/* check the parity */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (buffer_recov[l] != 0 && memcmp(buffer_recov[l], buffer[diskmax + l], state->block_size) != 0) {
buffer_recov[l] = 0;
@ -991,7 +991,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* now writes recovered files */
if (fix) {
/* update the fixed files */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
/* nothing to do if it doesn't need recovering */
if (!failed[j].is_bad)
continue;
@ -1037,7 +1037,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* for blocks that are going to have it computed in the sync completion */
if (valid_parity) {
/* update the parity */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (buffer_recov[l] == 0 && parity[l] != 0) {
ret = parity_write(parity[l], i, buffer[diskmax + l], state->block_size);
if (ret == -1) {
@ -1057,7 +1057,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
}
} else {
/* if we are not fixing, we just set the FIXED flag */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
if (failed[j].is_bad) {
file_flag_set(block_file_get(failed[j].block), FILE_IS_FIXED);
}
@ -1066,7 +1066,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
}
} else {
/* if we are not checking, we just set the DAMAGED flag */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
if (failed[j].is_bad) {
file_flag_set(block_file_get(failed[j].block), FILE_IS_DAMAGED);
}
@ -1075,7 +1075,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* for all the files prints the final status, and does the final time fix */
/* we also ensure to close files after processing the last block */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
struct snapraid_block* block = BLOCK_EMPTY;
struct snapraid_file* collide_file;
struct snapraid_file* file;
@ -1260,7 +1260,7 @@ close_and_continue:
}
/* for each disk, recover empty files, symlinks and empty dirs */
for(i=0;i<diskmax;++i) {
for (i = 0; i < diskmax; ++i) {
tommy_node* node;
struct snapraid_disk* disk;
@ -1306,7 +1306,7 @@ close_and_continue:
} else if (st.st_size != 0) {
unsuccesful = 1;
fprintf(stdlog, "error:%s:%s: Empty file error for size '%"PRIu64"'\n", disk->name, file->sub, st.st_size);
fprintf(stdlog, "error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, file->sub, st.st_size);
++error;
}
@ -1627,7 +1627,7 @@ close_and_continue:
bail:
/* close all the files left open */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
@ -1642,7 +1642,7 @@ bail:
/* it happens only when aborting */
if (fix) {
/* for each disk */
for(i=0;i<diskmax;++i) {
for (i = 0; i < diskmax; ++i) {
tommy_node* node;
struct snapraid_disk* disk;
@ -1800,7 +1800,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
if (fix) {
/* if fixing, create the file and open for writing */
/* if it fails, we cannot continue */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
parity_ptr[l] = &parity[l];
ret = parity_create(parity_ptr[l], state->parity_path[l], &out_size, state->file_mode);
if (ret == -1) {
@ -1821,7 +1821,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
} else if (!state->opt.auditonly) {
/* if checking, open the file for reading */
/* it may fail if the file doesn't exist, in this case we continue to check the files */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
parity_ptr[l] = &parity[l];
ret = parity_open(parity_ptr[l], state->parity_path[l], state->file_mode);
if (ret == -1) {
@ -1832,7 +1832,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
}
} else {
/* otherwise don't use any parity */
for(l=0;l<state->level;++l)
for (l = 0; l < state->level; ++l)
parity_ptr[l] = 0;
}
@ -1857,7 +1857,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
}
/* try to close only if opened */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (parity_ptr[l]) {
ret = parity_close(parity_ptr[l]);
/* LCOV_EXCL_START */

View file

@ -54,9 +54,9 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
countsize = 0;
countpos = 0;
state_progress_begin(state, blockstart, blockmax, countmax);
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
/* for each disk, process the block */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
int read_size;
struct snapraid_block* block = BLOCK_EMPTY;
struct snapraid_disk* disk = handle[j].disk;
@ -112,7 +112,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
}
/* read the parity */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (parity[l]) {
/* until now is CPU */
state_usage_cpu(state);
@ -145,7 +145,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
bail:
/* close all the files left open */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
@ -199,7 +199,7 @@ void state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t
/* open the file for reading */
/* it may fail if the file doesn't exist, in this case we continue to dry the files */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
parity_ptr[l] = &parity[l];
ret = parity_open(parity_ptr[l], state->parity_path[l], state->file_mode);
if (ret == -1) {
@ -223,7 +223,7 @@ void state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t
}
/* try to close only if opened */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (parity_ptr[l]) {
ret = parity_close(parity_ptr[l]);
if (ret == -1) {

View file

@ -49,7 +49,7 @@ struct snapraid_hash* hash_alloc(struct snapraid_state* state, struct snapraid_d
buf = malloc_nofail(file->blockmax * HASH_SIZE);
/* set the back pointer */
for(i=0;i<file->blockmax;++i) {
for (i = 0; i < file->blockmax; ++i) {
memcpy(buf + i * HASH_SIZE, file->blockvec[i].hash, HASH_SIZE);
if (!block_has_updated_hash(&file->blockvec[i])) {
@ -80,6 +80,7 @@ int hash_compare(const void* void_arg, const void* void_data)
{
const char* arg = void_arg;
const struct snapraid_hash* hash = void_data;
return memcmp(arg, hash->hash, HASH_SIZE);
}
@ -100,12 +101,12 @@ void state_dup(struct snapraid_state* state)
printf("Comparing...\n");
/* for each disk */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
tommy_node* j;
struct snapraid_disk* disk = i->data;
/* for each file */
for(j=disk->filelist;j!=0;j=j->next) {
for (j = disk->filelist; j != 0; j = j->next) {
struct snapraid_file* file = j->data;
struct snapraid_hash* hash;
tommy_hash_t hash32;
@ -126,8 +127,8 @@ void state_dup(struct snapraid_state* state)
if (dup) {
++count;
size += dup->file->size;
fprintf(stdlog, "dup:%s:%s:%s:%s:%"PRIu64": dup\n", disk->name, file->sub, dup->disk->name, dup->file->sub, dup->file->size);
printf("%12"PRIu64" %s%s = %s%s\n", file->size, disk->dir, file->sub, dup->disk->dir, dup->file->sub);
fprintf(stdlog, "dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, file->sub, dup->disk->name, dup->file->sub, dup->file->size);
printf("%12" PRIu64 " %s%s = %s%s\n", file->size, disk->dir, file->sub, dup->disk->dir, dup->file->sub);
hash_free(hash);
} else {
tommy_hashdyn_insert(&hashset, &hash->nodeset, hash, hash32);
@ -140,14 +141,14 @@ void state_dup(struct snapraid_state* state)
tommy_hashdyn_done(&hashset);
printf("\n");
printf("%8u duplicates, for %"PRIu64" MiB\n", count, size / (1024*1024));
printf("%8u duplicates, for %" PRIu64 " MiB\n", count, size / (1024 * 1024));
if (count)
printf("There are duplicates!\n");
else
printf("No duplicates\n");
fprintf(stdlog, "summary:dup_count:%u\n", count);
fprintf(stdlog, "summary:dup_size:%"PRIu64"\n", size);
fprintf(stdlog, "summary:dup_size:%" PRIu64 "\n", size);
if (count == 0) {
fprintf(stdlog, "summary:exit:unique\n");
} else {

View file

@ -53,7 +53,7 @@ struct snapraid_filter* filter_alloc_file(int direction, const char* pattern)
/* find first and last slash */
first = 0;
last = 0;
for(i=filter->pattern;*i;++i) {
for (i = filter->pattern; *i; ++i) {
if (*i == '/') {
if (!first)
first = i;
@ -154,7 +154,7 @@ static int filter_recurse(struct snapraid_filter* filter, const char* const_path
/* filter for all the directories */
name = path;
for(i=0;path[i] != 0;++i) {
for (i = 0; path[i] != 0; ++i) {
if (path[i] == '/') {
/* set a terminator */
path[i] = 0;
@ -185,7 +185,7 @@ static int filter_element(tommy_list* filterlist, const char* disk, const char*
int direction = 1; /* by default include all */
/* for each filter */
for(i=tommy_list_head(filterlist);i!=0;i=i->next) {
for (i = tommy_list_head(filterlist); i != 0; i = i->next) {
int ret;
struct snapraid_filter* filter = i->data;
@ -243,7 +243,7 @@ int filter_existence(int filter_missing, const char* dir, const char* sub)
/* we directly check if in the disk the file is present or not */
pathprint(path, sizeof(path), "%s%s", dir, sub);
if (lstat(path, &st) != 0) {
/* if the file doesn't exist, we don't filter it out */
if (errno == ENOENT)
@ -266,12 +266,12 @@ int filter_correctness(int filter_error, tommy_arrayblkof* infoarr, struct snapr
return 0;
/* check each block of the file */
for(i=0;i<file->blockmax;++i) {
for (i = 0; i < file->blockmax; ++i) {
struct snapraid_block* block;
snapraid_info info;
block = &file->blockvec[i];
info = info_get(infoarr, block->parity_pos);
/* if the file has a bad block, don't exclude it */
@ -287,7 +287,7 @@ int filter_content(tommy_list* contentlist, const char* path)
{
tommy_node* i;
for(i=tommy_list_head(contentlist);i!=0;i=i->next) {
for (i = tommy_list_head(contentlist); i != 0; i = i->next) {
struct snapraid_content* content = i->data;
char tmp[PATH_MAX];
@ -394,7 +394,7 @@ struct snapraid_file* file_alloc(unsigned block_size, const char* sub, uint64_t
file->blockvec = malloc_nofail(file->blockmax * sizeof(struct snapraid_block));
/* set the back pointer */
for(i=0;i<file->blockmax;++i) {
for (i = 0; i < file->blockmax; ++i) {
file->blockvec[i].parity_pos = POS_INVALID;
file->blockvec[i].file_mixed = 0;
@ -447,7 +447,7 @@ void file_copy(struct snapraid_file* src_file, struct snapraid_file* dst_file)
/* LCOV_EXCL_STOP */
}
for(i=0;i<dst_file->blockmax;++i) {
for (i = 0; i < dst_file->blockmax; ++i) {
/* set a block with hash computed but without parity */
block_state_set(&dst_file->blockvec[i], BLOCK_STATE_REP);
@ -461,6 +461,7 @@ void file_copy(struct snapraid_file* src_file, struct snapraid_file* dst_file)
const char* file_name(const struct snapraid_file* file)
{
const char* r = strrchr(file->sub, '/');
if (!r)
r = file->sub;
else
@ -472,6 +473,7 @@ int file_inode_compare_to_arg(const void* void_arg, const void* void_data)
{
const uint64_t* arg = void_arg;
const struct snapraid_file* file = void_data;
if (*arg < file->inode)
return -1;
if (*arg > file->inode)
@ -483,6 +485,7 @@ int file_inode_compare(const void* void_a, const void* void_b)
{
const struct snapraid_file* file_a = void_a;
const struct snapraid_file* file_b = void_b;
if (file_a->inode < file_b->inode)
return -1;
if (file_a->inode > file_b->inode)
@ -494,6 +497,7 @@ int file_path_compare(const void* void_a, const void* void_b)
{
const struct snapraid_file* file_a = void_a;
const struct snapraid_file* file_b = void_b;
return strcmp(file_a->sub, file_b->sub);
}
@ -501,6 +505,7 @@ int file_physical_compare(const void* void_a, const void* void_b)
{
const struct snapraid_file* file_a = void_a;
const struct snapraid_file* file_b = void_b;
if (file_a->physical < file_b->physical)
return -1;
if (file_a->physical > file_b->physical)
@ -512,6 +517,7 @@ int file_path_compare_to_arg(const void* void_arg, const void* void_data)
{
const char* arg = void_arg;
const struct snapraid_file* file = void_data;
return strcmp(arg, file->sub);
}
@ -593,6 +599,7 @@ int link_name_compare_to_arg(const void* void_arg, const void* void_data)
{
const char* arg = void_arg;
const struct snapraid_link* link = void_data;
return strcmp(arg, link->sub);
}
@ -600,6 +607,7 @@ int link_alpha_compare(const void* void_a, const void* void_b)
{
const struct snapraid_link* link_a = void_a;
const struct snapraid_link* link_b = void_b;
return strcmp(link_a->sub, link_b->sub);
}
@ -624,6 +632,7 @@ int dir_name_compare(const void* void_arg, const void* void_data)
{
const char* arg = void_arg;
const struct snapraid_dir* dir = void_data;
return strcmp(arg, dir->sub);
}
@ -695,7 +704,7 @@ int disk_is_empty(struct snapraid_disk* disk, block_off_t blockmax)
/* checks all the blocks to search for deleted ones */
/* this search is slow, but it's done only if no file is present */
for(i=0;i<blockmax;++i) {
for (i = 0; i < blockmax; ++i) {
struct snapraid_block* block = tommy_arrayblk_get(&disk->blockarr, i);
unsigned block_state = block_state_get(block);
@ -706,7 +715,7 @@ int disk_is_empty(struct snapraid_disk* disk, block_off_t blockmax)
case BLOCK_STATE_DELETED :
/* if there is a deleted block, the disk is not empty */
return 0;
default:
default :
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inconsistency for used block in disk '%s' without files\n", disk->name);
exit(EXIT_FAILURE);
@ -741,6 +750,7 @@ int info_time_compare(const void* void_a, const void* void_b)
const snapraid_info* info_b = void_b;
time_t time_a = info_get_time(*info_a);
time_t time_b = info_get_time(*info_b);
if (time_a < time_b)
return -1;
if (time_a > time_b)

View file

@ -192,7 +192,7 @@ struct snapraid_block {
* meaning that they don't have any previous content.
* This is important because it means that deleting them, you are not going
* to lose something that cannot be recovered.
* Note that excluded files won't ever get this flag.
* Note that excluded files won't ever get this flag.
*/
#define FILE_IS_CREATED 0x20
@ -256,7 +256,7 @@ struct snapraid_link {
/* nodes for data structures */
tommy_node nodelist;
tommy_hashdyn_node nodeset;
};
};
/**
* Dir.
@ -268,7 +268,7 @@ struct snapraid_dir {
/* nodes for data structures */
tommy_node nodelist;
tommy_hashdyn_node nodeset;
};
};
/**
* Deleted entry.
@ -521,7 +521,7 @@ static inline int hash_is_invalid(const unsigned char* hash)
{
unsigned i;
for(i=0;i<HASH_SIZE;++i)
for (i = 0; i < HASH_SIZE; ++i)
if (hash[i] != 0x00)
return 0;
@ -537,7 +537,7 @@ static inline int hash_is_zero(const unsigned char* hash)
{
unsigned i;
for(i=0;i<HASH_SIZE;++i)
for (i = 0; i < HASH_SIZE; ++i)
if (hash[i] != 0xFF)
return 0;
@ -578,7 +578,7 @@ static inline int block_has_file(const struct snapraid_block* block)
unsigned state = block_state_get(block);
return state == BLOCK_STATE_BLK
|| state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP;
|| state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP;
}
/**
@ -591,7 +591,7 @@ static inline int block_has_invalid_parity(const struct snapraid_block* block)
unsigned state = block_state_get(block);
return state == BLOCK_STATE_DELETED
|| state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP;
|| state == BLOCK_STATE_CHG || state == BLOCK_STATE_REP;
}
/**
@ -862,6 +862,7 @@ static inline snapraid_info info_make(time_t last_access, int error, int rehash)
{
/* clear the lowest bits as reserved for other information */
snapraid_info info = last_access & ~0x3;
if (error != 0)
info |= 0x1;
if (rehash != 0)
@ -930,7 +931,7 @@ static inline void info_set(tommy_arrayblkof* array, unsigned pos, snapraid_info
static inline snapraid_info info_get(tommy_arrayblkof* array, unsigned pos)
{
snapraid_info info;
if (pos >= tommy_arrayblkof_size(array))
return 0;

View file

@ -69,7 +69,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
char path_from[PATH_MAX];
/* check if exists a .unrecoverable copy, and rename to the real one */
pathprint(path_from , sizeof(path_from), "%s.unrecoverable", handle->path);
pathprint(path_from, sizeof(path_from), "%s.unrecoverable", handle->path);
if (rename(path_from, handle->path) == 0) {
/* open for read write */
@ -136,7 +136,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
#if HAVE_POSIX_FADVISE
if ((mode & MODE_SEQUENTIAL) != 0) {
/* advise sequential access */
/* advise sequential access */
ret = posix_fadvise(handle->f, 0, 0, POSIX_FADV_SEQUENTIAL);
if (ret != 0) {
/* LCOV_EXCL_START */
@ -256,7 +256,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
/* check if we are going to read only not initialized data */
if (offset >= handle->valid_size) {
fprintf(out, "Reading missing data from file '%s' at offset %"PRIu64".\n", handle->path, offset);
fprintf(out, "Reading missing data from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
return -1;
}
@ -265,7 +265,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
#if !HAVE_PREAD
if (lseek(handle->f, offset, SEEK_SET) != offset) {
/* LCOV_EXCL_START */
fprintf(out, "Error seeking file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
fprintf(out, "Error seeking file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -282,12 +282,12 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
if (read_ret < 0) {
/* LCOV_EXCL_START */
fprintf(out, "Error reading file '%s' at offset %"PRIu64" for size %u. %s.\n", handle->path, offset + count, read_size - count, strerror(errno));
fprintf(out, "Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, read_size - count, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
if (read_ret == 0) {
fprintf(out, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
fprintf(out, "Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
return -1;
}
@ -382,7 +382,7 @@ struct snapraid_handle* handle_map(struct snapraid_state* state, unsigned* handl
/* get the size of the mapping */
size = 0;
for(i=state->maplist;i!=0;i=i->next) {
for (i = state->maplist; i != 0; i = i->next) {
struct snapraid_map* map = i->data;
if (map->position > size)
size = map->position;
@ -391,7 +391,7 @@ struct snapraid_handle* handle_map(struct snapraid_state* state, unsigned* handl
handle = malloc_nofail(size * sizeof(struct snapraid_handle));
for(j=0;j<size;++j) {
for (j = 0; j < size; ++j) {
/* default for empty position */
handle[j].disk = 0;
handle[j].file = 0;
@ -400,18 +400,18 @@ struct snapraid_handle* handle_map(struct snapraid_state* state, unsigned* handl
}
/* set the vector */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_map* map;
struct snapraid_disk* disk = i->data;
tommy_node* k;
/* search the mapping for this disk */
for(k=state->maplist;k!=0;k=k->next) {
for (k = state->maplist; k != 0; k = k->next) {
map = k->data;
if (strcmp(disk->name, map->name) == 0)
break;
}
if (k==0) {
if (k == 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Internal error for inconsistent disk mapping.\n");
exit(EXIT_FAILURE);

View file

@ -29,6 +29,7 @@ int import_block_hash_compare(const void* void_arg, const void* void_data)
{
const unsigned char* arg = void_arg;
const struct snapraid_import_block* block = void_data;
return memcmp(arg, block->hash, HASH_SIZE);
}
@ -36,6 +37,7 @@ int import_block_prevhash_compare(const void* void_arg, const void* void_data)
{
const unsigned char* arg = void_arg;
const struct snapraid_import_block* block = void_data;
return memcmp(arg, block->prevhash, HASH_SIZE);
}
@ -94,7 +96,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
#endif
offset = 0;
for(i=0;i<file->blockmax;++i) {
for (i = 0; i < file->blockmax; ++i) {
struct snapraid_import_block* block = &file->blockvec[i];
unsigned read_size = block_size;
if (read_size > size)
@ -231,8 +233,8 @@ static void import_dir(struct snapraid_state* state, const char* dir)
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
while (1) {
while (1) {
char path[PATH_MAX];
struct stat st;
const char* name;

View file

@ -40,7 +40,7 @@ void state_list(struct snapraid_state* state)
printf("Listing...\n");
/* for each disk */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
tommy_node* j;
struct snapraid_disk* disk = i->data;
@ -48,7 +48,7 @@ void state_list(struct snapraid_state* state)
tommy_list_sort(&disk->filelist, file_path_compare);
/* for each file */
for(j=disk->filelist;j!=0;j=j->next) {
for (j = disk->filelist; j != 0; j = j->next) {
struct snapraid_file* file = j->data;
#if HAVE_LOCALTIME_R
struct tm tm_res;
@ -59,7 +59,7 @@ void state_list(struct snapraid_state* state)
++file_count;
file_size += file->size;
fprintf(stdlog, "file:%s:%s:%"PRIu64":%"PRIi64":%u:%"PRIi64"\n", disk->name, file->sub, file->size, file->mtime_sec, file->mtime_nsec, file->inode);
fprintf(stdlog, "file:%s:%s:%" PRIu64 ":%" PRIi64 ":%u:%" PRIi64 "\n", disk->name, file->sub, file->size, file->mtime_sec, file->mtime_nsec, file->inode);
t = file->mtime_sec;
#if HAVE_LOCALTIME_R
@ -68,7 +68,7 @@ void state_list(struct snapraid_state* state)
tm = localtime(&t);
#endif
printf("%12"PRIu64" ", file->size);
printf("%12" PRIu64 " ", file->size);
if (tm) {
printf("%04u/%02u/%02u %02u:%02u", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min);
if (state->opt.verbose) {
@ -83,7 +83,7 @@ void state_list(struct snapraid_state* state)
tommy_list_sort(&disk->linklist, link_alpha_compare);
/* for each link */
for(j=disk->linklist;j!=0;j=j->next) {
for (j = disk->linklist; j != 0; j = j->next) {
struct snapraid_link* link = j->data;
const char* type;
@ -93,8 +93,8 @@ void state_list(struct snapraid_state* state)
case FILE_IS_SYMDIR : type = "symdir"; break;
case FILE_IS_JUNCTION : type = "junction"; break;
/* LCOV_EXCL_START */
default: type = "unknown"; break;
/* LCOV_EXCL_STOP */
default : type = "unknown"; break;
/* LCOV_EXCL_STOP */
}
++link_count;
@ -110,11 +110,11 @@ void state_list(struct snapraid_state* state)
}
}
printf("\n");
printf("%8u files, for %"PRIu64" GiB\n", file_count, file_size / (1024*1024*1024));
printf("%8u files, for %" PRIu64 " GiB\n", file_count, file_size / (1024 * 1024 * 1024));
printf("%8u links\n", link_count);
fprintf(stdlog, "summary:file_count:%u\n", file_count);
fprintf(stdlog, "summary:file_size:%"PRIu64"\n", file_size);
fprintf(stdlog, "summary:file_size:%" PRIu64 "\n", file_size);
fprintf(stdlog, "summary:link_count:%u\n", link_count);
fprintf(stdlog, "summary:exit:ok\n");
fflush(stdlog);

View file

@ -113,7 +113,7 @@ void os_init(void)
if (!ntdll) {
fprintf(stderr, "Error loading the NTDLL module.\n");
exit(EXIT_FAILURE);
}
}
/* load functions not always available */
ptr_SetThreadExecutionState = (void*)GetProcAddress(kernel32, "SetThreadExecutionState");
@ -386,7 +386,7 @@ static void windows_info2stat(const BY_HANDLE_FILE_INFORMATION* info, const FILE
st->st_mode = S_IFCHR;
st->st_desc = "reparse-point-nfs";
break;
default:
default :
st->st_mode = S_IFCHR;
st->st_desc = "reparse-point";
break;
@ -486,7 +486,7 @@ static void windows_finddata2stat(const WIN32_FIND_DATAW* info, struct windows_s
st->st_mode = S_IFCHR;
st->st_desc = "reparse-point-nfs";
break;
default:
default :
st->st_mode = S_IFCHR;
st->st_desc = "reparse-point";
break;
@ -546,9 +546,9 @@ static void windows_finddata2dirent(const WIN32_FIND_DATAW* info, struct windows
size_t len;
name = u16tou8(info->cFileName);
len = strlen(name);
if (len + 1 >= sizeof(dirent->d_name)) {
fprintf(stderr, "Name too long\n");
exit(EXIT_FAILURE);
@ -600,7 +600,7 @@ static void windows_errno(DWORD error)
case ERROR_PRIVILEGE_NOT_HELD : /* in CreateSymlinkW if no SeCreateSymbolicLinkPrivilige permission */
errno = EPERM;
break;
default:
default :
fprintf(stderr, "Unexpected Windows error %d.\n", (int)error);
errno = EIO;
break;
@ -619,7 +619,7 @@ int windows_fstat(int fd, struct windows_stat* st)
return -1;
}
if (!GetFileInformationByHandle(h, &info)) {
if (!GetFileInformationByHandle(h, &info)) {
windows_errno(GetLastError());
return -1;
}
@ -699,7 +699,7 @@ int lstat_ex(const char* file, struct windows_stat* st)
return -1;
}
if (!GetFileInformationByHandle(h, &info)) {
if (!GetFileInformationByHandle(h, &info)) {
DWORD error = GetLastError();
CloseHandle(h);
windows_errno(error);
@ -740,7 +740,7 @@ int windows_stat(const char* file, struct windows_stat* st)
return -1;
}
if (!GetFileInformationByHandle(h, &info)) {
if (!GetFileInformationByHandle(h, &info)) {
DWORD error = GetLastError();
CloseHandle(h);
windows_errno(error);
@ -830,7 +830,7 @@ int windows_fsync(int fd)
*/
return 0;
default:
default :
windows_errno(error);
return -1;
}
@ -941,7 +941,7 @@ windows_dir* windows_opendir(const char* dir)
/* add final / and * */
len = wcslen(wdir);
if (len!= 0 && wdir[len-1] != '\\')
if (len != 0 && wdir[len - 1] != '\\')
wdir[len++] = L'\\';
wdir[len++] = L'*';
wdir[len++] = 0;
@ -1063,27 +1063,27 @@ int windows_symlink(const char* existing, const char* file)
#endif
#ifndef REPARSE_DATA_BUFFER_HEADER_SIZE
typedef struct _REPARSE_DATA_BUFFER {
DWORD ReparseTag;
WORD ReparseDataLength;
WORD Reserved;
DWORD ReparseTag;
WORD ReparseDataLength;
WORD Reserved;
_ANONYMOUS_UNION union {
struct {
WORD SubstituteNameOffset;
WORD SubstituteNameLength;
WORD PrintNameOffset;
WORD PrintNameLength;
ULONG Flags;
WORD SubstituteNameOffset;
WORD SubstituteNameLength;
WORD PrintNameOffset;
WORD PrintNameLength;
ULONG Flags;
WCHAR PathBuffer[1];
} SymbolicLinkReparseBuffer;
struct {
WORD SubstituteNameOffset;
WORD SubstituteNameLength;
WORD PrintNameOffset;
WORD PrintNameLength;
WORD SubstituteNameOffset;
WORD SubstituteNameLength;
WORD PrintNameOffset;
WORD PrintNameLength;
WCHAR PathBuffer[1];
} MountPointReparseBuffer;
struct {
BYTE DataBuffer[1];
BYTE DataBuffer[1];
} GenericReparseBuffer;
} DUMMYUNIONNAME;
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
@ -1129,7 +1129,7 @@ int windows_readlink(const char* file, char* buffer, size_t size)
/* convert the name to UTF-8 */
name = u16tou8n(rdb->SymbolicLinkReparseBuffer.PathBuffer + rdb->SymbolicLinkReparseBuffer.PrintNameOffset,
rdb->SymbolicLinkReparseBuffer.PrintNameLength / 2, &len);
rdb->SymbolicLinkReparseBuffer.PrintNameLength / 2, &len);
/* check for overflow */
if (len > size) {

View file

@ -25,7 +25,7 @@
*/
unsigned long long seed = 0;
unsigned rnd(unsigned max)
unsigned rnd(unsigned max)
{
seed = seed * 6364136223846793005LL + 1442695040888963407LL;
@ -43,7 +43,8 @@ unsigned rndnz(unsigned max)
void rndnz_range(unsigned char* data, int size)
{
int i;
for(i=0;i<size;++i)
for (i = 0; i < size; ++i)
data[i] = rndnz(256);
}
@ -52,7 +53,7 @@ void rndnz_damage(unsigned char* data, int size)
int i;
/* corrupt ensuring always different data */
for(i=0;i<size;++i) {
for (i = 0; i < size; ++i) {
unsigned char c;
do {
@ -64,11 +65,12 @@ void rndnz_damage(unsigned char* data, int size)
}
char CHARSET[] = "qwertyuiopasdfghjklzxcvbnm1234567890 .-+";
#define CHARSET_LEN (sizeof(CHARSET)-1)
#define CHARSET_LEN (sizeof(CHARSET) - 1)
void rnd_name(char* file)
{
int l = 1 + rnd(20);
while (l) {
*file++ = CHARSET[rnd(CHARSET_LEN)];
--l;
@ -252,8 +254,8 @@ void cmd_generate(int disk, int size)
|| strcmp(file, "nul") == 0
|| strcmp(file, "aux") == 0
|| file[0] == ' '
|| file[strlen(file)-1] == ' '
|| file[strlen(file)-1] == '.'
|| file[strlen(file) - 1] == ' '
|| file[strlen(file) - 1] == '.'
) {
continue;
}
@ -282,7 +284,7 @@ void cmd_generate(int disk, int size)
* - The file must exist.
* - The file size is not changed.
* - The written data may be equal or not at the already existing one.
* - If it's a symlink nothing is done.
* - If it's a symlink nothing is done.
*/
void cmd_write(const char* path, int size)
{
@ -663,16 +665,16 @@ int main(int argc, char* argv[])
file = atoi(argv[4]);
size = atoi(argv[5]);
for(i=0;i<disk;++i) {
for(j=0;j<file;++j) {
for (i = 0; i < disk; ++i) {
for (j = 0; j < file; ++j) {
if (j == 0)
/* create at least a big one */
cmd_generate(i+1, size);
cmd_generate(i + 1, size);
else if (j == 1)
/* create at least an empty one */
cmd_generate(i+1, 0);
cmd_generate(i + 1, 0);
else
cmd_generate(i+1, rnd(size));
cmd_generate(i + 1, rnd(size));
}
}
} else if (strcmp(argv[1], "write") == 0) {
@ -691,10 +693,10 @@ int main(int argc, char* argv[])
b = 5;
/* sort the file names */
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
for(i=b;i<argc;++i)
for(j=0;j<fail;++j)
for (i = b; i < argc; ++i)
for (j = 0; j < fail; ++j)
cmd_write(argv[i], rnd(size));
} else if (strcmp(argv[1], "damage") == 0) {
int fail, size;
@ -712,10 +714,10 @@ int main(int argc, char* argv[])
b = 5;
/* sort the file names */
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
for(i=b;i<argc;++i)
for(j=0;j<fail;++j)
for (i = b; i < argc; ++i)
for (j = 0; j < fail; ++j)
cmd_damage(argv[i], rndnz(size)); /* at least one byte */
} else if (strcmp(argv[1], "append") == 0) {
int size;
@ -732,9 +734,9 @@ int main(int argc, char* argv[])
b = 4;
/* sort the file names */
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
for(i=b;i<argc;++i)
for (i = b; i < argc; ++i)
cmd_append(argv[i], rnd(size));
} else if (strcmp(argv[1], "truncate") == 0) {
int size;
@ -751,9 +753,9 @@ int main(int argc, char* argv[])
b = 4;
/* sort the file names */
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
for(i=b;i<argc;++i)
for (i = b; i < argc; ++i)
cmd_truncate(argv[i], rnd(size));
} else if (strcmp(argv[1], "change") == 0) {
int size;
@ -770,9 +772,9 @@ int main(int argc, char* argv[])
b = 4;
/* sort the file names */
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
qsort(&argv[b], argc - b, sizeof(argv[b]), file_cmp);
for(i=b;i<argc;++i)
for (i = b; i < argc; ++i)
cmd_change(argv[i], rnd(size));
} else {
/* LCOV_EXCL_START */

View file

@ -44,25 +44,25 @@ static inline uint32_t fmix32(uint32_t h)
* Don't declare these variables static, otherwise the gcc optimizer
* may generate very slow code for multiplication with these constants,
* like:
-> .cpp
k1 *= c1;
-> .asm
152: 8d 14 80 lea (%eax,%eax,4),%edx
155: 8d 14 90 lea (%eax,%edx,4),%edx
158: c1 e2 03 shl $0x3,%edx
15b: 29 c2 sub %eax,%edx
15d: 8d 14 d2 lea (%edx,%edx,8),%edx
160: 8d 14 90 lea (%eax,%edx,4),%edx
163: 8d 14 d0 lea (%eax,%edx,8),%edx
166: 8d 14 90 lea (%eax,%edx,4),%edx
169: 8d 14 50 lea (%eax,%edx,2),%edx
16c: 8d 14 90 lea (%eax,%edx,4),%edx
16f: 8d 14 92 lea (%edx,%edx,4),%edx
172: 8d 14 50 lea (%eax,%edx,2),%edx
175: 8d 04 d0 lea (%eax,%edx,8),%eax
178: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
17f: 29 d0 sub %edx,%eax
-> .cpp
k1 *= c1;
-> .asm
152: 8d 14 80 lea (%eax,%eax,4),%edx
155: 8d 14 90 lea (%eax,%edx,4),%edx
158: c1 e2 03 shl $0x3,%edx
15b: 29 c2 sub %eax,%edx
15d: 8d 14 d2 lea (%edx,%edx,8),%edx
160: 8d 14 90 lea (%eax,%edx,4),%edx
163: 8d 14 d0 lea (%eax,%edx,8),%edx
166: 8d 14 90 lea (%eax,%edx,4),%edx
169: 8d 14 50 lea (%eax,%edx,2),%edx
16c: 8d 14 90 lea (%eax,%edx,4),%edx
16f: 8d 14 92 lea (%edx,%edx,4),%edx
172: 8d 14 50 lea (%eax,%edx,2),%edx
175: 8d 04 d0 lea (%eax,%edx,8),%eax
178: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
17f: 29 d0 sub %edx,%eax
* resulting in speeds of 500 MB/s instead of 3000 MB/s.
*
@ -98,7 +98,7 @@ void MurmurHash3_x86_128(const void* key, unsigned len, const uint8_t* seed, voi
/* body */
for(i=0;i<nblocks;++i) {
for (i = 0; i < nblocks; ++i) {
uint32_t k1 = blocks[0];
uint32_t k2 = blocks[1];
uint32_t k3 = blocks[2];
@ -111,21 +111,21 @@ void MurmurHash3_x86_128(const void* key, unsigned len, const uint8_t* seed, voi
k4 = util_swap32(k4);
#endif
k1 *= c1; k1 = util_rotl32(k1,15); k1 *= c2; h1 ^= k1;
k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1;
h1 = util_rotl32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b;
h1 = util_rotl32(h1, 19); h1 += h2; h1 = h1 * 5 + 0x561ccd1b;
k2 *= c2; k2 = util_rotl32(k2,16); k2 *= c3; h2 ^= k2;
k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2;
h2 = util_rotl32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747;
h2 = util_rotl32(h2, 17); h2 += h3; h2 = h2 * 5 + 0x0bcaa747;
k3 *= c3; k3 = util_rotl32(k3,17); k3 *= c4; h3 ^= k3;
k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3;
h3 = util_rotl32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35;
h3 = util_rotl32(h3, 15); h3 += h4; h3 = h3 * 5 + 0x96cd1c35;
k4 *= c4; k4 = util_rotl32(k4,18); k4 *= c1; h4 ^= k4;
k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4;
h4 = util_rotl32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
h4 = util_rotl32(h4, 13); h4 += h1; h4 = h4 * 5 + 0x32ac3b17;
blocks += 4;
}
@ -143,23 +143,23 @@ void MurmurHash3_x86_128(const void* key, unsigned len, const uint8_t* seed, voi
case 15 : k4 ^= tail[14] << 16;
case 14 : k4 ^= tail[13] << 8;
case 13 : k4 ^= tail[12] << 0;
k4 *= c4; k4 = util_rotl32(k4,18); k4 *= c1; h4 ^= k4;
k4 *= c4; k4 = util_rotl32(k4, 18); k4 *= c1; h4 ^= k4;
case 12 : k3 ^= tail[11] << 24;
case 11 : k3 ^= tail[10] << 16;
case 10 : k3 ^= tail[ 9] << 8;
case 9 : k3 ^= tail[ 8] << 0;
k3 *= c3; k3 = util_rotl32(k3,17); k3 *= c4; h3 ^= k3;
k3 *= c3; k3 = util_rotl32(k3, 17); k3 *= c4; h3 ^= k3;
case 8 : k2 ^= tail[ 7] << 24;
case 7 : k2 ^= tail[ 6] << 16;
case 6 : k2 ^= tail[ 5] << 8;
case 5 : k2 ^= tail[ 4] << 0;
k2 *= c2; k2 = util_rotl32(k2,16); k2 *= c3; h2 ^= k2;
k2 *= c2; k2 = util_rotl32(k2, 16); k2 *= c3; h2 ^= k2;
case 4 : k1 ^= tail[ 3] << 24;
case 3 : k1 ^= tail[ 2] << 16;
case 2 : k1 ^= tail[ 1] << 8;
case 1 : k1 ^= tail[ 0] << 0;
k1 *= c1; k1 = util_rotl32(k1,15); k1 *= c2; h1 ^= k1;
};
k1 *= c1; k1 = util_rotl32(k1, 15); k1 *= c2; h1 ^= k1;
}
}
/* finalization */

View file

@ -261,3 +261,4 @@
{ "\x12\x75\x7c\xa3\xe7\x74\x65\x23\x81\x28\xf1\x5b\x1f\x2d\x8b\x6f\x44\xe0\xcd\x2d\xd8\xdb\x77\x16\x6c\x0b\x7b\x0d\x9b\x70\x34\x9b\x8c\x71\xb7\xdd\x93\xda\x42\x0b\xf7\x73\xd2\xa5\xce\x3e\xd1\x3c\x05\x4c\xeb\xda\x7c\x3c\x01\x0f\x4e\x51\x37\x99\x2e\x2f\x28\xaf\xed\x32\x39\xea\x18\x6b\x0b\xd0\xbd\x39\x0a\xff\x4e\x7f\x22\xf3\x9f\x87\x92\x74\x0a\x73\xd8\x9f\xb2\x5b\xcc\x8e\xe4\x08\xc9\xa7\x99\x4c\x06\x7e\x18\xfc\x02\x68\xb8\x8c\x1e\x9d\xc3\x45\x44\x08\x77\x25\xc5\xaf\x26\x53\x41\xba\x7d\x3d\xbf\x22\xe1\x50\xdd\xf7\xf5\x53\x21\x4d\x38\x61\x6d\xc4\xcc\x81\x91\xb3\x51\xe3\xfb\xf1\xf0\xba\x89\x3f\x74\xb0\x7f\x55\x92\x0a\x94\x88\x49\x5a\x27\x14\x64\xdb\x8f\x0c\x1d\x6c\x90\xdb\xdc\x2c\xe9\x76\x1d\xae\x09\x20\x6f\xd9\xe2\xd9\x98\x5f\xd7\x64\xd6\xd8\xcf\xf4\x40\x7a\x6b\x72\x4b\x77\x54\x6d\x69\xf4\xad\x9f\xcc\xa1\xa8\x18\x49\xf9\x34\x0a\x57\x18\xd4\x30\x36\x34\x8b\xdb\x2c\xb9\xf4\x9a\xea\x05\x6e\x85\x0e\xbd\x73\x26\xc2\xca\x0a\x05\x81\xf4\x53\xcf\xfa\x19\x40\x22\x0d\x09\x63\xf8\xf2\x01\xe1\xad\x79\xc3\x86\xae\x6b\x4e", 254, { 0xce, 0x3c, 0x1c, 0xb0, 0xc1, 0xd5, 0x9a, 0x1f, 0xad, 0x95, 0x57, 0x98, 0xc6, 0x74, 0x61, 0x10 } },
{ "\xf3\xc0\x10\x3f\xf2\xea\xca\xc4\xea\x01\xdf\x39\x6d\xce\x54\x61\xef\xdd\xf4\x42\x92\xe5\x70\x9d\x1c\xcf\xa0\x08\x0a\x65\xe8\xaa\xbe\x98\xb6\x93\xd3\x6d\x27\xb5\x91\x86\xc9\x83\x7c\x49\x7b\x25\x07\xaf\x71\x55\x66\xab\x54\xd9\x81\x34\x86\x9d\x04\xf1\x83\x6c\x93\x80\x63\x4b\x1b\x64\x7b\x72\x44\x89\x24\xe8\x02\x74\x93\xba\x4b\x0b\xe7\xd7\xe3\xfe\x42\x8b\x53\xd1\x0e\x96\xf8\x88\x61\xe9\x37\xee\x7b\xfc\xce\x81\x6c\xce\x46\xfd\xd3\x7a\x84\x83\xc1\x73\x7f\x66\xbb\x5c\x0c\x93\xde\x86\xd6\x9a\x1d\x07\x69\x5d\xa6\x73\x6d\x54\x64\x3a\xef\x7a\x9d\x9e\xdb\xd7\xba\x4f\x86\xab\x27\xa4\x68\x34\x51\x78\xe7\x1c\xcc\x9f\x4e\x83\x97\x04\xdc\xa4\x77\x61\xf9\x26\x7f\x99\x84\x01\xb1\xb5\x47\x0b\xbf\x79\x8c\x1f\xea\xa2\xc9\xe8\x0c\xbf\x76\x4f\xb1\xa9\xff\x7f\x5f\xa1\xd5\x91\xf6\x04\xa0\xd9\x32\xad\x8f\xcc\x4e\xe7\xcf\x8c\xc3\x0d\x19\x12\x2f\xc1\x66\xf7\x50\xc5\xbe\xdf\x2f\x79\x2e\x83\x59\xf1\xd8\x59\x48\xb2\x24\xe1\xe1\x0a\x15\x8e\x17\x09\xb6\x50\xad\x1f\xb3\xba\x18\x54\x03\xd5\x82\x1e\xc3\x80\xeb\xe2\x1f\x82\x6a\x0a\x69\x2e\x92", 255, { 0xbb, 0x05, 0x2f, 0x98, 0xc3, 0x43, 0x0a, 0x44, 0x7d, 0xae, 0x93, 0xea, 0x0a, 0x81, 0x4e, 0x3a } },
{ "\xbf\x4b\xb1\xf0\x43\x19\xfc\xb0\xee\x40\x48\x5f\xc3\xdc\x4a\xca\xaf\x65\xf5\x06\x5d\x88\xe7\x89\xb8\x14\x71\x76\xfe\x0b\x46\xf6\x7e\xd9\xbf\xc1\xee\xa1\xc8\xbd\x6b\xb2\x6b\xbd\x0d\x18\xf7\x6a\x26\x4f\xcc\x3f\x18\x13\xc6\xae\xd0\x53\x44\x60\xe3\x43\xd4\x9a\x43\x91\x7c\xbb\x9d\xaf\xa7\xe1\x53\x4f\xab\xac\x11\xed\xf3\x1a\x0e\x85\xce\x92\xe1\x66\xd3\xfc\xfd\x1f\xee\x0d\xcb\x95\x0c\xa0\x63\x36\x5f\x40\xe6\x48\x4e\xc2\x7a\x5b\xfd\x0f\xe3\xdd\x74\x00\xbb\xcc\x6e\x62\x4e\x86\xc0\x18\x14\xbc\x64\x60\xcb\x85\x22\x2e\x31\x8f\xda\xb4\x5b\x70\x70\x03\xb5\x1a\x54\xcb\x97\x6d\xac\x3e\x7f\xe7\x21\x13\xf1\x77\x43\xa7\xe8\x6f\x9a\x3e\xf7\x97\x4a\x66\x01\x5d\x62\x7c\x91\x2a\xc1\x48\xd7\xd1\xa5\xc4\x40\x21\xd1\xfa\xb1\x9a\x5b\x0b\x5f\x3c\x0f\x4b\x4d\x7a\x83\x8a\x63\x4e\xb9\x6e\x28\x66\x6a\xfc\x1d\x7c\xf5\x35\xb5\xc3\xe4\xdd\xf4\x7d\x16\x57\xa2\xa9\x8f\xab\x2c\xda\xd9\xaa\x18\x23\x14\x29\x23\x2f\xa1\x69\xf9\x6d\x67\x97\x91\x68\xc0\x6e\x22\x34\x04\xfa\xc5\x04\xb0\x78\xa8\xd9\x32\x5a\xec\x55\x53\x66\x1d\xae\x41\xfe\x4b\xbe\x38\x7a", 256, { 0x64, 0xe1, 0xfd, 0x82, 0x3c, 0xe4, 0x10, 0x8b, 0x41, 0xca, 0x5d, 0xff, 0xed, 0x9f, 0x47, 0x22 } },

View file

@ -29,12 +29,12 @@ void state_nano(struct snapraid_state* state)
printf("Setting nanosecond timestamps...\n");
/* for all disks */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
tommy_node* j;
/* for all files */
for(j=disk->filelist;j!=0;j=j->next) {
for (j = disk->filelist; j != 0; j = j->next) {
struct snapraid_file* file = j->data;
/* if the file has a zero nanosecond timestamp */

View file

@ -32,7 +32,7 @@ block_off_t parity_size(struct snapraid_state* state)
/* compute the size of the parity file */
parity_block = 0;
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
/* start from the declared size */
@ -66,12 +66,12 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
blockalloc = size / state->block_size;
/* for all disks */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
tommy_node* j;
/* for all files */
for(j=disk->filelist;j!=0;j=j->next) {
for (j = disk->filelist; j != 0; j = j->next) {
struct snapraid_file* file = j->data;
if (file->blockmax > 0) {
@ -212,9 +212,9 @@ int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* o
if (f_ret != 0) {
/* LCOV_EXCL_START */
if (f_errno == ENOSPC) {
fprintf(stderr, "Failed to grow parity file '%s' to size %"PRIu64" using %s due lack of space.\n", parity->path, size, call);
fprintf(stderr, "Failed to grow parity file '%s' to size %" PRIu64 " using %s due lack of space.\n", parity->path, size, call);
} else {
fprintf(stderr, "Error growing parity file '%s' to size %"PRIu64" using %s. Do you have enough space? %s.\n", parity->path, size, call, strerror(f_errno));
fprintf(stderr, "Error growing parity file '%s' to size %" PRIu64 " using %s. Do you have enough space? %s.\n", parity->path, size, call, strerror(f_errno));
}
goto bail;
/* LCOV_EXCL_STOP */
@ -245,7 +245,7 @@ int parity_chsize(struct snapraid_parity* parity, data_off_t size, data_off_t* o
/* now check the error */
if (f_ret != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error truncating parity file '%s' to size %"PRIu64". %s.\n", parity->path, size, strerror(f_errno));
fprintf(stderr, "Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", parity->path, size, strerror(f_errno));
goto bail;
/* LCOV_EXCL_STOP */
}
@ -419,14 +419,14 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char*
/* check if we are going to read only not initialized data */
if (offset >= parity->valid_size) {
fprintf(out, "Reading missing data from file '%s' at offset %"PRIu64".\n", parity->path, offset);
fprintf(out, "Reading missing data from file '%s' at offset %" PRIu64 ".\n", parity->path, offset);
return -1;
}
#if !HAVE_PREAD
if (lseek(parity->f, offset, SEEK_SET) != offset) {
/* LCOV_EXCL_START */
fprintf(out, "Error seeking file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
fprintf(out, "Error seeking file '%s' at offset %" PRIu64 ". %s.\n", parity->path, offset, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -442,13 +442,13 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char*
#endif
if (read_ret < 0) {
/* LCOV_EXCL_START */
fprintf(out, "Error reading file '%s' at offset %"PRIu64" for size %u. %s.\n", parity->path, offset + count, block_size - count, strerror(errno));
fprintf(out, "Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", parity->path, offset + count, block_size - count, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
if (read_ret == 0) {
/* LCOV_EXCL_START */
fprintf(out, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
fprintf(out, "Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", parity->path, offset, strerror(errno));
return -1;
/* LCOV_EXCL_STOP */
}
@ -464,4 +464,3 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char*
return block_size;
}

View file

@ -37,8 +37,8 @@ static int clean_dir(struct snapraid_state* state, const char* dir)
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
while (1) {
while (1) {
char path_next[PATH_MAX];
struct stat st;
const char* name;
@ -220,19 +220,19 @@ void state_pool(struct snapraid_state* state)
/* for each disk */
count = 0;
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
tommy_node* j;
struct snapraid_disk* disk = i->data;
/* for each file */
for(j=disk->filelist;j!=0;j=j->next) {
for (j = disk->filelist; j != 0; j = j->next) {
struct snapraid_file* file = j->data;
make_link(pool_dir, share_dir, disk, file->sub);
++count;
}
/* for each link */
for(j=disk->linklist;j!=0;j=j->next) {
for (j = disk->linklist; j != 0; j = j->next) {
struct snapraid_link* link = j->data;
make_link(pool_dir, share_dir, disk, link->sub);
++count;

View file

@ -176,9 +176,9 @@
#endif
#if HAVE_GETOPT_LONG
#define SWITCH_GETOPT_LONG(a,b) a
#define SWITCH_GETOPT_LONG(a, b) a
#else
#define SWITCH_GETOPT_LONG(a,b) b
#define SWITCH_GETOPT_LONG(a, b) b
#endif
/**

View file

@ -59,7 +59,7 @@ void state_rehash(struct snapraid_state* state)
randomize(state->hashseed, HASH_SIZE);
/* mark all the block for rehashing */
for(i=0;i<blockmax;++i) {
for (i = 0; i < blockmax; ++i) {
snapraid_info info;
/* if it's unused */

View file

@ -167,7 +167,7 @@ static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_fil
state->need_write = 1;
/* free all the blocks of the file */
for(i=0;i<file->blockmax;++i) {
for (i = 0; i < file->blockmax; ++i) {
struct snapraid_block* block = &file->blockvec[i];
block_off_t block_pos = block->parity_pos;
unsigned block_state;
@ -211,7 +211,7 @@ static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_fil
/* we just don't know the old hash, and then we set it to invalid */
hash_invalid_set(deleted->block.hash);
break;
default:
default :
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inconsistency in deallocating for block %u state %u\n", block->parity_pos, block_state);
exit(EXIT_FAILURE);
@ -239,7 +239,7 @@ static int file_is_full_invalid_parity_and_stable(struct snapraid_state* state,
return 0;
/* check all blocks */
for(i=0;i<file->blockmax;++i) {
for (i = 0; i < file->blockmax; ++i) {
struct snapraid_block* block = &file->blockvec[i];
snapraid_info info;
@ -271,7 +271,7 @@ static int file_is_full_hashed_and_stable(struct snapraid_state* state, struct s
return 0;
/* check all blocks */
for(i=0;i<file->blockmax;++i) {
for (i = 0; i < file->blockmax; ++i) {
struct snapraid_block* block = &file->blockvec[i];
snapraid_info info;
@ -357,7 +357,7 @@ static void scan_file_insert(struct snapraid_scan* scan, struct snapraid_file* f
/* allocate the blocks of the file */
block_pos = disk->first_free_block;
block_max = tommy_arrayblk_size(&disk->blockarr);
for(i=0;i<file->blockmax;++i) {
for (i = 0; i < file->blockmax; ++i) {
snapraid_info info;
struct snapraid_block* block = &file->blockvec[i];
@ -381,7 +381,7 @@ static void scan_file_insert(struct snapraid_scan* scan, struct snapraid_file* f
if (block_has_updated_hash(block) && !info_get_rehash(info)) {
/* the only possible case is for REP blocks */
assert(block_state_get(block) == BLOCK_STATE_REP);
/* convert to a REP block */
block_state_set(&file->blockvec[i], BLOCK_STATE_REP);
@ -482,6 +482,7 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c
/* always search with the new inode, in the all new inodes found until now, */
/* with the eventual presence of also the past inodes */
uint64_t inode = st->st_ino;
file = tommy_hashdyn_search(&disk->inodeset, file_inode_compare_to_arg, &inode, file_inode_hash(inode));
/* identify moved files with past inodes and hardlinks with the new inodes */
@ -490,10 +491,10 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c
if (file->size == st->st_size
&& file->mtime_sec == st->st_mtime
&& (file->mtime_nsec == STAT_NSEC(st)
/* always accept the stored value if it's STAT_NSEC_INVALID */
/* it happens when upgrading from an old version of SnapRAID */
/* not yet supporting the nanosecond field */
|| file->mtime_nsec == STAT_NSEC_INVALID
/* always accept the stored value if it's STAT_NSEC_INVALID */
/* it happens when upgrading from an old version of SnapRAID */
/* not yet supporting the nanosecond field */
|| file->mtime_nsec == STAT_NSEC_INVALID
)
) {
/* check if multiple files have the same inode */
@ -504,7 +505,7 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c
return;
} else {
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inode '%"PRIu64"' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub);
fprintf(stderr, "Internal inode '%" PRIu64 "' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -568,7 +569,7 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c
/* for sure it cannot be already present */
if (file_flag_has(file, FILE_IS_PRESENT)) {
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inode '%"PRIu64"' inconsistency for files '%s%s' and '%s%s' matching and already present but different\n", file->inode, disk->dir, sub, disk->dir, file->sub);
fprintf(stderr, "Internal inode '%" PRIu64 "' inconsistency for files '%s%s' and '%s%s' matching and already present but different\n", file->inode, disk->dir, sub, disk->dir, file->sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -613,7 +614,7 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c
/* here the inode has to be different, otherwise we would have found it before */
if (file->inode == st->st_ino) {
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inconsistency in inode '%"PRIu64"' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub);
fprintf(stderr, "Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -631,10 +632,10 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c
if (file->size == st->st_size
&& file->mtime_sec == st->st_mtime
&& (file->mtime_nsec == STAT_NSEC(st)
/* always accept the stored value if it's STAT_NSEC_INVALID */
/* it happens when upgrading from an old version of SnapRAID */
/* not yet supporting the nanosecond field */
|| file->mtime_nsec == STAT_NSEC_INVALID
/* always accept the stored value if it's STAT_NSEC_INVALID */
/* it happens when upgrading from an old version of SnapRAID */
/* not yet supporting the nanosecond field */
|| file->mtime_nsec == STAT_NSEC_INVALID
)
) {
/* mark as present */
@ -695,7 +696,7 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c
}
/* here if the file is changed but with the correct name */
/* do a safety check to ensure that the common ext4 case of zeroing */
/* the size of a file after a crash doesn't propagate to the backup */
if (file->size != 0 && st->st_size == 0) {
@ -745,7 +746,7 @@ static void scan_file(struct snapraid_scan* scan, int output, const char* sub, c
tommy_uint32_t hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec);
/* search for a file with the same name and stamp in all the disks */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* other_disk = i->data;
struct snapraid_file* other_file;
@ -1048,7 +1049,7 @@ static int scan_dir(struct snapraid_scan* scan, int output, const char* dir, con
/* process the sorted dir entries */
node = list;
while (node!=0) {
while (node != 0) {
char path_next[PATH_MAX];
char sub_next[PATH_MAX];
struct dirent_sorted* dd = node->data;
@ -1192,7 +1193,7 @@ static int scan_dir(struct snapraid_scan* scan, int output, const char* dir, con
if (filter_path(&state->filterlist, disk->name, sub_next) == 0) {
/* late stat */
if (!st) st = DSTAT(path_next, dd, &st_buf);
fprintf(stderr, "WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next);
} else {
if (state->opt.verbose) {
@ -1224,7 +1225,7 @@ void state_scan(struct snapraid_state* state, int output)
printf("Comparing...\n");
/* first scan all the directory and find new and deleted files */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
struct snapraid_scan* scan;
tommy_node* node;
@ -1293,7 +1294,7 @@ void state_scan(struct snapraid_state* state, int output)
/* only when all disks have all the new files found */
/* now process all the new and deleted files */
for(i=scanlist;i!=0;i=i->next) {
for (i = scanlist; i != 0; i = i->next) {
struct snapraid_scan* scan = i->data;
struct snapraid_disk* disk = scan->disk;
tommy_node* node;
@ -1392,7 +1393,7 @@ void state_scan(struct snapraid_state* state, int output)
/* if verbose, prints the list of duplicates */
/* if they are supposed real offsets */
if (state->opt.verbose && phy_last != FILEPHY_UNREPORTED_OFFSET) {
fprintf(stderr, "WARNING! Files '%s%s' and '%s%s' have the same physical offset %"PRId64".\n", disk->dir, phy_file_last->sub, disk->dir, file->sub, phy_last);
fprintf(stderr, "WARNING! Files '%s%s' and '%s%s' have the same physical offset %" PRId64 ".\n", disk->dir, phy_file_last->sub, disk->dir, file->sub, phy_last);
}
++phy_dup;
}
@ -1442,7 +1443,7 @@ void state_scan(struct snapraid_state* state, int output)
/* checks for disks where all the previously existing files where removed */
if (!state->opt.force_empty) {
done = 0;
for(i=state->disklist,j=scanlist;i!=0;i=i->next,j=j->next) {
for (i = state->disklist, j = scanlist; i != 0; i = i->next, j = j->next) {
struct snapraid_disk* disk = i->data;
struct snapraid_scan* scan = j->data;
@ -1469,7 +1470,7 @@ void state_scan(struct snapraid_state* state, int output)
/* checks for disks without the physical offset support */
if (state->opt.force_order == SORT_PHYSICAL) {
done = 0;
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
if (disk->has_unreliable_physical) {
@ -1488,7 +1489,7 @@ void state_scan(struct snapraid_state* state, int output)
/* checks for disks without persistent inodes */
done = 0;
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
if (disk->has_volatile_inodes) {
@ -1506,7 +1507,7 @@ void state_scan(struct snapraid_state* state, int output)
/* checks for disks with changed UUID */
done = 0;
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
/* don't print the message if the UUID changed because before */
@ -1528,7 +1529,7 @@ void state_scan(struct snapraid_state* state, int output)
/* checks for disks with unsupported UUID */
done = 0;
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
if (disk->has_unsupported_uuid) {
@ -1557,7 +1558,7 @@ void state_scan(struct snapraid_state* state, int output)
total.count_remove = 0;
total.count_insert = 0;
for(i=scanlist;i!=0;i=i->next) {
for (i = scanlist; i != 0; i = i->next) {
struct snapraid_scan* scan = i->data;
total.count_equal += scan->count_equal;
total.count_move += scan->count_move;

View file

@ -77,7 +77,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
/* first count the number of blocks to process */
countmax = 0;
countlast = 0;
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
time_t blocktime;
snapraid_info info;
@ -134,7 +134,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
countpos = 0;
countlast = 0;
state_progress_begin(state, blockstart, blockmax, countmax);
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
time_t blocktime;
snapraid_info info;
int error_on_this_block;
@ -194,7 +194,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
rehash = info_get_rehash(info);
/* for each disk, process the block */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
int read_size;
unsigned char hash[HASH_SIZE];
struct snapraid_block* block;
@ -334,13 +334,13 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
state_usage_cpu(state);
/* buffers for parity read and not computed */
for(l=0;l<state->level;++l)
for (l = 0; l < state->level; ++l)
buffer_recov[l] = buffer[diskmax + state->level + l];
for(;l<LEV_MAX;++l)
for (; l < LEV_MAX; ++l)
buffer_recov[l] = 0;
/* read the parity */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
ret = parity_read(parity[l], i, buffer_recov[l], state->block_size, stdlog);
if (ret == -1) {
buffer_recov[l] = 0;
@ -359,7 +359,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
raid_gen(diskmax, state->level, state->block_size, buffer);
/* compare the parity */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (buffer_recov[l] && memcmp(buffer[diskmax + l], buffer_recov[l], state->block_size) != 0) {
fprintf(stdlog, "parity_error:%u:%s: Data error\n", i, lev_config_name(l));
@ -389,7 +389,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
/* if rehash is needed */
if (rehash) {
/* store all the new hash already computed */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
if (rehandle[j].block)
memcpy(rehandle[j].block->hash, rehandle[j].hash, HASH_SIZE);
}
@ -459,7 +459,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
fflush(stdlog);
bail:
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
ret = handle_close(&handle[j]);
if (ret == -1) {
/* LCOV_EXCL_START */
@ -553,7 +553,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
/* copy the info in the temp vector */
count = 0;
fprintf(stdlog, "block_count:%u\n", blockmax);
for(i=0;i<blockmax;++i) {
for (i = 0; i < blockmax; ++i) {
snapraid_info info = info_get(&state->infoarr, i);
/* skip unused blocks */
@ -580,7 +580,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
unsigned j = i + 1;
while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j]))
++j;
fprintf(stdlog, "info_time:%"PRIu64":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
fprintf(stdlog, "info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
i = j;
}
@ -609,14 +609,14 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
}
fprintf(stdlog, "count_limit:%u\n", countlimit);
fprintf(stdlog, "time_limit:%"PRIu64"\n", (uint64_t)timelimit);
fprintf(stdlog, "time_limit:%" PRIu64 "\n", (uint64_t)timelimit);
fprintf(stdlog, "last_limit:%u\n", lastlimit);
/* free the temp vector */
free(infomap);
/* open the file for reading */
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
parity_ptr[l] = &parity[l];
ret = parity_open(parity_ptr[l], state->parity_path[l], state->file_mode);
if (ret == -1) {
@ -637,7 +637,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
/* continue, as we are already exiting */
}
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
ret = parity_close(parity_ptr[l]);
if (ret == -1) {
/* LCOV_EXCL_START */

View file

@ -54,52 +54,52 @@ struct hash_test_vector {
* Test vectors for tommy_hash32
*/
static struct hash32_test_vector TEST_HASH32[] = {
{ "", 0, 0x8614384c },
{ "a", 1, 0x12c16c36 },
{ "abc", 3, 0xc58e8af5 },
{ "message digest", 14, 0x006b32f1 },
{ "abcdefghijklmnopqrstuvwxyz", 26, 0x7e6fcfe0 },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x8604adf8 },
{ "The quick brown fox jumps over the lazy dog", 43, 0xdeba3d3a },
{ "\x00", 1, 0x4a7d1c33 },
{ "\x16\x27", 2, 0x8b50899b },
{ "\xe2\x56\xb4", 3, 0x60406493 },
{ "\xc9\x4d\x9c\xda", 4, 0xa049144a },
{ "\x79\xf1\x29\x69\x5d", 5, 0x4da2c2f1 },
{ "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x59de30cf },
{ "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x219e149c },
{ "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x25067520 },
{ "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0xa1f368d8 },
{ "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x805fc63d },
{ "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0x7f75dd0f },
{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0xb9154382 },
{ 0, 0, 0 }
{ "", 0, 0x8614384c },
{ "a", 1, 0x12c16c36 },
{ "abc", 3, 0xc58e8af5 },
{ "message digest", 14, 0x006b32f1 },
{ "abcdefghijklmnopqrstuvwxyz", 26, 0x7e6fcfe0 },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x8604adf8 },
{ "The quick brown fox jumps over the lazy dog", 43, 0xdeba3d3a },
{ "\x00", 1, 0x4a7d1c33 },
{ "\x16\x27", 2, 0x8b50899b },
{ "\xe2\x56\xb4", 3, 0x60406493 },
{ "\xc9\x4d\x9c\xda", 4, 0xa049144a },
{ "\x79\xf1\x29\x69\x5d", 5, 0x4da2c2f1 },
{ "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x59de30cf },
{ "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x219e149c },
{ "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x25067520 },
{ "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0xa1f368d8 },
{ "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x805fc63d },
{ "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0x7f75dd0f },
{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0xb9154382 },
{ 0, 0, 0 }
};
/**
* Test vectors for tommy_hash64
*/
static struct hash64_test_vector TEST_HASH64[] = {
{ "", 0, 0x8614384cb5165fbfULL },
{ "a", 1, 0x1a2e0298a8e94a3dULL },
{ "abc", 3, 0x7555796b7a7d21ebULL },
{ "message digest", 14, 0x9411a57d04b92fb4ULL },
{ "abcdefghijklmnopqrstuvwxyz", 26, 0x3ca3f8d2b4e69832ULL },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x6dae542ba0015a4dULL },
{ "The quick brown fox jumps over the lazy dog", 43, 0xe06d8cbb3d2ea1a6ULL },
{ "\x00", 1, 0x201e664fb5f2c021ULL },
{ "\x16\x27", 2, 0xef42fa8032c4b775ULL },
{ "\xe2\x56\xb4", 3, 0x6e6c498a6688466cULL },
{ "\xc9\x4d\x9c\xda", 4, 0x5195005419905423ULL },
{ "\x79\xf1\x29\x69\x5d", 5, 0x221235b48afee7c1ULL },
{ "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x1b1f18b9266f095bULL },
{ "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x2cbafa8e741d49caULL },
{ "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x4677f04c06e0758dULL },
{ "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0x5afe09e8214e2163ULL },
{ "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x115b6276d209fab6ULL },
{ "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0xd0636d2f01cf3a3eULL },
{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0x6d259f5fef74f93eULL },
{ 0, 0, 0 }
{ "", 0, 0x8614384cb5165fbfULL },
{ "a", 1, 0x1a2e0298a8e94a3dULL },
{ "abc", 3, 0x7555796b7a7d21ebULL },
{ "message digest", 14, 0x9411a57d04b92fb4ULL },
{ "abcdefghijklmnopqrstuvwxyz", 26, 0x3ca3f8d2b4e69832ULL },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x6dae542ba0015a4dULL },
{ "The quick brown fox jumps over the lazy dog", 43, 0xe06d8cbb3d2ea1a6ULL },
{ "\x00", 1, 0x201e664fb5f2c021ULL },
{ "\x16\x27", 2, 0xef42fa8032c4b775ULL },
{ "\xe2\x56\xb4", 3, 0x6e6c498a6688466cULL },
{ "\xc9\x4d\x9c\xda", 4, 0x5195005419905423ULL },
{ "\x79\xf1\x29\x69\x5d", 5, 0x221235b48afee7c1ULL },
{ "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x1b1f18b9266f095bULL },
{ "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x2cbafa8e741d49caULL },
{ "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x4677f04c06e0758dULL },
{ "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0x5afe09e8214e2163ULL },
{ "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x115b6276d209fab6ULL },
{ "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0xd0636d2f01cf3a3eULL },
{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0x6d259f5fef74f93eULL },
{ 0, 0, 0 }
};
/**
@ -107,7 +107,7 @@ static struct hash64_test_vector TEST_HASH64[] = {
*/
static struct hash_test_vector TEST_MURMUR3[] = {
#include "murmur3test.c"
{ 0, 0, { 0 } }
{ 0, 0, { 0 } }
};
/**
@ -115,7 +115,7 @@ static struct hash_test_vector TEST_MURMUR3[] = {
*/
static struct hash_test_vector TEST_SPOOKY2[] = {
#include "spooky2test.c"
{ 0, 0, { 0 } }
{ 0, 0, { 0 } }
};
#define HASH_TEST_MAX 512 /* tests are never longer than 512 bytes */
@ -153,7 +153,7 @@ static void test_hash(void)
seed_aligned[14] = 0x9e;
seed_aligned[15] = 0x43;
for(i=0;TEST_HASH32[i].data;++i) {
for (i = 0; TEST_HASH32[i].data; ++i) {
uint32_t digest;
memcpy(buffer_aligned, TEST_HASH32[i].data, TEST_HASH32[i].len);
digest = tommy_hash_u32(seed32, buffer_aligned, TEST_MURMUR3[i].len);
@ -165,7 +165,7 @@ static void test_hash(void)
}
}
for(i=0;TEST_HASH64[i].data;++i) {
for (i = 0; TEST_HASH64[i].data; ++i) {
uint64_t digest;
memcpy(buffer_aligned, TEST_HASH64[i].data, TEST_HASH64[i].len);
digest = tommy_hash_u64(seed64, buffer_aligned, TEST_MURMUR3[i].len);
@ -178,7 +178,7 @@ static void test_hash(void)
}
for(i=0;TEST_MURMUR3[i].data;++i) {
for (i = 0; TEST_MURMUR3[i].data; ++i) {
unsigned char digest[HASH_SIZE];
memcpy(buffer_aligned, TEST_MURMUR3[i].data, TEST_MURMUR3[i].len);
memhash(HASH_MURMUR3, seed_aligned, digest, buffer_aligned, TEST_MURMUR3[i].len);
@ -190,7 +190,7 @@ static void test_hash(void)
}
}
for(i=0;TEST_SPOOKY2[i].data;++i) {
for (i = 0; TEST_SPOOKY2[i].data; ++i) {
unsigned char digest[HASH_SIZE];
memcpy(buffer_aligned, TEST_SPOOKY2[i].data, TEST_SPOOKY2[i].len);
memhash(HASH_SPOOKY2, seed_aligned, digest, buffer_aligned, TEST_SPOOKY2[i].len);
@ -216,31 +216,31 @@ struct crc_test_vector {
* Test vectors for CRC32C (Castagnoli)
*/
static struct crc_test_vector TEST_CRC32C[] = {
{ "", 0, 0 },
{ "\x61", 1, 0xc1d04330 },
{ "\x66\x6f\x6f", 3, 0xcfc4ae1d },
{ "\x68\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64", 11, 0xc99465aa },
{ "\x68\x65\x6c\x6c\x6f\x20", 6, 0x7e627e58 },
{ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 32, 0x8a9136aa },
{ "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 32, 0x62a8ab43 },
{ "\x1f\x1e\x1d\x1c\x1b\x1a\x19\x18\x17\x16\x15\x14\x13\x12\x11\x10\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08\x07\x06\x05\x04\x03\x02\x01\x00", 32, 0x113fdb5c },
{ "\x01\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x14\x00\x00\x00\x18\x28\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", 48, 0xd9963a56 },
{ "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", 32, 0x46dd794e },
{ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28", 40, 0x0e2c157f },
{ "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50", 40, 0xe980ebf6 },
{ "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78", 40, 0xde74bded },
{ "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0", 40, 0xd579c862 },
{ "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8", 40, 0xba979ad0 },
{ "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0", 40, 0x2b29d913 },
{ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0", 240, 0x24c5d375 },
{ 0, 0, 0 }
{ "", 0, 0 },
{ "\x61", 1, 0xc1d04330 },
{ "\x66\x6f\x6f", 3, 0xcfc4ae1d },
{ "\x68\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64", 11, 0xc99465aa },
{ "\x68\x65\x6c\x6c\x6f\x20", 6, 0x7e627e58 },
{ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 32, 0x8a9136aa },
{ "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 32, 0x62a8ab43 },
{ "\x1f\x1e\x1d\x1c\x1b\x1a\x19\x18\x17\x16\x15\x14\x13\x12\x11\x10\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08\x07\x06\x05\x04\x03\x02\x01\x00", 32, 0x113fdb5c },
{ "\x01\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x14\x00\x00\x00\x18\x28\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", 48, 0xd9963a56 },
{ "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", 32, 0x46dd794e },
{ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28", 40, 0x0e2c157f },
{ "\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50", 40, 0xe980ebf6 },
{ "\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78", 40, 0xde74bded },
{ "\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0", 40, 0xd579c862 },
{ "\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8", 40, 0xba979ad0 },
{ "\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0", 40, 0x2b29d913 },
{ "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0", 240, 0x24c5d375 },
{ 0, 0, 0 }
};
static void test_crc32c(void)
{
unsigned i;
for(i=0;TEST_CRC32C[i].data;++i) {
for (i = 0; TEST_CRC32C[i].data; ++i) {
uint32_t digest;
digest = crc32c(0, (const unsigned char*)TEST_CRC32C[i].data, TEST_CRC32C[i].len);
if (digest != TEST_CRC32C[i].digest) {
@ -275,7 +275,7 @@ static void test_tommy(void)
tommy_arrayblk_init(&arrayblk);
tommy_arrayblkof_init(&arrayblkof, sizeof(unsigned));
for(i=0;i<TOMMY_SIZE;++i) {
for (i = 0; i < TOMMY_SIZE; ++i) {
tommy_array_insert(&array, &node[i]);
tommy_arrayblk_insert(&arrayblk, &node[i]);
tommy_arrayblkof_grow(&arrayblkof, i + 1);
@ -289,7 +289,7 @@ static void test_tommy(void)
if (tommy_arrayblkof_memory_usage(&arrayblkof) < TOMMY_SIZE * sizeof(unsigned))
goto bail;
for(i=0;i<TOMMY_SIZE;++i) {
for (i = 0; i < TOMMY_SIZE; ++i) {
if (tommy_array_get(&array, i) != &node[i])
goto bail;
if (tommy_arrayblk_get(&arrayblk, i) != &node[i])
@ -304,7 +304,7 @@ static void test_tommy(void)
tommy_hashdyn_init(&hashdyn);
for(i=0;i<TOMMY_SIZE;++i)
for (i = 0; i < TOMMY_SIZE; ++i)
tommy_hashdyn_insert(&hashdyn, &node[i], &node[i], i % 64);
if (tommy_hashdyn_count(&hashdyn) != TOMMY_SIZE)
@ -313,14 +313,14 @@ static void test_tommy(void)
if (tommy_hashdyn_memory_usage(&hashdyn) < TOMMY_SIZE * sizeof(void*))
goto bail;
for(i=0;i<TOMMY_SIZE/2;++i)
for (i = 0; i < TOMMY_SIZE / 2; ++i)
tommy_hashdyn_remove_existing(&hashdyn, &node[i]);
for(i=0;i<TOMMY_SIZE/2;++i)
for (i = 0; i < TOMMY_SIZE / 2; ++i)
if (tommy_hashdyn_remove(&hashdyn, tommy_test_search, &node[i], i % 64) != 0)
goto bail;
for(i=TOMMY_SIZE/2;i<TOMMY_SIZE;++i)
for (i = TOMMY_SIZE / 2; i < TOMMY_SIZE; ++i)
if (tommy_hashdyn_remove(&hashdyn, tommy_test_search, &node[i], i % 64) == 0)
goto bail;

View file

@ -75,7 +75,7 @@ void usage(void)
void memory(void)
{
fprintf(stdlog, "memory:used:%"PRIu64"\n", (uint64_t)malloc_counter());
fprintf(stdlog, "memory:used:%" PRIu64 "\n", (uint64_t)malloc_counter());
printf("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024));
}
@ -134,7 +134,7 @@ void log_open(const char* log)
}
/* process the path */
for(*path=0;*log!=0;) {
for (*path = 0; *log != 0; ) {
switch (*log) {
case '%' :
++log;
@ -148,14 +148,14 @@ void log_open(const char* log)
case 'D' :
pathcat(path, sizeof(path), text_D);
break;
default:
default :
/* LCOV_EXCL_START */
fprintf(stderr, "Invalid type specifier '%c' in the log file.\n", *log);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
break;
default:
default :
pathcatc(path, sizeof(path), *log);
break;
}
@ -421,7 +421,7 @@ int main(int argc, char* argv[])
#else
getopt(argc, argv, OPTIONS))
#endif
!= EOF) {
!= EOF) {
switch (c) {
case 'c' :
pathimport(conf, sizeof(conf), optarg);
@ -435,7 +435,7 @@ int main(int argc, char* argv[])
/* LCOV_EXCL_STOP */
}
tommy_list_insert_tail(&filterlist_file, &filter->node, filter);
} break;
} break;
case 'd' : {
struct snapraid_filter* filter = filter_alloc_disk(1, optarg);
if (!filter) {
@ -445,7 +445,7 @@ int main(int argc, char* argv[])
/* LCOV_EXCL_STOP */
}
tommy_list_insert_tail(&filterlist_disk, &filter->node, filter);
} break;
} break;
case 'm' :
filter_missing = 1;
break;
@ -623,7 +623,7 @@ int main(int argc, char* argv[])
case OPT_TEST_RUN :
run = optarg;
break;
default:
default :
/* LCOV_EXCL_START */
fprintf(stderr, "Unknown option '%c'\n", (char)c);
exit(EXIT_FAILURE);
@ -682,7 +682,7 @@ int main(int argc, char* argv[])
switch (operation) {
case OPERATION_CHECK :
break;
default:
default :
if (opt.auditonly) {
/* LCOV_EXCL_START */
fprintf(stderr, "You cannot use -a, --audit-only with the '%s' command\n", command);
@ -694,7 +694,7 @@ int main(int argc, char* argv[])
switch (operation) {
case OPERATION_SYNC :
break;
default:
default :
if (opt.prehash) {
/* LCOV_EXCL_START */
fprintf(stderr, "You cannot use -h, --pre-hash with the '%s' command\n", command);
@ -736,7 +736,7 @@ int main(int argc, char* argv[])
case OPERATION_FIX :
case OPERATION_DRY :
break;
default:
default :
if (!tommy_list_empty(&filterlist_file)) {
/* LCOV_EXCL_START */
fprintf(stderr, "You cannot use -f, --filter with the '%s' command\n", command);
@ -761,7 +761,7 @@ int main(int argc, char* argv[])
case OPERATION_CHECK :
case OPERATION_FIX :
break;
default:
default :
if (filter_error != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "You cannot use -e, --filter-error with the '%s' command\n", command);
@ -774,7 +774,7 @@ int main(int argc, char* argv[])
case OPERATION_CHECK :
case OPERATION_FIX :
break;
default:
default :
if (import != 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "You cannot import with the '%s' command\n", command);
@ -803,14 +803,14 @@ int main(int argc, char* argv[])
t = time(0);
tm = localtime(&t);
fprintf(stdlog, "version:%s\n", PACKAGE_VERSION);
fprintf(stdlog, "unixtime:%"PRIi64"\n", (int64_t)t);
fprintf(stdlog, "unixtime:%" PRIi64 "\n", (int64_t)t);
if (tm) {
char datetime[64];
strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm);
fprintf(stdlog, "time:%s\n", datetime);
}
fprintf(stdlog, "command:%s\n", command);
for(i=0;i<argc;++i)
for (i = 0; i < argc; ++i)
fprintf(stdlog, "argv:%u:%s\n", i, argv[i]);
fflush(stdlog);
@ -870,14 +870,14 @@ int main(int argc, char* argv[])
/* save the new state before the sync */
/* this allow to recover the case of the changes in the array after an aborted sync. */
/* for example, think at this case: */
/* - add some files at the array */
/* - run a sync command, it will recompute the parity adding the new files */
/* - abort the sync command before it stores the new content file */
/* - delete the not yet synced files from the array */
/* - run a new sync command */
/* the new sync command has now way to know that the parity file was modified */
/* because the files triggering these changes are now deleted */
/* and they aren't listed in the content file */

View file

@ -28,7 +28,7 @@
/*
* Size of the blocks to test.
*/
#define TEST_SIZE (256*1024)
#define TEST_SIZE (256 * 1024)
/*
* Number of data blocks to test.
@ -61,9 +61,9 @@ static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop)
* Stop time measurement.
*/
#define SPEED_STOP \
count += delta; \
gettimeofday(&stop, 0); \
} while (diffgettimeofday(&start, &stop) < period * 1000LL); \
count += delta; \
gettimeofday(&stop, 0); \
} while (diffgettimeofday(&start, &stop) < period * 1000LL) ; \
ds = size * (int64_t)count * nd; \
dt = diffgettimeofday(&start, &stop);
@ -95,8 +95,8 @@ void speed(int period)
memset(v[i], i, size);
/* zero buffer */
memset(v[nd+RAID_PARITY_MAX], 0, size);
raid_zero(v[nd+RAID_PARITY_MAX]);
memset(v[nd + RAID_PARITY_MAX], 0, size);
raid_zero(v[nd + RAID_PARITY_MAX]);
/* hash seed */
for (i = 0; i < HASH_SIZE; ++i)
@ -169,7 +169,7 @@ void speed(int period)
memset(v[j], j, size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
printf("\n");
printf("\n");
@ -184,7 +184,7 @@ void speed(int period)
crc32c_gen(0, v[j], size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
printf("\n");
printf("%8s", "intel");
@ -197,7 +197,7 @@ void speed(int period)
crc32c_x86(0, v[j], size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
#endif
printf("\n");
@ -231,7 +231,7 @@ void speed(int period)
memhash(HASH_MURMUR3, seed, digest, v[j], size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
SPEED_START {
@ -239,7 +239,7 @@ void speed(int period)
memhash(HASH_SPOOKY2, seed, digest, v[j], size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
printf("\n");
printf("\n");
@ -277,14 +277,14 @@ void speed(int period)
raid_gen1_int32(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
SPEED_START {
raid_gen1_int64(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -293,7 +293,7 @@ void speed(int period)
raid_gen1_sse2(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
}
@ -310,7 +310,7 @@ void speed(int period)
raid_gen1_avx2(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
}
#endif
@ -327,14 +327,14 @@ void speed(int period)
raid_gen2_int32(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
SPEED_START {
raid_gen2_int64(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -343,7 +343,7 @@ void speed(int period)
raid_gen2_sse2(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86_64
@ -351,7 +351,7 @@ void speed(int period)
raid_gen2_sse2ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
}
@ -366,7 +366,7 @@ void speed(int period)
raid_gen2_avx2(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
}
#endif
@ -383,14 +383,14 @@ void speed(int period)
raid_genz_int32(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
SPEED_START {
raid_genz_int64(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -399,7 +399,7 @@ void speed(int period)
raid_genz_sse2(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86_64
@ -407,7 +407,7 @@ void speed(int period)
raid_genz_sse2ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
}
@ -424,7 +424,7 @@ void speed(int period)
raid_genz_avx2ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
}
#endif
@ -440,7 +440,7 @@ void speed(int period)
raid_gen3_int8(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
printf("%8s", "");
@ -462,7 +462,7 @@ void speed(int period)
raid_gen3_ssse3(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86_64
@ -470,7 +470,7 @@ void speed(int period)
raid_gen3_ssse3ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
}
@ -483,7 +483,7 @@ void speed(int period)
raid_gen3_avx2ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
}
#endif
@ -499,7 +499,7 @@ void speed(int period)
raid_gen4_int8(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
printf("%8s", "");
@ -521,7 +521,7 @@ void speed(int period)
raid_gen4_ssse3(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86_64
@ -529,7 +529,7 @@ void speed(int period)
raid_gen4_ssse3ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
}
@ -542,7 +542,7 @@ void speed(int period)
raid_gen4_avx2ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
}
#endif
@ -558,7 +558,7 @@ void speed(int period)
raid_gen5_int8(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
printf("%8s", "");
@ -580,7 +580,7 @@ void speed(int period)
raid_gen5_ssse3(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86_64
@ -588,7 +588,7 @@ void speed(int period)
raid_gen5_ssse3ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
}
@ -601,7 +601,7 @@ void speed(int period)
raid_gen5_avx2ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
}
#endif
@ -617,7 +617,7 @@ void speed(int period)
raid_gen6_int8(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
printf("%8s", "");
@ -639,7 +639,7 @@ void speed(int period)
raid_gen6_ssse3(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86_64
@ -647,7 +647,7 @@ void speed(int period)
raid_gen6_ssse3ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#endif
}
@ -660,7 +660,7 @@ void speed(int period)
raid_gen6_avx2ext(nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
}
#endif
@ -689,7 +689,7 @@ void speed(int period)
raid_rec1_int8(1, id, ip + 1, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -700,7 +700,7 @@ void speed(int period)
raid_rec1_ssse3(1, id, ip + 1, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
if (raid_cpu_has_avx2()) {
@ -710,7 +710,7 @@ void speed(int period)
raid_rec1_avx2(1, id, ip + 1, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
#endif
printf("\n");
@ -725,7 +725,7 @@ void speed(int period)
raid_rec2_int8(2, id, ip + 1, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -736,7 +736,7 @@ void speed(int period)
raid_rec2_ssse3(2, id, ip + 1, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
if (raid_cpu_has_avx2()) {
@ -746,7 +746,7 @@ void speed(int period)
raid_rec2_avx2(2, id, ip + 1, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
#endif
printf("\n");
@ -760,7 +760,7 @@ void speed(int period)
raid_recX_int8(3, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -770,7 +770,7 @@ void speed(int period)
raid_recX_ssse3(3, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
if (raid_cpu_has_avx2()) {
@ -779,7 +779,7 @@ void speed(int period)
raid_recX_avx2(3, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
#endif
printf("\n");
@ -793,7 +793,7 @@ void speed(int period)
raid_recX_int8(4, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -803,7 +803,7 @@ void speed(int period)
raid_recX_ssse3(4, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
if (raid_cpu_has_avx2()) {
@ -812,7 +812,7 @@ void speed(int period)
raid_recX_avx2(4, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
#endif
printf("\n");
@ -826,7 +826,7 @@ void speed(int period)
raid_recX_int8(5, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -836,7 +836,7 @@ void speed(int period)
raid_recX_ssse3(5, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
if (raid_cpu_has_avx2()) {
@ -845,7 +845,7 @@ void speed(int period)
raid_recX_avx2(5, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
#endif
printf("\n");
@ -859,7 +859,7 @@ void speed(int period)
raid_recX_int8(6, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
fflush(stdout);
#ifdef CONFIG_X86
@ -869,7 +869,7 @@ void speed(int period)
raid_recX_ssse3(6, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
if (raid_cpu_has_avx2()) {
@ -878,7 +878,7 @@ void speed(int period)
raid_recX_avx2(6, id, ip, nd, size, v);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
printf("%8" PRIu64, ds / dt);
}
#endif
printf("\n");

View file

@ -51,54 +51,54 @@
//
// Google's CityHash has similar specs to SpookyHash, and CityHash is faster
// on new Intel boxes. MD4 and MD5 also have similar specs, but they are orders
// of magnitude slower. CRCs are two or more times slower, but unlike
// SpookyHash, they have nice math for combining the CRCs of pieces to form
// the CRCs of wholes. There are also cryptographic hashes, but those are even
// of magnitude slower. CRCs are two or more times slower, but unlike
// SpookyHash, they have nice math for combining the CRCs of pieces to form
// the CRCs of wholes. There are also cryptographic hashes, but those are even
// slower than MD5.
//
#define Mix(data, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) \
s0 += data[0]; s2 ^= s10; s11^= s0; s0 = util_rotl64(s0,11); s11 += s1; \
s1 += data[1]; s3 ^= s11; s0 ^= s1; s1 = util_rotl64(s1,32); s0 += s2; \
s2 += data[2]; s4 ^= s0; s1 ^= s2; s2 = util_rotl64(s2,43); s1 += s3; \
s3 += data[3]; s5 ^= s1; s2 ^= s3; s3 = util_rotl64(s3,31); s2 += s4; \
s4 += data[4]; s6 ^= s2; s3 ^= s4; s4 = util_rotl64(s4,17); s3 += s5; \
s5 += data[5]; s7 ^= s3; s4 ^= s5; s5 = util_rotl64(s5,28); s4 += s6; \
s6 += data[6]; s8 ^= s4; s5 ^= s6; s6 = util_rotl64(s6,39); s5 += s7; \
s7 += data[7]; s9 ^= s5; s6 ^= s7; s7 = util_rotl64(s7,57); s6 += s8; \
s8 += data[8]; s10^= s6; s7 ^= s8; s8 = util_rotl64(s8,55); s7 += s9; \
s9 += data[9]; s11^= s7; s8 ^= s9; s9 = util_rotl64(s9,54); s8 += s10; \
s10+= data[10]; s0 ^= s8; s9 ^= s10; s10= util_rotl64(s10,22); s9 += s11; \
s11+= data[11]; s1 ^= s9; s10^= s11; s11= util_rotl64(s11,46); s10 += s0;
s0 += data[0]; s2 ^= s10; s11 ^= s0; s0 = util_rotl64(s0, 11); s11 += s1; \
s1 += data[1]; s3 ^= s11; s0 ^= s1; s1 = util_rotl64(s1, 32); s0 += s2; \
s2 += data[2]; s4 ^= s0; s1 ^= s2; s2 = util_rotl64(s2, 43); s1 += s3; \
s3 += data[3]; s5 ^= s1; s2 ^= s3; s3 = util_rotl64(s3, 31); s2 += s4; \
s4 += data[4]; s6 ^= s2; s3 ^= s4; s4 = util_rotl64(s4, 17); s3 += s5; \
s5 += data[5]; s7 ^= s3; s4 ^= s5; s5 = util_rotl64(s5, 28); s4 += s6; \
s6 += data[6]; s8 ^= s4; s5 ^= s6; s6 = util_rotl64(s6, 39); s5 += s7; \
s7 += data[7]; s9 ^= s5; s6 ^= s7; s7 = util_rotl64(s7, 57); s6 += s8; \
s8 += data[8]; s10 ^= s6; s7 ^= s8; s8 = util_rotl64(s8, 55); s7 += s9; \
s9 += data[9]; s11 ^= s7; s8 ^= s9; s9 = util_rotl64(s9, 54); s8 += s10; \
s10 += data[10]; s0 ^= s8; s9 ^= s10; s10 = util_rotl64(s10, 22); s9 += s11; \
s11 += data[11]; s1 ^= s9; s10 ^= s11; s11 = util_rotl64(s11, 46); s10 += s0;
#define EndPartial(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11) \
h11+= h1; h2 ^= h11; h1 = util_rotl64(h1,44); \
h0 += h2; h3 ^= h0; h2 = util_rotl64(h2,15); \
h1 += h3; h4 ^= h1; h3 = util_rotl64(h3,34); \
h2 += h4; h5 ^= h2; h4 = util_rotl64(h4,21); \
h3 += h5; h6 ^= h3; h5 = util_rotl64(h5,38); \
h4 += h6; h7 ^= h4; h6 = util_rotl64(h6,33); \
h5 += h7; h8 ^= h5; h7 = util_rotl64(h7,10); \
h6 += h8; h9 ^= h6; h8 = util_rotl64(h8,13); \
h7 += h9; h10^= h7; h9 = util_rotl64(h9,38); \
h8 += h10; h11^= h8; h10= util_rotl64(h10,53); \
h9 += h11; h0 ^= h9; h11= util_rotl64(h11,42); \
h10+= h0; h1 ^= h10; h0 = util_rotl64(h0,54);
h11 += h1; h2 ^= h11; h1 = util_rotl64(h1, 44); \
h0 += h2; h3 ^= h0; h2 = util_rotl64(h2, 15); \
h1 += h3; h4 ^= h1; h3 = util_rotl64(h3, 34); \
h2 += h4; h5 ^= h2; h4 = util_rotl64(h4, 21); \
h3 += h5; h6 ^= h3; h5 = util_rotl64(h5, 38); \
h4 += h6; h7 ^= h4; h6 = util_rotl64(h6, 33); \
h5 += h7; h8 ^= h5; h7 = util_rotl64(h7, 10); \
h6 += h8; h9 ^= h6; h8 = util_rotl64(h8, 13); \
h7 += h9; h10 ^= h7; h9 = util_rotl64(h9, 38); \
h8 += h10; h11 ^= h8; h10 = util_rotl64(h10, 53); \
h9 += h11; h0 ^= h9; h11 = util_rotl64(h11, 42); \
h10 += h0; h1 ^= h10; h0 = util_rotl64(h0, 54);
#define End(data, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10,h11) \
#define End(data, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11) \
h0 += data[0]; h1 += data[1]; h2 += data[2]; h3 += data[3]; \
h4 += data[4]; h5 += data[5]; h6 += data[6]; h7 += data[7]; \
h8 += data[8]; h9 += data[9]; h10+= data[10]; h11+= data[11]; \
EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11); \
EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11); \
EndPartial(h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
h8 += data[8]; h9 += data[9]; h10 += data[10]; h11 += data[11]; \
EndPartial(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); \
EndPartial(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); \
EndPartial(h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
// number of uint64_t's in internal state
#define sc_numVars 12
// size of the internal state
#define sc_blockSize (sc_numVars*8)
#define sc_blockSize (sc_numVars * 8)
//
// sc_const: a constant which:
// * is not zero
@ -113,6 +113,7 @@ void SpookyHash128(const void* message, size_t length, const uint8_t* seed, uint
uint64_t h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11;
uint64_t buf[sc_numVars];
uint64_t* end;
union {
const uint8_t* p8;
uint64_t* p64;
@ -136,35 +137,35 @@ void SpookyHash128(const void* message, size_t length, const uint8_t* seed, uint
h2 = h5 = h8 = h11 = sc_const;
u.p8 = message;
end = u.p64 + (length/sc_blockSize)*sc_numVars;
end = u.p64 + (length / sc_blockSize) * sc_numVars;
/* body */
while (u.p64 < end) {
#if WORDS_BIGENDIAN
for(i=0;i<sc_numVars;++i)
for (i = 0; i < sc_numVars; ++i)
buf[i] = util_swap64(u.p64[i]);
Mix(buf,h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
Mix(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
#else
Mix(u.p64,h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
Mix(u.p64, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
#endif
u.p64 += sc_numVars;
}
/* tail */
remainder = (length - ((const uint8_t *)end-(const uint8_t *)message));
remainder = (length - ((const uint8_t*)end - (const uint8_t*)message));
memcpy(buf, end, remainder);
memset(((uint8_t *)buf)+remainder, 0, sc_blockSize-remainder);
((uint8_t *)buf)[sc_blockSize-1] = remainder;
memset(((uint8_t*)buf) + remainder, 0, sc_blockSize - remainder);
((uint8_t*)buf)[sc_blockSize - 1] = remainder;
/* finalization */
#if WORDS_BIGENDIAN
for(i=0;i<sc_numVars;++i)
for (i = 0; i < sc_numVars; ++i)
buf[i] = util_swap64(buf[i]);
#endif
End(buf,h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11);
End(buf, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
#if WORDS_BIGENDIAN
h0 = util_swap64(h0);

View file

@ -261,3 +261,4 @@
{ "\x12\x75\x7c\xa3\xe7\x74\x65\x23\x81\x28\xf1\x5b\x1f\x2d\x8b\x6f\x44\xe0\xcd\x2d\xd8\xdb\x77\x16\x6c\x0b\x7b\x0d\x9b\x70\x34\x9b\x8c\x71\xb7\xdd\x93\xda\x42\x0b\xf7\x73\xd2\xa5\xce\x3e\xd1\x3c\x05\x4c\xeb\xda\x7c\x3c\x01\x0f\x4e\x51\x37\x99\x2e\x2f\x28\xaf\xed\x32\x39\xea\x18\x6b\x0b\xd0\xbd\x39\x0a\xff\x4e\x7f\x22\xf3\x9f\x87\x92\x74\x0a\x73\xd8\x9f\xb2\x5b\xcc\x8e\xe4\x08\xc9\xa7\x99\x4c\x06\x7e\x18\xfc\x02\x68\xb8\x8c\x1e\x9d\xc3\x45\x44\x08\x77\x25\xc5\xaf\x26\x53\x41\xba\x7d\x3d\xbf\x22\xe1\x50\xdd\xf7\xf5\x53\x21\x4d\x38\x61\x6d\xc4\xcc\x81\x91\xb3\x51\xe3\xfb\xf1\xf0\xba\x89\x3f\x74\xb0\x7f\x55\x92\x0a\x94\x88\x49\x5a\x27\x14\x64\xdb\x8f\x0c\x1d\x6c\x90\xdb\xdc\x2c\xe9\x76\x1d\xae\x09\x20\x6f\xd9\xe2\xd9\x98\x5f\xd7\x64\xd6\xd8\xcf\xf4\x40\x7a\x6b\x72\x4b\x77\x54\x6d\x69\xf4\xad\x9f\xcc\xa1\xa8\x18\x49\xf9\x34\x0a\x57\x18\xd4\x30\x36\x34\x8b\xdb\x2c\xb9\xf4\x9a\xea\x05\x6e\x85\x0e\xbd\x73\x26\xc2\xca\x0a\x05\x81\xf4\x53\xcf\xfa\x19\x40\x22\x0d\x09\x63\xf8\xf2\x01\xe1\xad\x79\xc3\x86\xae\x6b\x4e", 254, { 0x23, 0xe9, 0x88, 0x6a, 0xc2, 0x8c, 0x64, 0x59, 0xdb, 0xa2, 0xe7, 0x84, 0x10, 0x37, 0x53, 0xd0 } },
{ "\xf3\xc0\x10\x3f\xf2\xea\xca\xc4\xea\x01\xdf\x39\x6d\xce\x54\x61\xef\xdd\xf4\x42\x92\xe5\x70\x9d\x1c\xcf\xa0\x08\x0a\x65\xe8\xaa\xbe\x98\xb6\x93\xd3\x6d\x27\xb5\x91\x86\xc9\x83\x7c\x49\x7b\x25\x07\xaf\x71\x55\x66\xab\x54\xd9\x81\x34\x86\x9d\x04\xf1\x83\x6c\x93\x80\x63\x4b\x1b\x64\x7b\x72\x44\x89\x24\xe8\x02\x74\x93\xba\x4b\x0b\xe7\xd7\xe3\xfe\x42\x8b\x53\xd1\x0e\x96\xf8\x88\x61\xe9\x37\xee\x7b\xfc\xce\x81\x6c\xce\x46\xfd\xd3\x7a\x84\x83\xc1\x73\x7f\x66\xbb\x5c\x0c\x93\xde\x86\xd6\x9a\x1d\x07\x69\x5d\xa6\x73\x6d\x54\x64\x3a\xef\x7a\x9d\x9e\xdb\xd7\xba\x4f\x86\xab\x27\xa4\x68\x34\x51\x78\xe7\x1c\xcc\x9f\x4e\x83\x97\x04\xdc\xa4\x77\x61\xf9\x26\x7f\x99\x84\x01\xb1\xb5\x47\x0b\xbf\x79\x8c\x1f\xea\xa2\xc9\xe8\x0c\xbf\x76\x4f\xb1\xa9\xff\x7f\x5f\xa1\xd5\x91\xf6\x04\xa0\xd9\x32\xad\x8f\xcc\x4e\xe7\xcf\x8c\xc3\x0d\x19\x12\x2f\xc1\x66\xf7\x50\xc5\xbe\xdf\x2f\x79\x2e\x83\x59\xf1\xd8\x59\x48\xb2\x24\xe1\xe1\x0a\x15\x8e\x17\x09\xb6\x50\xad\x1f\xb3\xba\x18\x54\x03\xd5\x82\x1e\xc3\x80\xeb\xe2\x1f\x82\x6a\x0a\x69\x2e\x92", 255, { 0xe8, 0x99, 0x39, 0xbb, 0x59, 0x6c, 0x74, 0x74, 0x67, 0x04, 0x26, 0x4c, 0xd3, 0xaf, 0x38, 0x31 } },
{ "\xbf\x4b\xb1\xf0\x43\x19\xfc\xb0\xee\x40\x48\x5f\xc3\xdc\x4a\xca\xaf\x65\xf5\x06\x5d\x88\xe7\x89\xb8\x14\x71\x76\xfe\x0b\x46\xf6\x7e\xd9\xbf\xc1\xee\xa1\xc8\xbd\x6b\xb2\x6b\xbd\x0d\x18\xf7\x6a\x26\x4f\xcc\x3f\x18\x13\xc6\xae\xd0\x53\x44\x60\xe3\x43\xd4\x9a\x43\x91\x7c\xbb\x9d\xaf\xa7\xe1\x53\x4f\xab\xac\x11\xed\xf3\x1a\x0e\x85\xce\x92\xe1\x66\xd3\xfc\xfd\x1f\xee\x0d\xcb\x95\x0c\xa0\x63\x36\x5f\x40\xe6\x48\x4e\xc2\x7a\x5b\xfd\x0f\xe3\xdd\x74\x00\xbb\xcc\x6e\x62\x4e\x86\xc0\x18\x14\xbc\x64\x60\xcb\x85\x22\x2e\x31\x8f\xda\xb4\x5b\x70\x70\x03\xb5\x1a\x54\xcb\x97\x6d\xac\x3e\x7f\xe7\x21\x13\xf1\x77\x43\xa7\xe8\x6f\x9a\x3e\xf7\x97\x4a\x66\x01\x5d\x62\x7c\x91\x2a\xc1\x48\xd7\xd1\xa5\xc4\x40\x21\xd1\xfa\xb1\x9a\x5b\x0b\x5f\x3c\x0f\x4b\x4d\x7a\x83\x8a\x63\x4e\xb9\x6e\x28\x66\x6a\xfc\x1d\x7c\xf5\x35\xb5\xc3\xe4\xdd\xf4\x7d\x16\x57\xa2\xa9\x8f\xab\x2c\xda\xd9\xaa\x18\x23\x14\x29\x23\x2f\xa1\x69\xf9\x6d\x67\x97\x91\x68\xc0\x6e\x22\x34\x04\xfa\xc5\x04\xb0\x78\xa8\xd9\x32\x5a\xec\x55\x53\x66\x1d\xae\x41\xfe\x4b\xbe\x38\x7a", 256, { 0xf9, 0xd0, 0x4d, 0xbb, 0xc9, 0x3f, 0xc3, 0xa4, 0x73, 0xd0, 0xd2, 0x2a, 0xb4, 0x79, 0x0a, 0xcb } },

View file

@ -82,7 +82,7 @@ void state_init(struct snapraid_state* state)
state->block_size = 256 * 1024; /* default 256 KiB */
state->raid_mode = RAID_MODE_CAUCHY;
state->file_mode = MODE_SEQUENTIAL;
for(l=0;l<LEV_MAX;++l) {
for (l = 0; l < LEV_MAX; ++l) {
state->parity_path[l][0] = 0;
state->parity_device[l] = 0;
state->tick_parity[l] = 0;
@ -139,7 +139,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
}
}
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (state->parity_path[l][0] == 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "No '%s' specification in '%s'\n", lev_config_name(l), path);
@ -156,10 +156,10 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
}
/* checks for equal paths */
for(i=state->contentlist;i!=0;i=i->next) {
for (i = state->contentlist; i != 0; i = i->next) {
struct snapraid_content* content = i->data;
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (pathcmp(state->parity_path[l], content->content) == 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Same path used for '%s' and 'content' as '%s'\n", lev_config_name(l), content->content);
@ -171,7 +171,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
/* check if all the data and parity disks are different */
if (!state->opt.skip_device) {
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
tommy_node* j;
struct snapraid_disk* disk = i->data;
@ -188,13 +188,13 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
#endif
if (!state->opt.force_device) {
for(j=i->next;j!=0;j=j->next) {
for (j = i->next; j != 0; j = j->next) {
struct snapraid_disk* other = j->data;
if (disk->device == other->device) {
/* LCOV_EXCL_START */
fprintf(stderr, "Disks '%s' and '%s' are on the same device.\n", disk->dir, other->dir);
#ifdef _WIN32
fprintf(stderr, "Both have the serial number '%"PRIx64"'.\n", disk->device);
fprintf(stderr, "Both have the serial number '%" PRIx64 "'.\n", disk->device);
fprintf(stderr, "Try using the 'VolumeID' tool by 'Mark Russinovich'\n");
fprintf(stderr, "to change one of the disk serial.\n");
#endif
@ -208,12 +208,12 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
}
}
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (disk->device == state->parity_device[l]) {
/* LCOV_EXCL_START */
fprintf(stderr, "Disk '%s' and %s '%s' are on the same device.\n", disk->dir, lev_name(l), state->parity_path[l]);
#ifdef _WIN32
fprintf(stderr, "Both have the serial number '%"PRIx64"'.\n", disk->device);
fprintf(stderr, "Both have the serial number '%" PRIx64 "'.\n", disk->device);
fprintf(stderr, "Try using the 'VolumeID' tool by 'Mark Russinovich'\n");
fprintf(stderr, "to change one of the disk serial.\n");
#endif
@ -226,7 +226,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
/* LCOV_EXCL_START */
fprintf(stderr, "Disk '%s' and pool '%s' are on the same device.\n", disk->dir, state->pool);
#ifdef _WIN32
fprintf(stderr, "Both have the serial number '%"PRIx64"'.\n", disk->device);
fprintf(stderr, "Both have the serial number '%" PRIx64 "'.\n", disk->device);
fprintf(stderr, "Try using the 'VolumeID' tool by 'Mark Russinovich'\n");
fprintf(stderr, "to change one of the disk serial.\n");
#endif
@ -236,7 +236,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
}
#ifdef _WIN32
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (state->parity_device[l] == 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Disk '%s' has a zero serial number.\n", state->parity_path[l]);
@ -259,29 +259,29 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
}
#endif
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
unsigned j;
for(j=l+1;j<state->level;++j) {
for (j = l + 1; j < state->level; ++j) {
if (state->parity_device[l] == state->parity_device[j]) {
/* LCOV_EXCL_START */
fprintf(stderr, "Parity '%s' and '%s' are on the same device.\n", state->parity_path[l], state->parity_path[j]);
#ifdef _WIN32
fprintf(stderr, "Both have the serial number '%"PRIx64"'.\n", state->parity_device[l]);
fprintf(stderr, "Both have the serial number '%" PRIx64 "'.\n", state->parity_device[l]);
fprintf(stderr, "Try using the 'VolumeID' tool by 'Mark Russinovich'\n");
fprintf(stderr, "to change one of the disk serial.\n");
#endif
#endif
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
}
}
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (state->pool[0] != 0 && state->pool_device == state->parity_device[l]) {
/* LCOV_EXCL_START */
fprintf(stderr, "Pool '%s' and parity '%s' are on the same device.\n", state->pool, state->parity_path[l]);
#ifdef _WIN32
fprintf(stderr, "Both have the serial number '%"PRIx64"'.\n", state->pool_device);
fprintf(stderr, "Both have the serial number '%" PRIx64 "'.\n", state->pool_device);
fprintf(stderr, "Try using the 'VolumeID' tool by 'Mark Russinovich'\n");
fprintf(stderr, "to change one of the disk serial.\n");
#endif
@ -296,12 +296,12 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
unsigned content_count;
content_count = 0;
for(i=state->contentlist;i!=0;i=i->next) {
for (i = state->contentlist; i != 0; i = i->next) {
tommy_node* j;
struct snapraid_content* content = i->data;
/* check if there are others in the same disk */
for(j=i->next;j!=0;j=j->next) {
for (j = i->next; j != 0; j = j->next) {
struct snapraid_content* other = j->data;
if (content->device == other->device) {
break;
@ -315,9 +315,9 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
++content_count;
}
if (content_count < state->level+1) {
if (content_count < state->level + 1) {
/* LCOV_EXCL_START */
fprintf(stderr, "You must have at least %d 'content' files in different disks.\n", state->level+1);
fprintf(stderr, "You must have at least %d 'content' files in different disks.\n", state->level + 1);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -338,10 +338,10 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
}
/* ensure that specified filter disks are valid ones */
for(i=tommy_list_head(filterlist_disk);i!=0;i=i->next) {
for (i = tommy_list_head(filterlist_disk); i != 0; i = i->next) {
tommy_node* j;
struct snapraid_filter* filter = i->data;
for(j=state->disklist;j!=0;j=j->next) {
for (j = state->disklist; j != 0; j = j->next) {
struct snapraid_disk* disk = j->data;
if (fnmatch(filter->pattern, disk->name, FNM_CASEINSENSITIVE_FOR_WIN) == 0)
break;
@ -354,7 +354,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
}
}
}
void state_config(struct snapraid_state* state, const char* path, const char* command, struct snapraid_option* opt, tommy_list* filterlist_disk)
@ -417,7 +417,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
sgetspace(f);
if (strcmp(tag, "blocksize") == 0
/* block_size is the old format of the option */
/* block_size is the old format of the option */
|| strcmp(tag, "block_size") == 0) {
ret = sgetu32(f, &state->block_size);
@ -433,7 +433,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (state->block_size > 16*1024) {
if (state->block_size > 16 * 1024) {
/* LCOV_EXCL_START */
fprintf(stderr, "Too big 'blocksize' specification in '%s' at line %u\n", path, line);
exit(EXIT_FAILURE);
@ -476,7 +476,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
level = 2;
state->raid_mode = RAID_MODE_VANDERMONDE;
break;
default:
default :
/* LCOV_EXCL_START */
fprintf(stderr, "Invalid '%s' specification in '%s' at line %u\n", tag, path, line);
exit(EXIT_FAILURE);
@ -622,7 +622,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
}
/* check if the content file is already specified */
for(i=state->contentlist;i!=0;i=i->next) {
for (i = state->contentlist; i != 0; i = i->next) {
content = i->data;
if (pathcmp(content->content, buffer) == 0)
break;
@ -705,7 +705,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
}
/* check if the disk name already exists */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
disk = i->data;
if (strcmp(disk->name, buffer) == 0)
break;
@ -879,13 +879,13 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
/* intentionally not set the prevhashseed, if used valgrind will warn about it */
fprintf(stdlog, "blocksize:%u\n", state->block_size);
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
fprintf(stdlog, "disk:%s:%s\n", disk->name, disk->dir);
}
fprintf(stdlog, "mode:%s\n", lev_raid_name(state->raid_mode, state->level));
for(l=0;l<state->level;++l)
for (l = 0; l < state->level; ++l)
fprintf(stdlog, "%s:%s\n", lev_config_name(l), state->parity_path[l]);
if (state->pool[0] != 0)
fprintf(stdlog, "pool:%s\n", state->pool);
@ -906,12 +906,12 @@ static void state_map(struct snapraid_state* state)
/* this happens when a disk is removed from the configuration file */
/* From SnapRAID 4.0 mappings are automatically removed if a disk is not used */
/* when saving the content file, but we keep this code to import older content files. */
for(i=state->maplist;i!=0;) {
for (i = state->maplist; i != 0; ) {
struct snapraid_map* map = i->data;
struct snapraid_disk* disk;
tommy_node* j;
for(j=state->disklist;j!=0;j=j->next) {
for (j = state->disklist; j != 0; j = j->next) {
disk = j->data;
if (strcmp(disk->name, map->name) == 0) {
/* disk found */
@ -921,8 +921,8 @@ static void state_map(struct snapraid_state* state)
/* go to the next mapping before removing */
i = i->next;
if (j==0) {
if (j == 0) {
/* disk not found, remove the mapping */
tommy_list_remove_existing(&state->maplist, &map->node);
map_free(map);
@ -932,32 +932,32 @@ static void state_map(struct snapraid_state* state)
/* maps each unmapped disk present in the configuration file in the first available hole */
/* this happens when you add disks for the first time in the configuration file */
hole = 0; /* first position to try */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
struct snapraid_map* map;
tommy_node* j;
/* check if the disk is already mapped */
for(j=state->maplist;j!=0;j=j->next) {
for (j = state->maplist; j != 0; j = j->next) {
map = j->data;
if (strcmp(disk->name, map->name) == 0) {
/* mapping found */
break;
}
}
if (j!=0)
if (j != 0)
continue;
/* mapping not found, search for an hole */
while (1) {
for(j=state->maplist;j!=0;j=j->next) {
for (j = state->maplist; j != 0; j = j->next) {
map = j->data;
if (map->position == hole) {
/* position already used */
break;
}
}
if (j==0) {
if (j == 0) {
/* hole found */
break;
}
@ -978,14 +978,14 @@ static void state_map(struct snapraid_state* state)
/* checks if mapping match the disk uuid */
uuid_mismatch = 0;
for(i=state->maplist;i!=0;i=i->next) {
for (i = state->maplist; i != 0; i = i->next) {
struct snapraid_map* map = i->data;
struct snapraid_disk* disk;
tommy_node* j;
char uuid[UUID_MAX];
int ret;
for(j=state->disklist;j!=0;j=j->next) {
for (j = state->disklist; j != 0; j = j->next) {
disk = j->data;
if (strcmp(disk->name, map->name) == 0) {
/* disk found */
@ -993,7 +993,7 @@ static void state_map(struct snapraid_state* state)
}
}
if (j==0) {
if (j == 0) {
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inconsistency for mapping '%s'\n", map->name);
exit(EXIT_FAILURE);
@ -1044,7 +1044,7 @@ static void state_map(struct snapraid_state* state)
/* count the number of data disks, including holes left after removing some */
diskcount = 0;
for(i=state->maplist;i!=0;i=i->next) {
for (i = state->maplist; i != 0; i = i->next) {
struct snapraid_map* map = i->data;
if (map->position + 1 > diskcount)
@ -1079,10 +1079,10 @@ static void state_content_check(struct snapraid_state* state, const char* path)
tommy_node* i;
/* checks that any map has different name and position */
for(i=state->maplist;i!=0;i=i->next) {
for (i = state->maplist; i != 0; i = i->next) {
struct snapraid_map* map = i->data;
tommy_node* j;
for(j=i->next;j!=0;j=j->next) {
for (j = i->next; j != 0; j = j->next) {
struct snapraid_map* other = j->data;
if (strcmp(map->name, other->name) == 0) {
/* LCOV_EXCL_START */
@ -1110,7 +1110,7 @@ static int position_is_required(struct snapraid_state* state, block_off_t pos)
tommy_node* i;
/* check for each disk */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
struct snapraid_block* block = disk_block_get(disk, pos);
@ -1139,7 +1139,7 @@ static int info_is_required(struct snapraid_state* state, block_off_t pos)
tommy_node* i;
/* check for each disk */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
struct snapraid_block* block = disk_block_get(disk, pos);
@ -1156,7 +1156,7 @@ static void position_clear_deleted(struct snapraid_state* state, block_off_t pos
tommy_node* i;
/* check for each disk if block is really used */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
struct snapraid_block* block = disk_block_get(disk, pos);
@ -1185,7 +1185,7 @@ static struct snapraid_disk* find_disk(struct snapraid_state* state, const char*
{
tommy_node* i;
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
if (strcmp(disk->name, name) == 0)
return disk;
@ -2150,7 +2150,7 @@ static void state_read_text(struct snapraid_state* state, const char* path, STRE
/* to be backward compatible with old context files without info */
/* create info records if missing */
for(b=0;b<blockmax;++b) {
for (b = 0; b < blockmax; ++b) {
/* if the position is used */
if (info_is_required(state, b)) {
snapraid_info info = info_get(&state->infoarr, b);
@ -2204,7 +2204,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
/* clear the info for unused blocks */
/* and get some other info */
info_has_rehash = 0; /* if there is a rehash info */
for(b=0;b<blockmax;++b) {
for (b = 0; b < blockmax; ++b) {
/* if the position is used */
if (position_is_required(state, b)) {
snapraid_info info = info_get(&state->infoarr, b);
@ -2280,7 +2280,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
}
/* for each map */
for(i=state->maplist;i!=0;i=i->next) {
for (i = state->maplist; i != 0; i = i->next) {
struct snapraid_map* map = i->data;
struct snapraid_disk* disk;
@ -2322,7 +2322,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
}
/* for each disk */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
tommy_node* j;
struct snapraid_disk* disk = i->data;
@ -2331,7 +2331,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
continue;
/* for each file */
for(j=disk->filelist;j!=0;j=j->next) {
for (j = disk->filelist; j != 0; j = j->next) {
struct snapraid_file* file = j->data;
uint64_t size;
uint64_t mtime_sec;
@ -2366,7 +2366,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
}
/* for each block in the file */
for(b=0;b<file->blockmax;++b) {
for (b = 0; b < file->blockmax; ++b) {
struct snapraid_block* block = &file->blockvec[b];
unsigned block_state = block_state_get(block);
@ -2388,7 +2388,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
case BLOCK_STATE_REP :
sputsl("rep ", f);
break;
default:
default :
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inconsistency in state for block %u state %u\n", block->parity_pos, block_state);
exit(EXIT_FAILURE);
@ -2415,7 +2415,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
}
/* for each link */
for(j=disk->linklist;j!=0;j=j->next) {
for (j = disk->linklist; j != 0; j = j->next) {
struct snapraid_link* link = j->data;
switch (link_flag_get(link, FILE_IS_LINK_MASK)) {
@ -2445,7 +2445,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
}
/* for each dir */
for(j=disk->dirlist;j!=0;j=j->next) {
for (j = disk->dirlist; j != 0; j = j->next) {
struct snapraid_dir* dir = j->data;
sputsl("dir ", f);
@ -2473,7 +2473,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
for(b=0;b<blockmax;++b) {
for (b = 0; b < blockmax; ++b) {
if (is_block_deleted(disk, b)) {
struct snapraid_block* block = disk_block_get(disk, b);
@ -2484,7 +2484,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
sputsl("off ", f);
sputu32(b, f);
sputc(' ', f);
@ -2501,7 +2501,7 @@ static void state_write_text(struct snapraid_state* state, STREAM* f)
}
/* write the info for each block */
for(b=0;b<blockmax;++b) {
for (b = 0; b < blockmax; ++b) {
snapraid_info info = info_get(&state->infoarr, b);
/* save only stuffs different than 0 */
@ -2555,7 +2555,7 @@ static void decoding_error(const char* path, STREAM* f)
if (seof(f)) {
/* LCOV_EXCL_START */
fprintf(stderr, "Unexpected end of content file '%s' at offset %"PRIi64"\n", path, stell(f));
fprintf(stderr, "Unexpected end of content file '%s' at offset %" PRIi64 "\n", path, stell(f));
fprintf(stderr, "This content file is truncated. Use an alternate copy.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
@ -2563,12 +2563,12 @@ static void decoding_error(const char* path, STREAM* f)
if (serror(f)) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error reading the content file '%s' at offset %"PRIi64"\n", path, stell(f));
fprintf(stderr, "Error reading the content file '%s' at offset %" PRIi64 "\n", path, stell(f));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
fprintf(stderr, "Decoding error in '%s' at offset %"PRIi64"\n", path, stell(f));
fprintf(stderr, "Decoding error in '%s' at offset %" PRIi64 "\n", path, stell(f));
buf[0] = 0;
buf[1] = 0;
@ -2591,7 +2591,7 @@ static void decoding_error(const char* path, STREAM* f)
if (serror(f)) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error flushing the content file '%s' at offset %"PRIi64"\n", path, stell(f));
fprintf(stderr, "Error flushing the content file '%s' at offset %" PRIi64 "\n", path, stell(f));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -2840,7 +2840,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
case 'p' :
block_state_set(block, BLOCK_STATE_REP);
break;
default:
default :
/* LCOV_EXCL_START */
decoding_error(path, f);
fprintf(stderr, "Invalid block type!\n");
@ -3123,7 +3123,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
/* go to the next run */
v_pos += v_count;
break;
default:
default :
/* LCOV_EXCL_START */
decoding_error(path, f);
fprintf(stderr, "Invalid hole type!\n");
@ -3283,7 +3283,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
case 'k' :
state->hash = HASH_SPOOKY2;
break;
default:
default :
/* LCOV_EXCL_START */
decoding_error(path, f);
fprintf(stderr, "Invalid checksum!\n");
@ -3310,7 +3310,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
case 'k' :
state->prevhash = HASH_SPOOKY2;
break;
default:
default :
/* LCOV_EXCL_START */
decoding_error(path, f);
fprintf(stderr, "Invalid checksum!\n");
@ -3419,7 +3419,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
if (ret < 0) {
/* LCOV_EXCL_START */
/* here don't call decoding_error() because it's too late to get the crc */
fprintf(stderr, "Error reading the CRC in '%s' at offset %"PRIi64"\n", path, stell(f));
fprintf(stderr, "Error reading the CRC in '%s' at offset %" PRIi64 "\n", path, stell(f));
fprintf(stderr, "This content file is damaged! Use an alternate copy.\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
@ -3448,7 +3448,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
if (serror(f)) {
/* LCOV_EXCL_START */
fprintf(stderr, "Error reading the content file '%s' at offset %"PRIi64"\n", path, stell(f));
fprintf(stderr, "Error reading the content file '%s' at offset %" PRIi64 "\n", path, stell(f));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
@ -3464,7 +3464,7 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
/* check that the stored parity size matches the loaded state */
if (blockmax != parity_size(state)) {
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inconsistency in parity size in '%s' at offset %"PRIi64"\n", path, stell(f));
fprintf(stderr, "Internal inconsistency in parity size in '%s' at offset %" PRIi64 "\n", path, stell(f));
if (state->opt.skip_content_check) {
fprintf(stderr, "Overriding from %u to %u.\n", blockmax, parity_size(state));
blockmax = parity_size(state);
@ -3514,7 +3514,7 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
/* and get some other info */
info_oldest = 0; /* oldest time in info */
info_has_rehash = 0; /* if there is a rehash info */
for(b=0;b<blockmax;++b) {
for (b = 0; b < blockmax; ++b) {
/* if the position is used */
if (position_is_required(state, b)) {
snapraid_info info = info_get(&state->infoarr, b);
@ -3599,7 +3599,7 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
/* for each map */
mapping_idx = 0;
for(i=state->maplist;i!=0;i=i->next) {
for (i = state->maplist; i != 0; i = i->next) {
struct snapraid_map* map = i->data;
struct snapraid_disk* disk;
@ -3635,7 +3635,7 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
}
/* for each disk */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
tommy_node* j;
struct snapraid_disk* disk = i->data;
@ -3644,7 +3644,7 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
continue;
/* for each file */
for(j=disk->filelist;j!=0;j=j->next) {
for (j = disk->filelist; j != 0; j = j->next) {
struct snapraid_file* file = j->data;
struct snapraid_block* blockvec = file->blockvec;
uint64_t size;
@ -3681,15 +3681,15 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
unsigned block_state = block_state_get(blockvec + begin);
uint32_t v_pos = blockvec[begin].parity_pos;
uint32_t v_count;
block_off_t end;
/* find the end of run of blocks */
end = begin + 1;
while (end < file->blockmax
&& block_state == block_state_get(blockvec + end)
&& blockvec[end-1].parity_pos + 1 == blockvec[end].parity_pos)
{
&& blockvec[end - 1].parity_pos + 1 == blockvec[end].parity_pos
) {
++end;
}
@ -3703,7 +3703,7 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
case BLOCK_STATE_REP :
sputc('p', f);
break;
default:
default :
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inconsistency in state for block %u state %u\n", v_pos, block_state);
exit(EXIT_FAILURE);
@ -3716,7 +3716,7 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
sputb32(v_count, f);
/* write hashes */
for(b=begin;b<end;++b) {
for (b = begin; b < end; ++b) {
struct snapraid_block* block = blockvec + b;
/* consistency check */
@ -3747,7 +3747,7 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
}
/* for each link */
for(j=disk->linklist;j!=0;j=j->next) {
for (j = disk->linklist; j != 0; j = j->next) {
struct snapraid_link* link = j->data;
switch (link_flag_get(link, FILE_IS_LINK_MASK)) {
@ -3773,7 +3773,7 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
}
/* for each dir */
for(j=disk->dirlist;j!=0;j=j->next) {
for (j = disk->dirlist; j != 0; j = j->next) {
struct snapraid_dir* dir = j->data;
sputc('r', f);
@ -3808,8 +3808,8 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
/* find the end of run of blocks */
end = begin + 1;
while (end < blockmax
&& is_deleted == is_block_deleted(disk, end))
{
&& is_deleted == is_block_deleted(disk, end)
) {
++end;
}
@ -3868,8 +3868,8 @@ static void state_write_binary(struct snapraid_state* state, STREAM* f)
/* find the end of run of blocks */
end = begin + 1;
while (end < blockmax
&& info == info_get(&state->infoarr, end))
{
&& info == info_get(&state->infoarr, end)
) {
++end;
}
@ -4011,7 +4011,7 @@ void state_read(struct snapraid_state* state)
if (other_st.st_size != st.st_size) {
fprintf(stderr, "WARNING! Content files '%s' and '%s' have a different size!\n", path, other_path);
fprintf(stderr, "Likely one of the two is broken!\n");
/* ensure to rewrite all the content files */
state->need_write = 1;
}
@ -4174,14 +4174,14 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom
if (state->opt.verbose) {
tommy_node* k;
for(k=tommy_list_head(filterlist_disk);k!=0;k=k->next) {
for (k = tommy_list_head(filterlist_disk); k != 0; k = k->next) {
struct snapraid_filter* filter = k->data;
printf("\t%s", filter->pattern);
if (filter->is_disk)
printf("//");
printf("\n");
}
for(k=tommy_list_head(filterlist_file);k!=0;k=k->next) {
for (k = tommy_list_head(filterlist_file); k != 0; k = k->next) {
struct snapraid_filter* filter = k->data;
printf("\t%s", filter->pattern);
if (filter->is_dir)
@ -4195,7 +4195,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom
}
/* for each disk */
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
tommy_node* j;
struct snapraid_disk* disk = i->data;
@ -4204,7 +4204,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom
printf("Scanning disk %s...\n", disk->name);
/* for each file */
for(j=tommy_list_head(&disk->filelist);j!=0;j=j->next) {
for (j = tommy_list_head(&disk->filelist); j != 0; j = j->next) {
struct snapraid_file* file = j->data;
if (filter_path(filterlist_disk, disk->name, file->sub) != 0
@ -4217,7 +4217,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom
}
/* for each link */
for(j=tommy_list_head(&disk->linklist);j!=0;j=j->next) {
for (j = tommy_list_head(&disk->linklist); j != 0; j = j->next) {
struct snapraid_link* link = j->data;
if (filter_path(filterlist_disk, disk->name, link->sub) != 0
@ -4229,7 +4229,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom
}
/* for each dir */
for(j=tommy_list_head(&disk->dirlist);j!=0;j=j->next) {
for (j = tommy_list_head(&disk->dirlist); j != 0; j = j->next) {
struct snapraid_dir* dir = j->data;
if (filter_dir(filterlist_disk, disk->name, dir->sub) != 0
@ -4245,7 +4245,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist_file, tom
int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, block_off_t blockmax, block_off_t countmax)
{
if (state->opt.gui) {
fprintf(stdlog,"run:begin:%u:%u:%u\n", blockstart, blockmax, countmax);
fprintf(stdlog, "run:begin:%u:%u:%u\n", blockstart, blockmax, countmax);
fflush(stdlog);
} else {
time_t now;
@ -4283,7 +4283,7 @@ void state_progress_end(struct snapraid_state* state, block_off_t countpos, bloc
time_t now;
time_t elapsed;
unsigned countsize_MiB = (countsize + 1024*1024 - 1) / (1024*1024);
unsigned countsize_MiB = (countsize + 1024 * 1024 - 1) / (1024 * 1024);
now = time(0);
@ -4309,7 +4309,7 @@ void state_progress_stop(struct snapraid_state* state)
now = time(0);
printf("\n");
state->progress_interruption = now;
}
@ -4330,7 +4330,7 @@ void state_progress_restart(struct snapraid_state* state)
int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off_t countpos, block_off_t countmax, data_off_t countsize)
{
if (state->opt.gui) {
fprintf(stdlog, "run:pos:%u:%u:%"PRIu64"\n", blockpos, countpos, countsize);
fprintf(stdlog, "run:pos:%u:%u:%" PRIu64 "\n", blockpos, countpos, countsize);
fflush(stdlog);
} else {
time_t now;
@ -4351,7 +4351,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
tick_total = state->tick_cpu + state->tick_io;
tick_cpu = state->tick_cpu;
printf("%u%%, %u MiB", countpos * 100 / countmax, (unsigned)(countsize / (1024*1024)));
printf("%u%%, %u MiB", countpos * 100 / countmax, (unsigned)(countsize / (1024 * 1024)));
/* if we have at least 5 measures */
if (state->progress_tick >= 5) {
@ -4389,10 +4389,10 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
delta_tick_cpu = tick_cpu - state->progress_tick_cpu[oldest];
if (delta_time != 0)
printf(", %u MiB/s", (unsigned)(delta_size / (1024*1024) / delta_time));
printf(", %u MiB/s", (unsigned)(delta_size / (1024 * 1024) / delta_time));
if (delta_tick_total != 0)
printf(", CPU %"PRIu64"%%", delta_tick_cpu * 100U / delta_tick_total);
printf(", CPU %" PRIu64 "%%", delta_tick_cpu * 100U / delta_tick_total);
/* estimate the remaining time */
if (delta_pos != 0) {
@ -4452,13 +4452,13 @@ void state_usage_print(struct snapraid_state* state)
tick_max = 0;
tick_total = 0;
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
tick_total += disk->tick;
if (disk->tick > tick_max)
tick_max = disk->tick;
}
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
tick_total += state->tick_parity[l];
if (state->tick_parity[l] > tick_max)
tick_max = state->tick_parity[l];
@ -4468,23 +4468,23 @@ void state_usage_print(struct snapraid_state* state)
return;
printf("Time for disk:");
for(i=state->disklist;i!=0;i=i->next) {
for (i = state->disklist; i != 0; i = i->next) {
struct snapraid_disk* disk = i->data;
if (disk->tick == tick_max)
printf(" %s:", disk->name);
else
printf(" ");
printf("%"PRIu64"%%", disk->tick * 100U / tick_total);
printf("%" PRIu64 "%%", disk->tick * 100U / tick_total);
}
printf("\n");
printf("Time for parity:");
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
if (state->tick_parity[l] == tick_max)
printf(" %s:", lev_config_name(l));
else
printf(" ");
printf("%"PRIu64"%%", state->tick_parity[l] * 100U / tick_total);
printf("%" PRIu64 "%%", state->tick_parity[l] * 100U / tick_total);
}
printf("\n");
}
@ -4516,7 +4516,7 @@ void generate_configuration(const char* path)
printf("# Use this blocksize\n");
printf("blocksize %u\n", state.block_size / 1024);
printf("\n");
for(i=0;i<LEV_MAX;++i) {
for (i = 0; i < LEV_MAX; ++i) {
printf("# Set the correct path for the %s file%s\n", lev_name(i), i != 0 ? " (if used)" : "");
printf("%s ENTER_HERE_THE_PARITY_FILE\n", lev_config_name(i));
printf("\n");
@ -4524,7 +4524,7 @@ void generate_configuration(const char* path)
printf("# Add any other content file\n");
printf("content %s\n", path);
printf("\n");
for(j=state.maplist;j;j=j->next) {
for (j = state.maplist; j; j = j->next) {
struct snapraid_map* map = j->data;
struct snapraid_disk* disk;
printf("# Set the correct dir for disk '%s'\n", map->name);

View file

@ -67,7 +67,7 @@ int state_status(struct snapraid_state* state)
file_size = 0;
file_fragmented = 0;
extra_fragment = 0;
for(node_disk=state->disklist;node_disk!=0;node_disk=node_disk->next) {
for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) {
struct snapraid_disk* disk = node_disk->data;
tommy_node* node;
unsigned disk_file_count = 0;
@ -90,7 +90,7 @@ int state_status(struct snapraid_state* state)
fragmented = 0;
prev_pos = file->blockvec[0].parity_pos;
for(i=1;i<file->blockmax;++i) {
for (i = 1; i < file->blockmax; ++i) {
block_off_t parity_pos = file->blockvec[i].parity_pos;
if (prev_pos + 1 != parity_pos) {
fragmented = 1;
@ -116,7 +116,7 @@ int state_status(struct snapraid_state* state)
fprintf(stdlog, "summary:disk_file_count:%s:%u\n", disk->name, disk_file_count);
fprintf(stdlog, "summary:disk_fragmented_file_count:%s:%u\n", disk->name, disk_file_fragmented);
fprintf(stdlog, "summary:disk_excess_fragment_count:%s:%u\n", disk->name, disk_extra_fragment);
fprintf(stdlog, "summary:disk_file_size:%s:%"PRIu64"\n", disk->name, disk_file_size);
fprintf(stdlog, "summary:disk_file_size:%s:%" PRIu64 "\n", disk->name, disk_file_size);
}
printf("\n");
@ -124,16 +124,16 @@ int state_status(struct snapraid_state* state)
printf("Files: %u\n", file_count);
printf("Fragmented files: %u\n", file_fragmented);
printf("Excess fragments: %u\n", extra_fragment);
printf("Files size: %"PRIu64" GiB\n", file_size / (1024*1024*1024) );
printf("Parity size: %"PRIu64" GiB\n", blockmax * (uint64_t)state->block_size / (1024*1024*1024) );
printf("Files size: %" PRIu64 " GiB\n", file_size / (1024 * 1024 * 1024) );
printf("Parity size: %" PRIu64 " GiB\n", blockmax * (uint64_t)state->block_size / (1024 * 1024 * 1024) );
printf("\n");
fprintf(stdlog, "summary:file_count:%u\n", file_count);
fprintf(stdlog, "summary:fragmented_file_count:%u\n", file_fragmented);
fprintf(stdlog, "summary:excess_fragment_count:%u\n", extra_fragment);
fprintf(stdlog, "summary:file_size:%"PRIu64"\n", file_size);
fprintf(stdlog, "summary:parity_size:%"PRIu64"\n", blockmax * (uint64_t)state->block_size);
fprintf(stdlog, "summary:file_size:%" PRIu64 "\n", file_size);
fprintf(stdlog, "summary:parity_size:%" PRIu64 "\n", blockmax * (uint64_t)state->block_size);
fprintf(stdlog, "summary:hash:%s\n", hash_config_name(state->hash));
fprintf(stdlog, "summary:prev_hash:%s\n", hash_config_name(state->prevhash));
fprintf(stdlog, "summary:best_hash:%s\n", hash_config_name(state->besthash));
@ -146,7 +146,7 @@ int state_status(struct snapraid_state* state)
rehash = 0;
unsynced_blocks = 0;
fprintf(stdlog, "block_count:%u\n", blockmax);
for(i=0;i<blockmax;++i) {
for (i = 0; i < blockmax; ++i) {
int one_invalid;
int one_valid;
@ -155,7 +155,7 @@ int state_status(struct snapraid_state* state)
/* for each disk */
one_invalid = 0;
one_valid = 0;
for(node_disk=state->disklist;node_disk!=0;node_disk=node_disk->next) {
for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) {
struct snapraid_disk* disk = node_disk->data;
struct snapraid_block* block = disk_block_get(disk, i);
@ -183,9 +183,9 @@ int state_status(struct snapraid_state* state)
if (state->opt.gui) {
if (info != 0)
fprintf(stdlog, "block:%u:%"PRIu64":%s:%s:%s:%s\n", i, (uint64_t)info_get_time(info), one_valid ? "used": "", one_invalid ? "unsynced" : "", info_get_bad(info) ? "bad" : "", info_get_rehash(info) ? "rehash" : "");
fprintf(stdlog, "block:%u:%" PRIu64 ":%s:%s:%s:%s\n", i, (uint64_t)info_get_time(info), one_valid ? "used" : "", one_invalid ? "unsynced" : "", info_get_bad(info) ? "bad" : "", info_get_rehash(info) ? "rehash" : "");
else
fprintf(stdlog, "block_noinfo:%u:%s:%s\n", i, one_valid ? "used": "", one_invalid ? "unsynced" : "");
fprintf(stdlog, "block_noinfo:%u:%s:%s\n", i, one_valid ? "used" : "", one_invalid ? "unsynced" : "");
}
}
@ -210,7 +210,7 @@ int state_status(struct snapraid_state* state)
unsigned j = i + 1;
while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j]))
++j;
fprintf(stdlog, "info_time:%"PRIu64":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
fprintf(stdlog, "info_time:%" PRIu64 ":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
i = j;
}
@ -224,11 +224,11 @@ int state_status(struct snapraid_state* state)
/* compute graph limits */
barpos = 0;
barmax = 0;
for(i=0;i<GRAPH_COLUMN;++i) {
for (i = 0; i < GRAPH_COLUMN; ++i) {
time_t limit;
unsigned step;
limit = oldest + (newest - oldest) * (i+1) / GRAPH_COLUMN;
limit = oldest + (newest - oldest) * (i + 1) / GRAPH_COLUMN;
step = 0;
while (barpos < count && info_get_time(infomap[barpos]) <= limit) {
@ -243,19 +243,19 @@ int state_status(struct snapraid_state* state)
}
/* print the graph */
for(y=0;y<GRAPH_ROW;++y) {
for (y = 0; y < GRAPH_ROW; ++y) {
if (y == 0)
printf("%3u%% ", barmax * 100 / count);
else if (y == GRAPH_ROW - 1)
printf(" 0%% ");
else if (y == GRAPH_ROW/2)
else if (y == GRAPH_ROW / 2)
printf("%3u%% ", barmax * 50 / count);
else
printf(" ");
for(x=0;x<GRAPH_COLUMN;++x) {
unsigned pivot = barmax * (GRAPH_ROW-y) / GRAPH_ROW;
for (x = 0; x < GRAPH_COLUMN; ++x) {
unsigned pivot = barmax * (GRAPH_ROW - y) / GRAPH_ROW;
/* if it's the baseline */
if (y == GRAPH_ROW-1) {
if (y == GRAPH_ROW - 1) {
if (bar[x] >= pivot) {
printf("*");
} else if (bar[x] > 0) {
@ -307,13 +307,13 @@ int state_status(struct snapraid_state* state)
printf("They are at blocks:");
/* print all the errors */
for(i=0;i<blockmax;++i) {
for (i = 0; i < blockmax; ++i) {
snapraid_info info = info_get(&state->infoarr, i);
/* skip unused blocks */
if (info == 0)
continue;
if (info_get_bad(info))
printf(" %u", i);
}

View file

@ -53,14 +53,14 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
/* first count the number of blocks to process */
countmax = 0;
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
struct snapraid_disk* disk = handle[j].disk;
/* if unused disk skip it */
if (!disk)
continue;
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
struct snapraid_block* block;
block = disk_block_get(disk, i);
@ -85,14 +85,14 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
if (!state_progress_begin(state, blockstart, blockmax, countmax))
goto end;
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
struct snapraid_disk* disk = handle[j].disk;
/* if unused disk skip it */
if (!disk)
continue;
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
snapraid_info info;
int rehash;
struct snapraid_block* block;
@ -189,12 +189,12 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
struct snapraid_file* file = block_file_get(block);
fprintf(stdlog, "error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, file->sub);
if (handle[j].st.st_size != file->size) {
fprintf(stderr, "Unexpected size change at file '%s' from %"PRIu64" to %"PRIu64".\n", handle[j].path, file->size, handle[j].st.st_size);
fprintf(stderr, "Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, handle[j].st.st_size);
} else if (handle[j].st.st_mtime != file->mtime_sec
|| STAT_NSEC(&handle[j].st) != file->mtime_nsec) {
fprintf(stderr, "Unexpected time change at file '%s' from %"PRIu64".%d to %"PRIu64".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, (uint32_t)STAT_NSEC(&handle[j].st));
fprintf(stderr, "Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, (uint32_t)STAT_NSEC(&handle[j].st));
} else {
fprintf(stderr, "Unexpected inode change from %"PRIu64" to %"PRIu64" at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
fprintf(stderr, "Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
}
fprintf(stderr, "WARNING! You cannot modify files during a sync.\n");
fprintf(stderr, "Rerun the sync command when finished.\n");
@ -290,7 +290,7 @@ end:
fprintf(stdlog, "hash_summary:error_readwrite:%u\n", error);
bail:
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
ret = handle_close(&handle[j]);
if (ret == -1) {
fprintf(stderr, "DANGER! Unexpected close error in a data disk.\n");
@ -372,8 +372,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
mtest_vector(buffermax, state->block_size, buffer);
/* fill up the zero buffer */
memset(buffer[buffermax-1], 0, state->block_size);
raid_zero(buffer[buffermax-1]);
memset(buffer[buffermax - 1], 0, state->block_size);
raid_zero(buffer[buffermax - 1]);
failed = malloc_nofail(diskmax * sizeof(struct failed_struct));
failed_map = malloc_nofail(diskmax * sizeof(unsigned));
@ -383,14 +383,14 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* first count the number of blocks to process */
countmax = 0;
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
int one_invalid;
int one_valid;
/* for each disk */
one_invalid = 0;
one_valid = 0;
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
struct snapraid_block* block = BLOCK_EMPTY;
if (handle[j].disk)
block = disk_block_get(handle[j].disk, i);
@ -426,7 +426,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
if (!state_progress_begin(state, blockstart, blockmax, countmax))
goto end;
for(i=blockstart;i<blockmax;++i) {
for (i = blockstart; i < blockmax; ++i) {
unsigned failed_count;
int one_invalid;
int one_valid;
@ -440,7 +440,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* for each disk */
one_invalid = 0;
one_valid = 0;
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
struct snapraid_block* block = BLOCK_EMPTY;
if (handle[j].disk)
block = disk_block_get(handle[j].disk, i);
@ -490,7 +490,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
parity_needs_to_be_updated = 1;
/* for each disk, process the block */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
int read_size;
unsigned char hash[HASH_SIZE];
struct snapraid_block* block;
@ -596,7 +596,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
error_on_this_block = 1;
continue;
}
/* LCOV_EXCL_START */
fprintf(stdlog, "error:%u:%s:%s: Open error. %s\n", i, disk->name, file->sub, strerror(errno));
fprintf(stderr, "DANGER! Unexpected open error in a data disk, it isn't possible to sync.\n");
@ -618,12 +618,12 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
struct snapraid_file* file = block_file_get(block);
fprintf(stdlog, "error:%u:%s:%s: Unexpected attribute change\n", i, disk->name, file->sub);
if (handle[j].st.st_size != file->size) {
fprintf(stderr, "Unexpected size change at file '%s' from %"PRIu64" to %"PRIu64".\n", handle[j].path, file->size, handle[j].st.st_size);
fprintf(stderr, "Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, handle[j].st.st_size);
} else if (handle[j].st.st_mtime != file->mtime_sec
|| STAT_NSEC(&handle[j].st) != file->mtime_nsec) {
fprintf(stderr, "Unexpected time change at file '%s' from %"PRIu64".%d to %"PRIu64".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, (uint32_t)STAT_NSEC(&handle[j].st));
fprintf(stderr, "Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, (uint32_t)STAT_NSEC(&handle[j].st));
} else {
fprintf(stderr, "Unexpected inode change from %"PRIu64" to %"PRIu64" at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
fprintf(stderr, "Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
}
fprintf(stderr, "WARNING! You cannot modify files during a sync.\n");
fprintf(stderr, "Rerun the sync command when finished.\n");
@ -733,7 +733,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
parity_needs_to_be_updated = 1;
}
}
/* copy the hash in the block, but doesn't mark the block as hashed */
/* this allow in case of skipped block to do not save the failed computation */
memcpy(block->hash, hash, HASH_SIZE);
@ -752,7 +752,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* setup the blocks to recover */
failed_mac = 0;
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
unsigned char* block_buffer = buffer[failed[j].index];
unsigned char* block_copy = buffer[diskmax + state->level + failed[j].index];
unsigned block_state = block_state_get(failed[j].block);
@ -789,8 +789,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* read the parity */
/* we are sure that parity exists because */
/* we have at least one BLK block */
for(l=0;l<state->level;++l) {
ret = parity_read(parity[l], i, buffer[diskmax+l], state->block_size, stdlog);
for (l = 0; l < state->level; ++l) {
ret = parity_read(parity[l], i, buffer[diskmax + l], state->block_size, stdlog);
if (ret == -1) {
/* LCOV_EXCL_START */
fprintf(stdlog, "parity_error:%u:%s: Read error\n", i, lev_config_name(l));
@ -810,7 +810,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
raid_rec(failed_mac, failed_map, diskmax, state->level, state->block_size, buffer);
/* check the result and prepare the data */
for(j=0;j<failed_count;++j) {
for (j = 0; j < failed_count; ++j) {
unsigned char hash[HASH_SIZE];
unsigned char* block_buffer = buffer[failed[j].index];
unsigned char* block_copy = buffer[diskmax + state->level + failed[j].index];
@ -862,8 +862,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
state_usage_cpu(state);
/* write the parity */
for(l=0;l<state->level;++l) {
ret = parity_write(parity[l], i, buffer[diskmax+l], state->block_size);
for (l = 0; l < state->level; ++l) {
ret = parity_write(parity[l], i, buffer[diskmax + l], state->block_size);
if (ret == -1) {
/* LCOV_EXCL_START */
fprintf(stdlog, "parity_error:%u:%s: Write error\n", i, lev_config_name(l));
@ -881,7 +881,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
}
/* for each disk, mark the blocks as processed */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
struct snapraid_block* block = BLOCK_EMPTY;
if (handle[j].disk)
block = disk_block_get(handle[j].disk, i);
@ -913,7 +913,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* if rehash is neeed */
if (rehash) {
/* store all the new hash already computed */
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
if (rehandle[j].block)
memcpy(rehandle[j].block->hash, rehandle[j].hash, HASH_SIZE);
}
@ -993,7 +993,7 @@ end:
fflush(stdlog);
bail:
for(j=0;j<diskmax;++j) {
for (j = 0; j < diskmax; ++j) {
ret = handle_close(&handle[j]);
if (ret == -1) {
fprintf(stderr, "DANGER! Unexpected close error in a data disk.\n");
@ -1052,7 +1052,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
blockmax = blockstart + blockcount;
}
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
/* create the file and open for writing */
parity_ptr[l] = &parity[l];
ret = parity_create(parity_ptr[l], state->parity_path[l], &out_size, state->file_mode);
@ -1118,7 +1118,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
}
}
for(l=0;l<state->level;++l) {
for (l = 0; l < state->level; ++l) {
ret = parity_sync(parity_ptr[l]);
if (ret == -1) {
/* LCOV_EXCL_START */

View file

@ -209,7 +209,7 @@ int fsinfo(const char* path, int* has_persistent_inode)
{
#if HAVE_STATFS && HAVE_STRUCT_STATFS_F_TYPE
struct statfs st;
if (statfs(path, &st) != 0)
return -1;
@ -220,7 +220,7 @@ int fsinfo(const char* path, int* has_persistent_inode)
case 0x4d44 : /* VFAT, "msdos" in the stat command */
*has_persistent_inode = 0;
break;
default:
default :
/* by default assume yes */
*has_persistent_inode = 1;
break;

View file

@ -102,7 +102,7 @@ STREAM* sopen_multi_write(unsigned count)
s->handle_size = count;
s->handle = malloc_nofail(count * sizeof(struct stream_handle));
for(i=0;i<count;++i)
for (i = 0; i < count; ++i)
s->handle[i].f = -1;
s->buffer = malloc_nofail(STREAM_SIZE);
@ -163,7 +163,7 @@ int sclose(STREAM* s)
}
}
for(i=0;i<s->handle_size;++i) {
for (i = 0; i < s->handle_size; ++i) {
if (close(s->handle[i].f) != 0) {
/* LCOV_EXCL_START */
fail = 1;
@ -252,7 +252,7 @@ int sflush(STREAM* s)
s->crc = crc32c(s->crc, s->buffer, size);
s->crc_uncached = s->crc;
for(i=0;i<s->handle_size;++i) {
for (i = 0; i < s->handle_size; ++i) {
ret = write(s->handle[i].f, s->buffer, size);
if (ret != size) {
@ -424,7 +424,7 @@ int sgetlasttok(STREAM* f, char* str, int size)
/* LCOV_EXCL_STOP */
}
while (ret > 0 && (str[ret-1] == ' ' || str[ret-1] == '\t'))
while (ret > 0 && (str[ret - 1] == ' ' || str[ret - 1] == '\t'))
--ret;
str[ret] = 0;
@ -437,13 +437,13 @@ int sgetu32(STREAM* f, uint32_t* value)
int c;
c = sgetc(f);
if (c>='0' && c<='9') {
if (c >= '0' && c <= '9') {
uint32_t v;
v = c - '0';
c = sgetc(f);
while (c>='0' && c<='9') {
while (c >= '0' && c <= '9') {
v *= 10;
v += c - '0';
c = sgetc(f);
@ -466,13 +466,13 @@ int sgetu64(STREAM* f, uint64_t* value)
int c;
c = sgetc(f);
if (c>='0' && c<='9') {
if (c >= '0' && c <= '9') {
uint64_t v;
v = c - '0';
c = sgetc(f);
while (c>='0' && c<='9') {
while (c >= '0' && c <= '9') {
v *= 10;
v += c - '0';
c = sgetc(f);
@ -872,7 +872,7 @@ int ssync(STREAM* s)
{
unsigned i;
for(i=0;i<s->handle_size;++i) {
for (i = 0; i < s->handle_size; ++i) {
if (fsync(s->handle[i].f) != 0) {
/* LCOV_EXCL_START */
s->state = STREAM_STATE_ERROR;
@ -1314,7 +1314,7 @@ void pathprint(char* dst, size_t size, const char* format, ...)
{
size_t len;
va_list ap;
va_start(ap, format);
len = vsnprintf(dst, size, format, ap);
va_end(ap);
@ -1340,7 +1340,7 @@ void pathslash(char* dst, size_t size)
}
dst[len] = '/';
dst[len+1] = 0;
dst[len + 1] = 0;
}
}
@ -1589,12 +1589,12 @@ void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr)
return ptr;
}
void mrand_vector(int n , size_t size, void** vv)
void mrand_vector(int n, size_t size, void** vv)
{
raid_mrand_vector(n, size, vv);
}
void mtest_vector(int n , size_t size, void** vv)
void mtest_vector(int n, size_t size, void** vv)
{
if (raid_mtest_vector(n, size, vv) != 0) {
/* LCOV_EXCL_START */
@ -1642,15 +1642,15 @@ static inline uint64_t util_rotl64(uint64_t x, int8_t r)
static inline uint32_t util_swap32(uint32_t v)
{
return (util_rotl32(v, 8) & 0x00ff00ff)
| (util_rotl32(v, 24) & 0xff00ff00);
| (util_rotl32(v, 24) & 0xff00ff00);
}
static inline uint64_t util_swap64(uint64_t v)
{
return (util_rotl64(v, 8) & 0x000000ff000000ffULL)
| (util_rotl64(v, 24) & 0x0000ff000000ff00ULL)
| (util_rotl64(v, 40) & 0x00ff000000ff0000ULL)
| (util_rotl64(v, 56) & 0xff000000ff000000ULL);
| (util_rotl64(v, 24) & 0x0000ff000000ff00ULL)
| (util_rotl64(v, 40) & 0x00ff000000ff0000ULL)
| (util_rotl64(v, 56) & 0xff000000ff000000ULL);
}
#endif
@ -1669,7 +1669,7 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void*
case HASH_SPOOKY2 :
SpookyHash128(src, size, seed, digest);
break;
default:
default :
/* LCOV_EXCL_START */
fprintf(stderr, "Internal inconsistency in hash function %u\n", kind);
exit(EXIT_FAILURE);
@ -1684,7 +1684,7 @@ const char* hash_config_name(unsigned kind)
case HASH_UNDEFINED : return "undefined";
case HASH_MURMUR3 : return "murmur3";
case HASH_SPOOKY2 : return "spooky2";
default:
default :
/* LCOV_EXCL_START */
return "unknown";
/* LCOV_EXCL_STOP */
@ -1699,7 +1699,7 @@ void randomize(void* void_ptr, unsigned size)
unsigned char* ptr = void_ptr;
unsigned i;
for(i=0;i<size;++i)
for (i = 0; i < size; ++i)
ptr[i] = rand();
}

View file

@ -21,7 +21,7 @@
/****************************************************************************/
/* stream */
#define STREAM_SIZE (64*1024) /**< Size of the buffer of the stream. */
#define STREAM_SIZE (64 * 1024) /**< Size of the buffer of the stream. */
#define STREAM_STATE_READ 0 /**< The stream is in a normal state of read. */
#define STREAM_STATE_WRITE 1 /**< The stream is in a normal state of write. */
@ -431,7 +431,7 @@ void pathprint(char* dst, size_t size, const char* format, ...);
/**
* Ensures the presence of a terminating slash, if it isn't empty.
* Aborts if too long.
* Aborts if too long.
*/
void pathslash(char* dst, size_t size);