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;

View file

@ -3,7 +3,7 @@ AC_PREREQ([2.65])
AC_INIT([snapraid], [8.1], [], [], [http://www.snapraid.it])
AM_INIT_AUTOMAKE([foreign no-dependencies subdir-objects])
AC_CONFIG_SRCDIR([cmdline/snapraid.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_HOST
dnl Checks for programs.
@ -90,6 +90,9 @@ AC_C_BIGENDIAN
dnl Checks for compiler
AC_CHECK_CC_OPT([-Wall], CFLAGS="$CFLAGS -Wall", [])
AC_CHECK_CC_OPT([-Wextra], CFLAGS="$CFLAGS -Wextra", [])
AC_CHECK_CC_OPT([-Wuninitialized], CFLAGS="$CFLAGS -Wuninitialized", [])
AC_CHECK_CC_OPT([-Wshadow], CFLAGS="$CFLAGS -Wshadow", [])
AC_CHECK_CC_OPT([-Wpadded], CFLAGS="$CFLAGS -Wpadded", [])
dnl Checks for AS supporting the SSE2 instructions.
AC_MSG_CHECKING([for sse2])

View file

@ -16,7 +16,7 @@
static struct raid_func {
const char *name;
void *p;
void (*p)();
} RAID_FUNC[] = {
{ "int8", raid_gen3_int8 },
{ "int8", raid_gen4_int8 },
@ -78,7 +78,7 @@ static struct raid_func {
{ 0, 0 }
};
static const char *raid_tag(void *func)
static const char *raid_tag(void (*func)())
{
struct raid_func *i = RAID_FUNC;