Chore: run clang-format

```bash
find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i
```
This commit is contained in:
李通洲
2026-03-29 09:28:49 +08:00
parent cdd4cee968
commit e0eba8ce21
690 changed files with 28093 additions and 30062 deletions
+1 -2
View File
@@ -3,8 +3,7 @@
#include "fastfetch.h"
#include "modules/memory/option.h"
typedef struct FFMemoryResult
{
typedef struct FFMemoryResult {
uint64_t bytesUsed;
uint64_t bytesTotal;
} FFMemoryResult;
+10 -8
View File
@@ -6,22 +6,24 @@
#include <sys/sysctl.h>
#include <unistd.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
const char* ffDetectMemory(FFMemoryResult* ram) {
size_t length = sizeof(ram->bytesTotal);
#if FF_APPLE_MEMSIZE_USABLE
if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, NULL, 0) != 0)
#if FF_APPLE_MEMSIZE_USABLE
if (sysctlbyname("hw.memsize_usable", &ram->bytesTotal, &length, NULL, 0) != 0) {
return "Failed to read hw.memsize_usable";
#else
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0) != 0)
}
#else
if (sysctl((int[]) {CTL_HW, HW_MEMSIZE}, 2, &ram->bytesTotal, &length, NULL, 0) != 0) {
return "Failed to read hw.memsize";
#endif
}
#endif
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
vm_statistics64_data_t vmstat;
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
if (host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS) {
return "Failed to read host_statistics64";
}
// https://github.com/st3fan/osx-10.9/blob/34e34a6a539b5a822cda4074e56a7ced9b57da71/system_cmds-597.1.1/vm_stat.tproj/vm_stat.c#L139
+4 -6
View File
@@ -1,16 +1,14 @@
#include "memory.h"
#include "common/sysctl.h"
const char* ffDetectMemory(FFMemoryResult* ram)
{
const char* ffDetectMemory(FFMemoryResult* ram) {
size_t length = sizeof(ram->bytesTotal);
if (sysctl((int[]){ CTL_HW, HW_PHYSMEM }, 2, &ram->bytesTotal, &length, NULL, 0))
if (sysctl((int[]) {CTL_HW, HW_PHYSMEM}, 2, &ram->bytesTotal, &length, NULL, 0)) {
return "Failed to read hw.physmem";
}
// vm.stats.vm.* are int values
int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0)
+ ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0)
+ ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);
int32_t pagesFree = ffSysctlGetInt("vm.stats.vm.v_free_count", 0) + ffSysctlGetInt("vm.stats.vm.v_inactive_count", 0) + ffSysctlGetInt("vm.stats.vm.v_cache_count", 0);
ram->bytesUsed = ram->bytesTotal - (uint64_t) pagesFree * instance.state.platform.sysinfo.pageSize;
+3 -3
View File
@@ -2,11 +2,11 @@
#include <OS.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
const char* ffDetectMemory(FFMemoryResult* ram) {
system_info info;
if (get_system_info(&info) != B_OK)
if (get_system_info(&info) != B_OK) {
return "Error getting system info";
}
uint32_t pageSize = instance.state.platform.sysinfo.pageSize;
ram->bytesTotal = pageSize * info.max_pages;
+19 -12
View File
@@ -4,12 +4,12 @@
#include <inttypes.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
const char* ffDetectMemory(FFMemoryResult* ram) {
char buf[PROC_FILE_BUFFSIZ];
ssize_t nRead = ffReadFileData("/proc/meminfo", ARRAY_SIZE(buf) - 1, buf);
if(nRead < 0)
if (nRead < 0) {
return "ffReadFileData(\"/proc/meminfo\", ARRAY_SIZE(buf)-1, buf)";
}
buf[nRead] = '\0';
uint64_t memTotal = 0,
@@ -20,30 +20,37 @@ const char* ffDetectMemory(FFMemoryResult* ram)
cached = 0,
sReclaimable = 0;
char *token = NULL;
if((token = strstr(buf, "MemTotal:")) != NULL)
char* token = NULL;
if ((token = strstr(buf, "MemTotal:")) != NULL) {
memTotal = strtoul(token + strlen("MemTotal:"), NULL, 10);
else
} else {
return "MemTotal not found in /proc/meminfo";
}
if((token = strstr(buf, "MemAvailable:")) != NULL)
if ((token = strstr(buf, "MemAvailable:")) != NULL) {
memAvailable = strtoul(token + strlen("MemAvailable:"), NULL, 10);
}
if (memAvailable == 0 || memAvailable >= memTotal) // MemAvailable can be unreasonable. #1988
{
if((token = strstr(buf, "MemFree:")) != NULL)
if ((token = strstr(buf, "MemFree:")) != NULL) {
memFree = strtoul(token + strlen("MemFree:"), NULL, 10);
}
if((token = strstr(buf, "Buffers:")) != NULL)
if ((token = strstr(buf, "Buffers:")) != NULL) {
buffers = strtoul(token + strlen("Buffers:"), NULL, 10);
}
if((token = strstr(buf, "Cached:")) != NULL)
if ((token = strstr(buf, "Cached:")) != NULL) {
cached = strtoul(token + strlen("Cached:"), NULL, 10);
}
if((token = strstr(buf, "Shmem:")) != NULL)
if ((token = strstr(buf, "Shmem:")) != NULL) {
shmem = strtoul(token + strlen("Shmem:"), NULL, 10);
}
if((token = strstr(buf, "SReclaimable:")) != NULL)
if ((token = strstr(buf, "SReclaimable:")) != NULL) {
sReclaimable = strtoul(token + strlen("SReclaimable:"), NULL, 10);
}
memAvailable = memFree + buffers + cached + sReclaimable - shmem;
}
+3 -3
View File
@@ -4,12 +4,12 @@
#include <sys/param.h>
#include <uvm/uvm_extern.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
const char* ffDetectMemory(FFMemoryResult* ram) {
struct uvmexp_sysctl buf;
size_t length = sizeof(buf);
if (sysctl((int[]){ CTL_VM, VM_UVMEXP2 }, 2, &buf, &length, NULL, 0) < 0)
if (sysctl((int[]) {CTL_VM, VM_UVMEXP2}, 2, &buf, &length, NULL, 0) < 0) {
return "sysctl(CTL_VM, VM_UVMEXP2) failed";
}
ram->bytesTotal = (uint64_t) buf.npages * instance.state.platform.sysinfo.pageSize;
ram->bytesUsed = ((uint64_t) buf.active + (uint64_t) buf.inactive + (uint64_t) buf.wired) * instance.state.platform.sysinfo.pageSize;
+1 -2
View File
@@ -1,6 +1,5 @@
#include "memory.h"
const char* ffDetectMemory(FF_MAYBE_UNUSED FFMemoryResult* ram)
{
const char* ffDetectMemory(FF_MAYBE_UNUSED FFMemoryResult* ram) {
return "Not supported on this platform";
}
+3 -3
View File
@@ -4,12 +4,12 @@
#include <sys/param.h>
#include <uvm/uvm_extern.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
const char* ffDetectMemory(FFMemoryResult* ram) {
struct uvmexp buf;
size_t length = sizeof(buf);
if (sysctl((int[]){ CTL_VM, VM_UVMEXP }, 2, &buf, &length, NULL, 0) < 0)
if (sysctl((int[]) {CTL_VM, VM_UVMEXP}, 2, &buf, &length, NULL, 0) < 0) {
return "sysctl(CTL_VM, VM_UVMEXP) failed";
}
ram->bytesTotal = (uint64_t) buf.npages * instance.state.platform.sysinfo.pageSize;
ram->bytesUsed = ((uint64_t) buf.active + (uint64_t) buf.inactive + (uint64_t) buf.wired) * instance.state.platform.sysinfo.pageSize;
+1 -2
View File
@@ -1,8 +1,7 @@
#include "memory.h"
#include <unistd.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
const char* ffDetectMemory(FFMemoryResult* ram) {
ram->bytesTotal = (uint64_t) sysconf(_SC_PHYS_PAGES) * instance.state.platform.sysinfo.pageSize;
ram->bytesUsed = ram->bytesTotal - (uint64_t) sysconf(_SC_AVPHYS_PAGES) * instance.state.platform.sysinfo.pageSize;
+3 -3
View File
@@ -2,16 +2,16 @@
#include <windows.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
const char* ffDetectMemory(FFMemoryResult* ram) {
MEMORYSTATUSEX statex = {
.dwLength = sizeof(statex),
};
// GlobalMemoryStatusEx() internally uses
// NtQuerySystemInformation(SystemBasicPerformanceInformation) in Win 7, and
// NtQuerySystemInformation(SystemMemoryUsageInformation) in Win 10
if (!GlobalMemoryStatusEx(&statex))
if (!GlobalMemoryStatusEx(&statex)) {
return "GlobalMemoryStatusEx() failed";
}
ram->bytesTotal = statex.ullTotalPhys;
ram->bytesUsed = statex.ullTotalPhys - statex.ullAvailPhys;