Update beautification with uncrustify

This commit is contained in:
Andrea Mazzoleni 2026-01-18 11:03:07 +01:00
parent e80734fc4c
commit b29500c25f
10 changed files with 2996 additions and 1205 deletions

View file

@ -372,7 +372,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
if ((block_state == BLOCK_STATE_BLK || block_state == BLOCK_STATE_REP)
/* try to fetch the block using the known hash */
&& (state_import_fetch(state, rehash, failed[j].block, buffer[failed[j].index]) == 0
|| state_search_fetch(state, rehash, failed[j].file, failed[j].file_pos, failed[j].block, buffer[failed[j].index]) == 0)
|| state_search_fetch(state, rehash, failed[j].file, failed[j].file_pos, failed[j].block, buffer[failed[j].index]) == 0)
) {
/* we already have corrected it! */
log_tag("hash_import: Fixed entry %u\n", j);

View file

@ -38,8 +38,9 @@ static int needs_quote(const WCHAR* arg)
#define charcat(c) \
do { \
if (pos + 1 >= size) \
if (pos + 1 >= size) { \
return -1; \
} \
cmd[pos++] = (c); \
} while (0)

View file

@ -56,13 +56,13 @@ int exit_sync_needed = 2;
* Direct access to RtlGenRandom().
* This function is accessible only with LoadLibrary() and it's available from Windows XP.
*/
static BOOLEAN (WINAPI* ptr_RtlGenRandom)(PVOID, ULONG);
static BOOLEAN(WINAPI * ptr_RtlGenRandom)(PVOID, ULONG);
/**
* Direct access to GetTickCount64().
* This function is available only from Windows Vista.
*/
static ULONGLONG (WINAPI* ptr_GetTickCount64)(void);
static ULONGLONG(WINAPI * ptr_GetTickCount64)(void);
/**
* Description of the last error.
@ -1840,8 +1840,8 @@ int windows_readlink(const char* file, char* buffer, size_t size)
/* convert the name to UTF-8 */
name = u16tou8ex(conv_buf_name,
rdb->SymbolicLinkReparseBuffer.PathBuffer + rdb->SymbolicLinkReparseBuffer.PrintNameOffset,
rdb->SymbolicLinkReparseBuffer.PrintNameLength / 2, &len);
rdb->SymbolicLinkReparseBuffer.PathBuffer + rdb->SymbolicLinkReparseBuffer.PrintNameOffset,
rdb->SymbolicLinkReparseBuffer.PrintNameLength / 2, &len);
/* check for overflow */
if (len > size) {

View file

@ -621,11 +621,13 @@ void config(char* conf, size_t conf_size, const char* argv0)
#ifdef SYSCONFDIR
/* if it exists, give precedence at sysconfdir, usually /usr/local/etc */
if (access(SYSCONFDIR "/" PACKAGE ".conf", F_OK) == 0)
if (access(SYSCONFDIR "/" PACKAGE ".conf", F_OK) == 0) {
pathcpy(conf, conf_size, SYSCONFDIR "/" PACKAGE ".conf");
else /* otherwise fallback to plain /etc */
} else /* otherwise fallback to plain /etc */
#endif
{
pathcpy(conf, conf_size, "/etc/" PACKAGE ".conf");
}
#endif
}

View file

@ -50,12 +50,14 @@ static int64_t diffgettimeofday(struct timeval *start, struct timeval *stop)
/**
* Stop time measurement.
*/
/* INDENT-OFF */
#define SPEED_STOP \
count += delta; \
gettimeofday(&stop, 0); \
} while (diffgettimeofday(&start, &stop) < period * 1000LL) ; \
count += delta; \
gettimeofday(&stop, 0); \
} while (diffgettimeofday(&start, &stop) < period * 1000LL); \
ds = size * (int64_t)count * nd; \
dt = diffgettimeofday(&start, &stop);
/* INDENT-ON */
/**
* Global variable used to propagate side effects.

View file

@ -129,7 +129,7 @@ uint64_t random_u64(void)
z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9ULL;
z = (z ^ (z >> 27)) * 0x94D049BB133111EBULL;
return z ^ (z >> 31);
}
@ -509,8 +509,9 @@ void printp(double v, size_t pad)
#define charcat(c) \
do { \
if (p == end) \
if (p == end) { \
goto bail; \
} \
*p++ = (c); \
} while (0)
@ -1746,7 +1747,7 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, uint64_t* sm
if (*s == 0) {
inside = 0;
/* common */
/* common */
} else if (smatch(s, "Rotation Rate: Solid State") == 0) {
info[INFO_ROTATION_RATE] = 0;
} else if (sscanf(s, "Rotation Rate: %" SCNu64, &info[INFO_ROTATION_RATE]) == 1) {
@ -1765,7 +1766,7 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, uint64_t* sm
}
} else if (sscanf(s, "Model Family: %63[^\n]", family) == 1) {
} else if (sscanf(s, "Device Model: %63[^\n]", model) == 1) {
/* SCSI */
/* SCSI */
} else if (sscanf(s, "Serial number: %63s", serial) == 1) { /* note "n" of "number" lower case */
} else if (sscanf(s, "Elements in grown defect list: %" SCNu64, &smart[SMART_REALLOCATED_SECTOR_COUNT]) == 1) {
} else if (sscanf(s, "Current Drive Temperature: %" SCNu64, &smart[SMART_TEMPERATURE_CELSIUS]) == 1) {
@ -1773,7 +1774,7 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, uint64_t* sm
} else if (sscanf(s, "Accumulated start-stop cycles: %" SCNu64, &smart[SMART_START_STOP_COUNT]) == 1) {
} else if (sscanf(s, "Accumulated load-unload cycles: %" SCNu64, &smart[SMART_LOAD_CYCLE_COUNT]) == 1) {
} else if (sscanf(s, " number of hours powered up = %" SCNu64, &smart[SMART_POWER_ON_HOURS]) == 1) {
/* ATA */
/* ATA */
} else if (sscanf(s, "Serial Number: %63s", serial) == 1) {
} else if (smatch(s, "ID#") == 0) {
inside = 1;
@ -2014,7 +2015,7 @@ void thread_yield(void)
/* wnmatch */
/**
* Helper function for case-insensitive character comparison
* Helper function for case-insensitive character comparison
*/
static inline int char_match(char p, char t)
{
@ -2102,7 +2103,7 @@ int wnmatch(const char* p, const char* t)
/*
* In between slashes matches to nothing
*
*
* Check for /##/ or ^##/ (^ start of string)
*
* This is required for:
@ -2110,7 +2111,7 @@ int wnmatch(const char* p, const char* t)
* "##/file.txt" matching "file.txt"
* "x##/file.txt" NOT matching "xfile.txt"
*/
if (*p == '/' && (p1 == 0 || p1 == '/')) {
if (*p == '/' && (p1 == 0 || p1 == '/')) {
/* try reducing to nothing */
if (wnmatch(p + 1, t) == 0)
return 0;
@ -2159,7 +2160,7 @@ int wnmatch(const char* p, const char* t)
++t;
break;
default:
default :
/* literal character */
if (*t == 0 || !char_match(*p, *t))
return 1;
@ -2173,3 +2174,4 @@ int wnmatch(const char* p, const char* t)
/* match successful if we've consumed all text */
return *t != 0;
}

View file

@ -57,7 +57,7 @@ void unlock_memory(void);
/**
* Reseed the random pseudo random number generator
*/
*/
void random_reseed(void);
/**
@ -490,9 +490,9 @@ void thread_yield(void);
/****************************************************************************/
/* match */
/*
/*
* Wild match function.
*
*
* - ? matches any single character except /
* - * matches any sequence of characters except /
* - ** (nearby a /) matches everything including /
@ -503,3 +503,4 @@ void thread_yield(void);
int wnmatch(const char* p, const char* t);
#endif

View file

@ -1288,7 +1288,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* LCOV_EXCL_START */
++io_error;
goto bail;
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_STOP */
case TASK_STATE_ERROR :
/* LCOV_EXCL_START */
++error;
@ -1450,7 +1450,7 @@ bail:
log_fatal("WARNING! Unexpected close error in a data disk.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle[j].path);
++error;
}
}
++error;
/* continue, as we are already exiting */
/* LCOV_EXCL_STOP */

View file

@ -709,7 +709,7 @@ const char* memhashname(unsigned kind)
case HASH_METRO : return "metro";
case HASH_MUSEAIR : return "museair";
}
return 0;
}

File diff suppressed because it is too large Load diff