From 713a8138c0db83a46e115293983029865a263aca Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Fri, 3 Nov 2017 23:46:45 +0100 Subject: [PATCH] Minor formatting changes --- cmdline/check.c | 4 ++-- cmdline/parity.c | 26 +++++++++++++------------- cmdline/scan.c | 2 +- cmdline/scrub.c | 8 ++++---- cmdline/state.c | 6 +++--- cmdline/sync.c | 4 ++-- cmdline/util.h | 8 ++++---- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cmdline/check.c b/cmdline/check.c index 4fc21391..72012df6 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -1191,7 +1191,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna failed[failed_count].handle = &handle[j]; ++failed_count; - log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u/%u\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff, BLOCK_HASH_SIZE*8); + log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u/%u\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff, BLOCK_HASH_SIZE * 8); ++error; continue; } @@ -1297,7 +1297,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna /* mark that the read parity is wrong, setting ptr to 0 */ buffer_recov[l] = 0; - log_tag("parity_error:%u:%s: Data error, diff bits %u/%u\n", i, lev_config_name(l), diff, state->block_size*8); + log_tag("parity_error:%u:%s: Data error, diff bits %u/%u\n", i, lev_config_name(l), diff, state->block_size * 8); ++error; } } diff --git a/cmdline/parity.c b/cmdline/parity.c index 5b38acbc..e4fefc6f 100644 --- a/cmdline/parity.c +++ b/cmdline/parity.c @@ -26,7 +26,7 @@ /** * Pseudo random limits for parity */ -#define PARITY_LIMIT(size,split,level) \ +#define PARITY_LIMIT(size, split, level) \ size ? size + (123562341 + split * 634542351 + level * 983491341) % size : 0 /****************************************************************************/ @@ -165,7 +165,7 @@ void parity_size(struct snapraid_parity_handle* handle, data_off_t* out_size) /* now compute the size summing all the parity splits */ size = 0; - for (s = 0;s < handle->split_mac;++s) { + for (s = 0; s < handle->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; size += split->size; @@ -185,7 +185,7 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p handle->level = level; handle->split_mac = 0; - for (s = 0;s < parity->split_mac;++s) { + for (s = 0; s < parity->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; int ret; int flags; @@ -247,7 +247,7 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p bail: /* LCOV_EXCL_START */ - for (s = 0;s < handle->split_mac;++s) { + for (s = 0; s < handle->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; close(split->f); split->f = -1; @@ -311,7 +311,7 @@ static int parity_handle_grow(struct snapraid_split_handle* split, data_off_t si * * See: man fallocate * ENOSYS - This kernel does not implement fallocate(). - * EOPNOTSUPP - The file system containing the file referred to by fd does not support this operation + * EOPNOTSUPP - The file system containing the file referred to by fd does not support this operation */ if (ret != 0 && (errno == EOPNOTSUPP || errno == ENOSYS)) { /* fallback using ftruncate() */ @@ -536,7 +536,7 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity* /* LCOV_EXCL_STOP */ } - for (s = 0;s < handle->split_mac;++s) { + for (s = 0; s < handle->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; int is_fixed = parity_split_is_fixed(handle, s); data_off_t run; @@ -564,7 +564,7 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity* /* otherwise tries to allocate all the needed remaining size */ run = size; } - + ret = parity_handle_chsize(split, run, block_size, skip_fallocate, skip_space_holder); if (ret != 0) { /* LCOV_EXCL_START */ @@ -613,7 +613,7 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity* if (is_modified) *is_modified = 0; - for (s = 0;s < handle->split_mac;++s) { + for (s = 0; s < handle->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; if (parity->split_map[s].size != split->size) { @@ -637,7 +637,7 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par /* mask of bits used by the block size */ block_mask = ((data_off_t)block_size) - 1; - for (s = 0;s < parity->split_mac;++s) { + for (s = 0; s < parity->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; int ret; int flags; @@ -701,7 +701,7 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par bail: /* LCOV_EXCL_START */ - for (s = 0;s < handle->split_mac;++s) { + for (s = 0; s < handle->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; close(split->f); split->f = -1; @@ -715,7 +715,7 @@ int parity_sync(struct snapraid_parity_handle* handle) #if HAVE_FSYNC unsigned s; - for (s = 0;s < handle->split_mac;++s) { + for (s = 0; s < handle->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; int ret; @@ -740,7 +740,7 @@ int parity_close(struct snapraid_parity_handle* handle) unsigned s; int f_ret = 0; - for (s = 0;s < handle->split_mac;++s) { + for (s = 0; s < handle->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; int ret; @@ -771,7 +771,7 @@ struct snapraid_split_handle* parity_split_find(struct snapraid_parity_handle* h if (*offset < 0) return 0; - for (s = 0;s < handle->split_mac;++s) { + for (s = 0; s < handle->split_mac; ++s) { struct snapraid_split_handle* split = &handle->split_map[s]; if (*offset < split->size) diff --git a/cmdline/scan.c b/cmdline/scan.c index d7b86c75..8e70ff3d 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -529,7 +529,7 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc if (st->st_nlink != synced_st.st_nlink) { #ifndef _WIN32 log_fatal("WARNING! Detected uncached nlink change from %u to %u for file '%s'\n", - (uint32_t)st->st_nlink , (uint32_t)synced_st.st_nlink, sub); + (uint32_t)st->st_nlink, (uint32_t)synced_st.st_nlink, sub); log_fatal("It's better if you run SnapRAID without other processes running.\n"); #endif st->st_nlink = synced_st.st_nlink; diff --git a/cmdline/scrub.c b/cmdline/scrub.c index f4499887..b744278f 100644 --- a/cmdline/scrub.c +++ b/cmdline/scrub.c @@ -473,14 +473,14 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) { unsigned diff = memdiff(hash, block->hash, BLOCK_HASH_SIZE); - log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff, BLOCK_HASH_SIZE*8); + log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff, BLOCK_HASH_SIZE * 8); /* it's a silent error only if we are dealing with synced files */ if (file_is_unsynced) { ++error; error_on_this_block = 1; } else { - log_error("Data error in file '%s' at position '%u', diff bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE*8); + log_error("Data error in file '%s' at position '%u', diff bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8); ++silent_error; silent_error_on_this_block = 1; } @@ -566,14 +566,14 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par if (buffer_recov[l] && memcmp(buffer[diskmax + l], buffer_recov[l], state->block_size) != 0) { unsigned diff = memdiff(buffer[diskmax + l], buffer_recov[l], state->block_size); - log_tag("parity_error:%u:%s: Data error, diff bits %u/%u\n", blockcur, lev_config_name(l), diff, state->block_size*8); + log_tag("parity_error:%u:%s: Data error, diff bits %u/%u\n", blockcur, lev_config_name(l), diff, state->block_size * 8); /* it's a silent error only if we are dealing with synced blocks */ if (block_is_unsynced) { ++error; error_on_this_block = 1; } else { - log_fatal("Data error in parity '%s' at position '%u', diff bits %u/%u\n", lev_config_name(l), blockcur, diff, state->block_size*8); + log_fatal("Data error in parity '%s' at position '%u', diff bits %u/%u\n", lev_config_name(l), blockcur, diff, state->block_size * 8); ++silent_error; silent_error_on_this_block = 1; } diff --git a/cmdline/state.c b/cmdline/state.c index fefedaae..7794b59c 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -342,7 +342,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t if (!state->opt.skip_device && !state->opt.skip_parity_access) { for (l = 0; l < state->level; ++l) { for (s = 0; s < state->parity[l].split_mac; ++s) { - unsigned j,t; + unsigned j, t; /* skip parity disks that are not accessible */ if (state->parity[l].skip_access) @@ -657,7 +657,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co BLOCK_HASH_SIZE = hash_size; } else if (lev_config_scan(tag, &level, &state->raid_mode) == 0) { char device[PATH_MAX]; - char* split_map[SPLIT_MAX+1]; + char* split_map[SPLIT_MAX + 1]; unsigned split_mac; char* slash; uint64_t dev; @@ -685,7 +685,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co /* LCOV_EXCL_STOP */ } - split_mac = strsplit(split_map, SPLIT_MAX+1, buffer, ","); + split_mac = strsplit(split_map, SPLIT_MAX + 1, buffer, ","); if (split_mac > SPLIT_MAX) { /* LCOV_EXCL_START */ diff --git a/cmdline/sync.c b/cmdline/sync.c index d1dee226..929d3acd 100644 --- a/cmdline/sync.c +++ b/cmdline/sync.c @@ -964,8 +964,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari continue; } else { /* otherwise it's a BLK with silent error */ unsigned diff = memdiff(hash, block->hash, BLOCK_HASH_SIZE); - log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff, BLOCK_HASH_SIZE*8); - log_error("Data error in file '%s' at position '%u', diff bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE*8); + log_tag("error:%u:%s:%s: Data error at position %u, diff bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff, BLOCK_HASH_SIZE * 8); + log_error("Data error in file '%s' at position '%u', diff bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8); /* save the failed block for the fix */ failed[failed_count].index = diskcur; diff --git a/cmdline/util.h b/cmdline/util.h index f755e9d1..1661a9df 100644 --- a/cmdline/util.h +++ b/cmdline/util.h @@ -86,7 +86,7 @@ static inline uint32_t crc32c_plain_char(uint32_t crc, unsigned char c) { #if HAVE_SSE42 if (tommy_likely(crc_x86)) { - asm("crc32b %1, %0\n" : "+r" (crc) : "m" (c)); + asm ("crc32b %1, %0\n" : "+r" (crc) : "m" (c)); return crc; } #endif @@ -123,20 +123,20 @@ static inline uint32_t crc32c_x86_plain(uint32_t crc, const unsigned char* ptr, #ifdef CONFIG_X86_64 uint64_t crc64 = crc; while (size >= 8) { - asm("crc32q %1, %0\n" : "+r" (crc64) : "m" (*(const uint64_t*)ptr)); + asm ("crc32q %1, %0\n" : "+r" (crc64) : "m" (*(const uint64_t*)ptr)); ptr += 8; size -= 8; } crc = crc64; #else while (size >= 4) { - asm("crc32l %1, %0\n" : "+r" (crc) : "m" (*(const uint32_t*)ptr)); + asm ("crc32l %1, %0\n" : "+r" (crc) : "m" (*(const uint32_t*)ptr)); ptr += 4; size -= 4; } #endif while (size) { - asm("crc32b %1, %0\n" : "+r" (crc) : "m" (*ptr)); + asm ("crc32b %1, %0\n" : "+r" (crc) : "m" (*ptr)); ++ptr; --size; }