mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Source code beautification
Done with uncrustify.
This commit is contained in:
parent
be84bbffe4
commit
36a4d24333
14 changed files with 51 additions and 45 deletions
|
|
@ -189,7 +189,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
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;
|
||||
|
|
@ -1077,7 +1077,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (handle[j].st.st_size != file->size
|
||||
|| handle[j].st.st_mtime != file->mtime_sec
|
||||
|| STAT_NSEC(&handle[j].st) != file->mtime_nsec
|
||||
/* don't check the inode to support file-system without persistent inodes */
|
||||
/* don't check the inode to support file-system without persistent inodes */
|
||||
) {
|
||||
/* report that the file is not synced */
|
||||
file_flag_set(file, FILE_IS_UNSYNCED);
|
||||
|
|
@ -1340,9 +1340,9 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
for (l = 0; l < state->level; ++l) {
|
||||
/* if the parity on disk is wrong */
|
||||
if (buffer_recov[l] == 0
|
||||
/* and we have access at the parity */
|
||||
/* and we have access at the parity */
|
||||
&& parity[l] != 0
|
||||
/* and the parity is not excluded */
|
||||
/* and the parity is not excluded */
|
||||
&& !state->parity[l].is_excluded
|
||||
) {
|
||||
ret = parity_write(parity[l], i, buffer[diskmax + l], state->block_size);
|
||||
|
|
|
|||
|
|
@ -843,7 +843,7 @@ static int devtest(tommy_list* low, int operation)
|
|||
switch (c) {
|
||||
case 0 : entry->smart[j] = 0; break;
|
||||
case 1 : entry->smart[j] = SMART_UNASSIGNED; break;
|
||||
default:
|
||||
default :
|
||||
if (j == 193)
|
||||
entry->smart[j] = c - 2;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
|
|||
state_progress_begin(state, blockstart, blockmax, countmax);
|
||||
while (1) {
|
||||
void** buffer;
|
||||
|
||||
|
||||
/* go to the next block */
|
||||
blockcur = io_read_next(&io, &buffer);
|
||||
if (blockcur >= blockmax)
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ void filter_free(struct snapraid_filter* filter)
|
|||
const char* filter_type(struct snapraid_filter* filter, char* out, size_t out_size)
|
||||
{
|
||||
const char* direction;
|
||||
|
||||
if (filter->direction < 0)
|
||||
direction = "exclude";
|
||||
else
|
||||
|
|
@ -1413,3 +1414,4 @@ int time_compare(const void* void_a, const void* void_b)
|
|||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ void os_abort(void)
|
|||
/* get stackstrace, but without symbols */
|
||||
size = CaptureStackBackTrace(0, 32, stack, NULL);
|
||||
|
||||
for (i=0; i<size; ++i)
|
||||
for (i = 0; i < size; ++i)
|
||||
printf("[bt] %02u: %p\n", i, stack[i]);
|
||||
|
||||
printf("Please report this error to the SnapRAID Forum:\n");
|
||||
|
|
@ -1853,8 +1853,8 @@ static int devresolve(const char* mount, char* file, size_t file_size, char* wfi
|
|||
i = 0;
|
||||
while (volume_guid[i] != 0)
|
||||
++i;
|
||||
if (i != 0 && volume_guid[i-1] == '\\')
|
||||
volume_guid[i-1] = 0;
|
||||
if (i != 0 && volume_guid[i - 1] == '\\')
|
||||
volume_guid[i - 1] = 0;
|
||||
|
||||
pathcpy(wfile, wfile_size, u16tou8(conv_buf_volume_guid, volume_guid));
|
||||
|
||||
|
|
@ -2245,7 +2245,7 @@ static int devup(const char* mount)
|
|||
pathprint(path, sizeof(path), "%s.snapraid-spinup.tmp", mount);
|
||||
|
||||
/* create a temporary file, automatically deleted on close */
|
||||
f = _wopen(convert(conv_buf, path), _O_CREAT | _O_TEMPORARY | _O_RDWR, _S_IREAD | _S_IWRITE);
|
||||
f = _wopen(convert(conv_buf, path), _O_CREAT | _O_TEMPORARY | _O_RDWR, _S_IREAD | _S_IWRITE);
|
||||
if (f != -1)
|
||||
close(f);
|
||||
|
||||
|
|
@ -2538,3 +2538,4 @@ int windows_cond_wait(windows_cond_t* cond, windows_mutex_t* mutex)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ void test(void)
|
|||
crc32c_init();
|
||||
|
||||
s = sopen_multi_write(STREAM_MAX);
|
||||
for (i = 0;i < STREAM_MAX; ++i) {
|
||||
snprintf(file, sizeof(file), "stream%u.bin", i);
|
||||
for (i = 0; i < STREAM_MAX; ++i) {
|
||||
snprintf(file, sizeof(file), "stream%u.bin", i);
|
||||
if (sopen_multi_file(s, i, file) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -48,7 +48,7 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=0;j<256;++j) {
|
||||
for (j = 0; j < 256; ++j) {
|
||||
if (sputc(j, s) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -56,7 +56,7 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=0;j<32;++j) {
|
||||
for (j = 0; j < 32; ++j) {
|
||||
if (sputb32(u32 >> j, s) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -64,7 +64,7 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=0;j<64;++j) {
|
||||
for (j = 0; j < 64; ++j) {
|
||||
if (sputb64(u64 >> j, s) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -72,7 +72,7 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=0;j<BUFFER_MAX;++j) {
|
||||
for (j = 0; j < BUFFER_MAX; ++j) {
|
||||
memset(buffer, j, j);
|
||||
if (swrite(buffer, j, s) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -81,9 +81,9 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=1;j<STR_MAX;++j) {
|
||||
memset(str, ' ' + j, j-1);
|
||||
str[j-1] = 0;
|
||||
for (j = 1; j < STR_MAX; ++j) {
|
||||
memset(str, ' ' + j, j - 1);
|
||||
str[j - 1] = 0;
|
||||
if (sputbs(str, s) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -115,7 +115,7 @@ void test(void)
|
|||
for (i = 0; i < STREAM_MAX; ++i) {
|
||||
uint32_t get_crc_stored;
|
||||
uint32_t get_crc_computed;
|
||||
snprintf(file, sizeof(file), "stream%u.bin", i);
|
||||
snprintf(file, sizeof(file), "stream%u.bin", i);
|
||||
|
||||
s = sopen_read(file);
|
||||
if (s == 0) {
|
||||
|
|
@ -124,7 +124,7 @@ void test(void)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
for(j=0;j<256;++j) {
|
||||
for (j = 0; j < 256; ++j) {
|
||||
int c = sgetc(s);
|
||||
if (c == EOF || (unsigned char)c != j) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -133,7 +133,7 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=0;j<32;++j) {
|
||||
for (j = 0; j < 32; ++j) {
|
||||
uint32_t v32;
|
||||
if (sgetb32(s, &v32) != 0 || v32 != (u32 >> j)) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -142,7 +142,7 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=0;j<64;++j) {
|
||||
for (j = 0; j < 64; ++j) {
|
||||
uint64_t v64;
|
||||
if (sgetb64(s, &v64) != 0 || v64 != (u64 >> j)) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -151,7 +151,7 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=1;j<BUFFER_MAX;++j) {
|
||||
for (j = 1; j < BUFFER_MAX; ++j) {
|
||||
char copy[BUFFER_MAX];
|
||||
memset(buffer, j, j);
|
||||
if (sread(s, copy, j) != 0 || memcmp(copy, buffer, j) != 0) {
|
||||
|
|
@ -161,10 +161,10 @@ void test(void)
|
|||
}
|
||||
}
|
||||
|
||||
for(j=1;j<STR_MAX;++j) {
|
||||
for (j = 1; j < STR_MAX; ++j) {
|
||||
char copy[STR_MAX];
|
||||
memset(str, ' ' + j, j-1);
|
||||
str[j-1] = 0;
|
||||
memset(str, ' ' + j, j - 1);
|
||||
str[j - 1] = 0;
|
||||
if (sgetbs(s, copy, sizeof(copy)) != 0 || strcmp(copy, str) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -204,7 +204,7 @@ void test(void)
|
|||
uint32_t get_crc_stored;
|
||||
uint32_t get_crc_computed;
|
||||
unsigned char buf[4];
|
||||
snprintf(file, sizeof(file), "stream%u.bin", i);
|
||||
snprintf(file, sizeof(file), "stream%u.bin", i);
|
||||
|
||||
s = sopen_read(file);
|
||||
if (s == 0) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ static void scrub_data_reader(struct snapraid_worker* worker, struct snapraid_ta
|
|||
if (handle->st.st_size != task->file->size
|
||||
|| handle->st.st_mtime != task->file->mtime_sec
|
||||
|| STAT_NSEC(&handle->st) != task->file->mtime_nsec
|
||||
/* don't check the inode to support filesystem without persistent inodes */
|
||||
/* don't check the inode to support filesystem without persistent inodes */
|
||||
) {
|
||||
/* report that the block and the file are not synced */
|
||||
task->is_timestamp_different = 1;
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ static void test_tommy(void)
|
|||
tommy_list list;
|
||||
tommy_hashdyn hashdyn;
|
||||
tommy_tree tree;
|
||||
tommy_node node[TOMMY_SIZE+1];
|
||||
tommy_node node[TOMMY_SIZE + 1];
|
||||
unsigned i;
|
||||
|
||||
tommy_array_init(&array);
|
||||
|
|
@ -436,7 +436,7 @@ static void test_tommy(void)
|
|||
tommy_tree_init(&tree, tommy_test_compare);
|
||||
|
||||
for (i = 0; i < TOMMY_SIZE; ++i)
|
||||
tommy_tree_insert(&tree, &node[i], (void*)(uintptr_t)(i+1));
|
||||
tommy_tree_insert(&tree, &node[i], (void*)(uintptr_t)(i + 1));
|
||||
|
||||
/* try to insert a duplicate, count should not change */
|
||||
if (tommy_tree_insert(&tree, &node[TOMMY_SIZE], (void*)1) != (void*)1) {
|
||||
|
|
@ -495,7 +495,7 @@ static void test_tommy(void)
|
|||
tommy_tree_remove_existing(&tree, &node[i]);
|
||||
|
||||
for (i = 0; i < TOMMY_SIZE / 2; ++i) {
|
||||
if (tommy_tree_remove(&tree, (void*)(uintptr_t)(i+1)) != 0) {
|
||||
if (tommy_tree_remove(&tree, (void*)(uintptr_t)(i + 1)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -503,7 +503,7 @@ static void test_tommy(void)
|
|||
}
|
||||
|
||||
for (i = TOMMY_SIZE / 2; i < TOMMY_SIZE; ++i) {
|
||||
if (tommy_tree_remove(&tree, (void*)(uintptr_t)(i+1)) == 0) {
|
||||
if (tommy_tree_remove(&tree, (void*)(uintptr_t)(i + 1)) == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t*
|
|||
const uint64_t* blocks;
|
||||
const uint64_t* end;
|
||||
size_t size_remainder;
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
unsigned i;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2894,7 +2894,7 @@ static void* state_write_thread(void* arg)
|
|||
while (end < file->blockmax) {
|
||||
if (v_state != block_state_get(fs_file2block_get(file, end)))
|
||||
break;
|
||||
if (v_pos + (end - begin) != fs_file2par_get(disk,file, end))
|
||||
if (v_pos + (end - begin) != fs_file2par_get(disk, file, end))
|
||||
break;
|
||||
++end;
|
||||
}
|
||||
|
|
@ -3996,7 +3996,7 @@ static void state_progress_latest(struct snapraid_state* state)
|
|||
/**
|
||||
* Get the reference value, 0 if index is PROGRESS_MAX
|
||||
*/
|
||||
#define ref(map,index) (index < PROGRESS_MAX ? map[index] : 0)
|
||||
#define ref(map, index) (index < PROGRESS_MAX ? map[index] : 0)
|
||||
|
||||
static void state_progress_graph(struct snapraid_state* state, struct snapraid_io* io, unsigned current, unsigned oldest)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ const char* quote(char prefix, const char* str, char* buffer)
|
|||
*p++ = c;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
default :
|
||||
/* unquoted */
|
||||
if (p == end)
|
||||
goto bail;
|
||||
|
|
@ -536,7 +536,7 @@ const char* quote(char prefix, const char* str, char* buffer)
|
|||
goto bail;
|
||||
*p++ = c;
|
||||
break;
|
||||
default:
|
||||
default :
|
||||
/* all the others are quoted with \ */
|
||||
if (p == end)
|
||||
goto bail;
|
||||
|
|
@ -716,6 +716,7 @@ void pathslash(char* dst, size_t size)
|
|||
void pathcut(char* dst)
|
||||
{
|
||||
char* slash = strrchr(dst, '/');
|
||||
|
||||
if (slash)
|
||||
slash[1] = 0;
|
||||
else
|
||||
|
|
@ -887,6 +888,7 @@ void malloc_counter_inc(size_t inc)
|
|||
static ssize_t malloc_print(int f, const char* str)
|
||||
{
|
||||
ssize_t len = 0;
|
||||
|
||||
while (str[len])
|
||||
++len;
|
||||
return write(f, str, len);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ void printp(double v, size_t pad);
|
|||
/****************************************************************************/
|
||||
/* escape */
|
||||
|
||||
#define ESC_MAX (PATH_MAX*2+1)
|
||||
#define ESC_MAX (PATH_MAX*2 + 1)
|
||||
|
||||
/**
|
||||
* Escape a string for the log.
|
||||
|
|
@ -224,7 +224,7 @@ void printp(double v, size_t pad);
|
|||
*/
|
||||
const char* esc(const char* str, char* buffer);
|
||||
|
||||
#define QUOTE_MAX (PATH_MAX*2+1)
|
||||
#define QUOTE_MAX (PATH_MAX*2 + 1)
|
||||
|
||||
/**
|
||||
* Quote a string for the shell.
|
||||
|
|
|
|||
|
|
@ -387,11 +387,11 @@ int fsinfo(const char* path, int* has_persistent_inode, uint64_t* total_space, u
|
|||
case 0x517B : ptype = "smb"; break; /* remote */
|
||||
case 0x5346544E : ptype = "ntfs"; break;
|
||||
case 0x52654973 : ptype = "reiserfs"; break;
|
||||
case 0x3153464A : ptype = "jfs" ; break;
|
||||
case 0x3153464A : ptype = "jfs"; break;
|
||||
case 0x58465342 : ptype = "xfs"; break;
|
||||
case 0x9123683E : ptype = "btrfs"; break;
|
||||
case 0x2FC12FC1 : ptype = "zfs"; break;
|
||||
default:
|
||||
default :
|
||||
snprintf(type, sizeof(type), "0x%X", (unsigned)st.f_type);
|
||||
ptype = type;
|
||||
}
|
||||
|
|
@ -517,7 +517,7 @@ static dev_t devread(const char* path)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
mi = strtoul(e+1, &e, 10);
|
||||
mi = strtoul(e + 1, &e, 10);
|
||||
if (*e != 0 && !isspace(*e)) {
|
||||
/* LCOV_EXCL_START */
|
||||
close(f);
|
||||
|
|
@ -1194,7 +1194,7 @@ void os_abort(void)
|
|||
|
||||
messages = backtrace_symbols(stack, size);
|
||||
|
||||
for (i=1; i<size; ++i) {
|
||||
for (i = 1; i < size; ++i) {
|
||||
const char* msg;
|
||||
|
||||
if (messages)
|
||||
|
|
|
|||
|
|
@ -87,11 +87,11 @@ static int fast_mtest_vector(int n, size_t size, void** vv)
|
|||
|
||||
/* copy to the next */
|
||||
for (j = 1; j < n; ++j)
|
||||
memcpy(vv[j], vv[j-1], size);
|
||||
memcpy(vv[j], vv[j - 1], size);
|
||||
|
||||
/* compare with the previous */
|
||||
for (j = 1; j <= n; ++j)
|
||||
if (memcmp(vv[j % n], vv[j-1], size) != 0)
|
||||
if (memcmp(vv[j % n], vv[j - 1], size) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue