diff --git a/cmdline/check.c b/cmdline/check.c index d5f52c44..7d2fe25c 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -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); diff --git a/cmdline/device.c b/cmdline/device.c index bb04089b..c5e211a6 100644 --- a/cmdline/device.c +++ b/cmdline/device.c @@ -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 diff --git a/cmdline/dry.c b/cmdline/dry.c index 521703ce..0864ffb4 100644 --- a/cmdline/dry.c +++ b/cmdline/dry.c @@ -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) diff --git a/cmdline/elem.c b/cmdline/elem.c index 1735cb6a..0e82f214 100644 --- a/cmdline/elem.c +++ b/cmdline/elem.c @@ -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; } + diff --git a/cmdline/mingw.c b/cmdline/mingw.c index 2b499738..e7c5b804 100644 --- a/cmdline/mingw.c +++ b/cmdline/mingw.c @@ -175,7 +175,7 @@ void os_abort(void) /* get stackstrace, but without symbols */ size = CaptureStackBackTrace(0, 32, stack, NULL); - for (i=0; i> 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> 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;jst.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; diff --git a/cmdline/selftest.c b/cmdline/selftest.c index 8785c0fe..f0ac9441 100644 --- a/cmdline/selftest.c +++ b/cmdline/selftest.c @@ -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 */ diff --git a/cmdline/spooky2.c b/cmdline/spooky2.c index 3658d2fd..339bc4d0 100644 --- a/cmdline/spooky2.c +++ b/cmdline/spooky2.c @@ -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 diff --git a/cmdline/state.c b/cmdline/state.c index 640e2f12..5f43d62f 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -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) { diff --git a/cmdline/support.c b/cmdline/support.c index 431c0b3f..a31c81fa 100644 --- a/cmdline/support.c +++ b/cmdline/support.c @@ -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); diff --git a/cmdline/support.h b/cmdline/support.h index 20e5a227..0ca4dbf2 100644 --- a/cmdline/support.h +++ b/cmdline/support.h @@ -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. diff --git a/cmdline/unix.c b/cmdline/unix.c index 60b0ffc2..bd194b46 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -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