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
+7 -7
View File
@@ -2,22 +2,22 @@
#include <sys/sysctl.h>
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/user.h>
# include <sys/types.h>
# include <sys/user.h>
#endif
#ifndef KERN_PROC_PROC
#define KERN_PROC_PROC KERN_PROC_ALL // Apple
# define KERN_PROC_PROC KERN_PROC_ALL // Apple
#endif
const char* ffDetectProcesses(uint32_t* result)
{
const char* ffDetectProcesses(uint32_t* result) {
int request[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC};
size_t length;
if(sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0)
if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) {
return "sysctl({CTL_KERN, KERN_PROC, KERN_PROC_PROC}) failed";
}
*result = (uint32_t)(length / sizeof(struct kinfo_proc));
*result = (uint32_t) (length / sizeof(struct kinfo_proc));
return NULL;
}
+3 -3
View File
@@ -2,11 +2,11 @@
#include <OS.h>
const char* ffDetectProcesses(uint32_t* result)
{
const char* ffDetectProcesses(uint32_t* result) {
system_info info;
if (get_system_info(&info) != B_OK)
if (get_system_info(&info) != B_OK) {
return "Error getting system info";
}
*result = info.used_teams;
+8 -9
View File
@@ -3,22 +3,21 @@
#include "common/io.h"
#include "common/stringUtils.h"
const char* ffDetectProcesses(uint32_t* result)
{
const char* ffDetectProcesses(uint32_t* result) {
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/proc");
if(dir == NULL)
if (dir == NULL) {
return "opendir(\"/proc\") failed";
}
uint32_t num = 0;
struct dirent* entry;
while ((entry = readdir(dir)) != NULL)
{
while ((entry = readdir(dir)) != NULL) {
if (
#ifdef _DIRENT_HAVE_D_TYPE
(entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) &&
#endif
ffCharIsDigit(entry->d_name[0]))
#ifdef _DIRENT_HAVE_D_TYPE
(entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) &&
#endif
ffCharIsDigit(entry->d_name[0]))
++num;
}
+4 -4
View File
@@ -2,14 +2,14 @@
#include <sys/sysctl.h>
const char* ffDetectProcesses(uint32_t* result)
{
const char* ffDetectProcesses(uint32_t* result) {
int request[] = {CTL_KERN, KERN_PROC2, KERN_PROC_ALL, -1, sizeof(struct kinfo_proc2), 0};
size_t length = 0;
if(sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0)
if (sysctl(request, ARRAY_SIZE(request), NULL, &length, NULL, 0) != 0) {
return "sysctl({CTL_KERN, KERN_PROC2, KERN_PROC_ALL}) failed";
}
*result = (uint32_t)(length / sizeof(struct kinfo_proc2));
*result = (uint32_t) (length / sizeof(struct kinfo_proc2));
return NULL;
}
@@ -1,6 +1,5 @@
#include "processes.h"
const char* ffDetectProcesses(uint32_t* result)
{
const char* ffDetectProcesses(uint32_t* result) {
return "Not supported on this platform";
}
+4 -3
View File
@@ -4,11 +4,12 @@
#include <sys/sysctl.h>
#include <kvm.h>
const char* ffDetectProcesses(uint32_t* result)
{
const char* ffDetectProcesses(uint32_t* result) {
kvm_t* kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL);
const void* ret = kvm_getprocs(kd, KERN_PROC_ALL, 0, 1, result);
kvm_close(kd);
if (!ret) return "kvm_getprocs() failed";
if (!ret) {
return "kvm_getprocs() failed";
}
return NULL;
}
+11 -12
View File
@@ -4,32 +4,31 @@
#include <ntstatus.h>
#include <winternl.h>
const char* ffDetectProcesses(uint32_t* result)
{
const char* ffDetectProcesses(uint32_t* result) {
SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = NULL;
// Multiple attempts in case processes change while
// we are in the middle of querying them.
ULONG size = 0;
for (int attempts = 0;; ++attempts)
{
if (size)
{
pstart = (SYSTEM_PROCESS_INFORMATION*)realloc(pstart, size);
for (int attempts = 0;; ++attempts) {
if (size) {
pstart = (SYSTEM_PROCESS_INFORMATION*) realloc(pstart, size);
assert(pstart);
}
NTSTATUS status = NtQuerySystemInformation(SystemProcessInformation, pstart, size, &size);
if(NT_SUCCESS(status))
if (NT_SUCCESS(status)) {
break;
else if(status == STATUS_INFO_LENGTH_MISMATCH && attempts < 4)
} else if (status == STATUS_INFO_LENGTH_MISMATCH && attempts < 4) {
size += sizeof(SYSTEM_PROCESS_INFORMATION) * 5;
else
} else {
return "NtQuerySystemInformation(SystemProcessInformation) failed";
}
}
*result = 1; //Init with 1 because we test for ptr->NextEntryOffset
for (SYSTEM_PROCESS_INFORMATION* ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*)((uint8_t*)ptr + ptr->NextEntryOffset))
*result = 1; // Init with 1 because we test for ptr->NextEntryOffset
for (SYSTEM_PROCESS_INFORMATION* ptr = pstart; ptr->NextEntryOffset; ptr = (SYSTEM_PROCESS_INFORMATION*) ((uint8_t*) ptr + ptr->NextEntryOffset)) {
++*result;
}
return NULL;
}