mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Addresses extra warnings.
This commit is contained in:
parent
9b74284e35
commit
15cfa07454
11 changed files with 62 additions and 52 deletions
40
check.c
40
check.c
|
|
@ -1185,7 +1185,7 @@ close_and_continue:
|
|||
char path[PATH_MAX];
|
||||
struct stat st;
|
||||
struct snapraid_file* file;
|
||||
int failed = 0;
|
||||
int unsuccesful = 0;
|
||||
|
||||
file = node->data;
|
||||
node = node->next; /* next node */
|
||||
|
|
@ -1204,24 +1204,24 @@ close_and_continue:
|
|||
pathprint(path, sizeof(path), "%s%s", disk->dir, file->sub);
|
||||
ret = stat(path, &st);
|
||||
if (ret == -1) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error stating empty file '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stdlog, "error:%s:%s: Empty file stat error\n", disk->name, file->sub);
|
||||
++error;
|
||||
} else if (!S_ISREG(st.st_mode)) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "error:%s:%s: Empty file error for not regular file\n", disk->name, file->sub);
|
||||
++error;
|
||||
} else if (st.st_size != 0) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "error:%s:%s: Empty file error for size '%"PRIu64"'\n", disk->name, file->sub, st.st_size);
|
||||
++error;
|
||||
}
|
||||
|
||||
if (fix && failed) {
|
||||
if (fix && unsuccesful) {
|
||||
int f;
|
||||
|
||||
/* create the ancestor directories */
|
||||
|
|
@ -1297,7 +1297,7 @@ close_and_continue:
|
|||
struct stat st;
|
||||
struct stat stto;
|
||||
struct snapraid_link* link;
|
||||
int failed = 0;
|
||||
int unsuccesful = 0;
|
||||
int unrecoverable = 0;
|
||||
|
||||
link = node->data;
|
||||
|
|
@ -1313,13 +1313,13 @@ close_and_continue:
|
|||
pathprint(path, sizeof(path), "%s%s", disk->dir, link->sub);
|
||||
ret = stat(path, &st);
|
||||
if (ret == -1) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error stating hardlink '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink stat error\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
} else if (!S_ISREG(st.st_mode)) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink error for not regular file\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
|
|
@ -1329,7 +1329,7 @@ close_and_continue:
|
|||
pathprint(pathto, sizeof(pathto), "%s%s", disk->dir, link->linkto);
|
||||
ret = stat(pathto, &stto);
|
||||
if (ret == -1) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
if (errno == ENOENT) {
|
||||
unrecoverable = 1;
|
||||
|
|
@ -1349,12 +1349,12 @@ close_and_continue:
|
|||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink to stat error\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
} else if (!S_ISREG(stto.st_mode)) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink-to error for not regular file\n", disk->name, link->sub, link->linkto);
|
||||
++error;
|
||||
} else if (!failed && st.st_ino != stto.st_ino) {
|
||||
failed = 1;
|
||||
} else if (!unsuccesful && st.st_ino != stto.st_ino) {
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Mismatch hardlink '%s' and '%s'. Different inode.\n", path, pathto);
|
||||
fprintf(stdlog, "hardlinkerror:%s:%s:%s: Hardlink mismatch for different inode\n", disk->name, link->sub, link->linkto);
|
||||
|
|
@ -1365,13 +1365,13 @@ close_and_continue:
|
|||
pathprint(path, sizeof(path), "%s%s", disk->dir, link->sub);
|
||||
ret = readlink(path, linkto, sizeof(linkto));
|
||||
if (ret < 0) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error reading symlink '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stdlog, "symlinkerror:%s:%s: Symlink read error\n", disk->name, link->sub);
|
||||
++error;
|
||||
} else if (ret >= PATH_MAX) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error reading symlink '%s'. Symlink too long.\n", path);
|
||||
fprintf(stdlog, "symlinkerror:%s:%s: Symlink read error\n", disk->name, link->sub);
|
||||
|
|
@ -1380,7 +1380,7 @@ close_and_continue:
|
|||
linkto[ret] = 0;
|
||||
|
||||
if (strcmp(linkto, link->linkto) != 0) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "symlinkerror:%s:%s: Symlink data error '%s' instead of '%s'\n", disk->name, link->sub, linkto, link->linkto);
|
||||
++error;
|
||||
|
|
@ -1388,7 +1388,7 @@ close_and_continue:
|
|||
}
|
||||
}
|
||||
|
||||
if (fix && failed && !unrecoverable) {
|
||||
if (fix && unsuccesful && !unrecoverable) {
|
||||
/* create the ancestor directories */
|
||||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
|
|
@ -1467,7 +1467,7 @@ close_and_continue:
|
|||
char path[PATH_MAX];
|
||||
struct stat st;
|
||||
struct snapraid_dir* dir;
|
||||
int failed = 0;
|
||||
int unsuccesful = 0;
|
||||
|
||||
dir = node->data;
|
||||
node = node->next; /* next node */
|
||||
|
|
@ -1481,19 +1481,19 @@ close_and_continue:
|
|||
pathprint(path, sizeof(path), "%s%s", disk->dir, dir->sub);
|
||||
ret = stat(path, &st);
|
||||
if (ret == -1) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "Error stating dir '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stdlog, "dir_error:%s:%s: Dir stat error\n", disk->name, dir->sub);
|
||||
++error;
|
||||
} else if (!S_ISDIR(st.st_mode)) {
|
||||
failed = 1;
|
||||
unsuccesful = 1;
|
||||
|
||||
fprintf(stdlog, "dir_error:%s:%s: Dir error for not directory\n", disk->name, dir->sub);
|
||||
++error;
|
||||
}
|
||||
|
||||
if (fix && failed) {
|
||||
if (fix && unsuccesful) {
|
||||
/* create the ancestor directories */
|
||||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
|
|
|
|||
13
configure.ac
13
configure.ac
|
|
@ -148,6 +148,19 @@ AC_ARG_ENABLE([debug],
|
|||
],
|
||||
[])
|
||||
|
||||
AC_ARG_ENABLE([warning],
|
||||
[AS_HELP_STRING([--enable-warning],[enable extra warning])],
|
||||
[
|
||||
AC_CHECK_CC_OPT([-Wpointer-arith], CFLAGS="$CFLAGS -Wpointer-arith", [])
|
||||
AC_CHECK_CC_OPT([-Wcast-qual], CFLAGS="$CFLAGS -Wcast-qual", [])
|
||||
AC_CHECK_CC_OPT([-Wunused], CFLAGS="$CFLAGS -Wunused", [])
|
||||
AC_CHECK_CC_OPT([-Wunreachable-code], CFLAGS="$CFLAGS -Wunreachable-code", [])
|
||||
AC_CHECK_CC_OPT([-Wpadded], CFLAGS="$CFLAGS -Wpadded", [])
|
||||
AC_CHECK_CC_OPT([-Wshadow], CFLAGS="$CFLAGS -Wshadow", [])
|
||||
AC_CHECK_CC_OPT([-Weverything], CFLAGS="$CFLAGS -Weverything", [])
|
||||
],
|
||||
[])
|
||||
|
||||
AC_ARG_VAR([TESTENV], [Test environment])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
|
|
|||
2
import.c
2
import.c
|
|
@ -45,7 +45,7 @@ int import_block_prevhash_compare(const void* void_arg, const void* void_data)
|
|||
*/
|
||||
static inline tommy_uint32_t import_block_hash(const unsigned char* hash)
|
||||
{
|
||||
return *(tommy_uint32_t*)hash;
|
||||
return *(const tommy_uint32_t*)hash;
|
||||
}
|
||||
|
||||
static void import_file(struct snapraid_state* state, const char* path, uint64_t size)
|
||||
|
|
|
|||
|
|
@ -82,10 +82,10 @@ void MurmurHash3_x86_128(const void* key, unsigned len, const uint8_t* seed, voi
|
|||
unsigned i;
|
||||
const uint32_t* blocks;
|
||||
|
||||
uint32_t h1 = ((uint32_t*)seed)[0];
|
||||
uint32_t h2 = ((uint32_t*)seed)[1];
|
||||
uint32_t h3 = ((uint32_t*)seed)[2];
|
||||
uint32_t h4 = ((uint32_t*)seed)[3];
|
||||
uint32_t h1 = ((const uint32_t*)seed)[0];
|
||||
uint32_t h2 = ((const uint32_t*)seed)[1];
|
||||
uint32_t h3 = ((const uint32_t*)seed)[2];
|
||||
uint32_t h4 = ((const uint32_t*)seed)[3];
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
h1 = util_swap32(h1);
|
||||
|
|
|
|||
4
scan.c
4
scan.c
|
|
@ -874,7 +874,7 @@ struct dirent_sorted {
|
|||
#if HAVE_STRUCT_DIRENT_D_STAT
|
||||
struct stat d_stat; /**< Stat result. */
|
||||
#endif
|
||||
char d_name[1]; /**< Variable length name. It must be the last field. */
|
||||
char d_name[]; /**< Variable length name. It must be the last field. */
|
||||
};
|
||||
|
||||
#if HAVE_STRUCT_DIRENT_D_INO
|
||||
|
|
@ -995,7 +995,7 @@ static int scan_dir(struct snapraid_scan* scan, int output, const char* dir, con
|
|||
}
|
||||
|
||||
name_len = strlen(dd->d_name);
|
||||
entry = malloc_nofail(sizeof(struct dirent_sorted) + name_len);
|
||||
entry = malloc_nofail(sizeof(struct dirent_sorted) + name_len + 1);
|
||||
|
||||
/* copy the dir entry */
|
||||
#if HAVE_STRUCT_DIRENT_D_INO
|
||||
|
|
|
|||
1
scrub.c
1
scrub.c
|
|
@ -134,7 +134,6 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
int error_on_this_block;
|
||||
int silent_error_on_this_block;
|
||||
int block_is_unsynced;
|
||||
int ret;
|
||||
int rehash;
|
||||
|
||||
/* if it's unused */
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ void SpookyHash128(const void* message, size_t length, const uint8_t* seed, uint
|
|||
unsigned i;
|
||||
#endif
|
||||
|
||||
h9 = ((uint64_t*)seed)[0];
|
||||
h10 = ((uint64_t*)seed)[1];
|
||||
h9 = ((const uint64_t*)seed)[0];
|
||||
h10 = ((const uint64_t*)seed)[1];
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
h9 = util_swap64(h9);
|
||||
|
|
|
|||
35
state.c
35
state.c
|
|
@ -452,20 +452,20 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
) {
|
||||
char device[PATH_MAX];
|
||||
char* slash;
|
||||
unsigned l;
|
||||
unsigned level;
|
||||
|
||||
switch (tag[0]) {
|
||||
case 'p' : l = 0; break;
|
||||
case 'q' : l = 1; break;
|
||||
case 'r' : l = 2; break;
|
||||
case '1' : l = 0; break;
|
||||
case '2' : l = 1; break;
|
||||
case '3' : l = 2; break;
|
||||
case '4' : l = 3; break;
|
||||
case '5' : l = 4; break;
|
||||
case '6' : l = 5; break;
|
||||
case 'p' : level = 0; break;
|
||||
case 'q' : level = 1; break;
|
||||
case 'r' : level = 2; break;
|
||||
case '1' : level = 0; break;
|
||||
case '2' : level = 1; break;
|
||||
case '3' : level = 2; break;
|
||||
case '4' : level = 3; break;
|
||||
case '5' : level = 4; break;
|
||||
case '6' : level = 5; break;
|
||||
case 'z' :
|
||||
l = 2;
|
||||
level = 2;
|
||||
state->raid_mode = RAID_MODE_VANDERMONDE;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -475,7 +475,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (*state->parity_path[l]) {
|
||||
if (*state->parity_path[level]) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Multiple '%s' specification in '%s' at line %u\n", tag, path, line);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -497,7 +497,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
pathimport(state->parity_path[l], sizeof(state->parity_path[l]), buffer);
|
||||
pathimport(state->parity_path[level], sizeof(state->parity_path[level]), buffer);
|
||||
|
||||
if (state->opt.skip_parity_access) {
|
||||
struct stat st;
|
||||
|
|
@ -516,15 +516,15 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
state->parity_device[l] = st.st_dev;
|
||||
state->parity_device[level] = st.st_dev;
|
||||
} else {
|
||||
/* if parity is skipped, uses a fake device */
|
||||
state->parity_device[l] = -1LL - l;
|
||||
state->parity_device[level] = -1LL - level;
|
||||
}
|
||||
|
||||
/* adjust the level */
|
||||
if (state->level < l + 1)
|
||||
state->level = l + 1;
|
||||
if (state->level < level + 1)
|
||||
state->level = level + 1;
|
||||
} else if (strcmp(tag, "share") == 0) {
|
||||
if (*state->share) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -2615,7 +2615,6 @@ static void state_read_binary(struct snapraid_state* state, const char* path, ST
|
|||
}
|
||||
|
||||
while (1) {
|
||||
char buffer[PATH_MAX];
|
||||
int c;
|
||||
|
||||
/* read the command */
|
||||
|
|
|
|||
1
sync.c
1
sync.c
|
|
@ -412,7 +412,6 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
int silent_error_on_this_block;
|
||||
int fixed_error_on_this_block;
|
||||
int parity_needs_to_be_updated;
|
||||
int ret;
|
||||
snapraid_info info;
|
||||
int rehash;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ tommy_inline tommy_uint32_t tommy_le_uint32_read(const void* ptr)
|
|||
/* allow unaligned read on Intel x86 and x86_64 platforms */
|
||||
#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__x86_64__) || defined(_M_X64)
|
||||
/* defines from http://predef.sourceforge.net/ */
|
||||
return *(tommy_uint32_t*)ptr;
|
||||
return *(const tommy_uint32_t*)ptr;
|
||||
#else
|
||||
const unsigned char* ptr8 = tommy_cast(const unsigned char*, ptr);
|
||||
return ptr8[0] + ((tommy_uint32_t)ptr8[1] << 8) + ((tommy_uint32_t)ptr8[2] << 16) + ((tommy_uint32_t)ptr8[3] << 24);
|
||||
|
|
|
|||
4
util.c
4
util.c
|
|
@ -1198,14 +1198,14 @@ uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size)
|
|||
#ifdef CONFIG_X86_64
|
||||
crc64 = crc;
|
||||
while (size >= 8) {
|
||||
asm volatile ("crc32q %1, %0\n" : "+r" (crc64) : "rm" (*(uint64_t*)ptr));
|
||||
asm volatile ("crc32q %1, %0\n" : "+r" (crc64) : "rm" (*(const uint64_t*)ptr));
|
||||
ptr += 8;
|
||||
size -= 8;
|
||||
}
|
||||
crc = crc64;
|
||||
#else
|
||||
while (size >= 4) {
|
||||
asm volatile ("crc32l %1, %0\n" : "+r" (crc) : "rm" (*(uint32_t*)ptr));
|
||||
asm volatile ("crc32l %1, %0\n" : "+r" (crc) : "rm" (*(const uint32_t*)ptr));
|
||||
ptr += 4;
|
||||
size -= 4;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue