Add some more warning checks, and fix the ones reported

This commit is contained in:
Andrea Mazzoleni 2015-08-05 09:42:11 +02:00
parent d493277ea1
commit 77117b1cd5
5 changed files with 23 additions and 14 deletions

View file

@ -302,19 +302,19 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* logs the status */
for (j = 0; j < failed_count; ++j) {
const char* state;
const char* desc;
const char* hash;
const char* data;
struct snapraid_block* block = failed[j].block;
unsigned block_state = block_state_get(block);
switch (block_state) {
case BLOCK_STATE_DELETED : state = "delete"; break;
case BLOCK_STATE_CHG : state = "change"; break;
case BLOCK_STATE_REP : state = "replace"; break;
case BLOCK_STATE_BLK : state = "block"; break;
case BLOCK_STATE_DELETED : desc = "delete"; break;
case BLOCK_STATE_CHG : desc = "change"; break;
case BLOCK_STATE_REP : desc = "replace"; break;
case BLOCK_STATE_BLK : desc = "block"; break;
/* LCOV_EXCL_START */
default : state = "unknown"; break;
default : desc = "unknown"; break;
/* LCOV_EXCL_STOP */
}
@ -338,9 +338,9 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
disk = handle->disk->name;
sub = block_file_get(block)->sub;
log_tag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, state, hash, data, disk, esc(sub), block_file_pos(block));
log_tag("entry:%u:%s:%s:%s:%s:%s:%u:\n", j, desc, hash, data, disk, esc(sub), block_file_pos(block));
} else {
log_tag("entry:%u:%s:%s:%s:\n", j, state, hash, data);
log_tag("entry:%u:%s:%s:%s:\n", j, desc, hash, data);
}
}

View file

@ -491,4 +491,10 @@ fnmatch (pattern, string, flags)
#endif /* _LIBC or not __GNU_LIBRARY__. */
#else
/* avoid the warning: ISO C forbids an empty translation unit */
extern int make_iso_compilers_happy;
#endif

View file

@ -112,7 +112,7 @@ int state_status(struct snapraid_state* state)
for (node_disk = state->disklist; node_disk != 0; node_disk = node_disk->next) {
struct snapraid_disk* disk = node_disk->data;
tommy_node* node;
block_off_t i;
block_off_t j;
unsigned disk_file_count = 0;
unsigned disk_file_fragmented = 0;
unsigned disk_extra_fragment = 0;
@ -139,8 +139,8 @@ int state_status(struct snapraid_state* state)
fragmented = 0;
prev_pos = file->blockvec[0].parity_pos;
for (i = 1; i < file->blockmax; ++i) {
block_off_t parity_pos = file->blockvec[i].parity_pos;
for (j = 1; j < file->blockmax; ++j) {
block_off_t parity_pos = file->blockvec[j].parity_pos;
if (prev_pos + 1 != parity_pos) {
fragmented = 1;
++extra_fragment;