From dbed1b32b4c23750354d88b22c37e4f02d7a7558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 20 Apr 2026 15:17:49 +0800 Subject: [PATCH] Style: runs clang-format --- .clang-format | 2 ++ src/common/impl/FFPlatform_windows.c | 5 ++--- src/common/impl/binary_apple.c | 3 ++- src/common/impl/smbios.c | 25 +++++++++++++------------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.clang-format b/.clang-format index 17a551e82..06f89607d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,5 @@ +# find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i + BasedOnStyle: LLVM Language: Cpp diff --git a/src/common/impl/FFPlatform_windows.c b/src/common/impl/FFPlatform_windows.c index 170494db8..e352af140 100644 --- a/src/common/impl/FFPlatform_windows.c +++ b/src/common/impl/FFPlatform_windows.c @@ -140,9 +140,8 @@ static void getUserName(FFPlatform* platform) { } NTSYSAPI NTSTATUS NTAPI LsaGetUserName( - _Outptr_ PLSA_UNICODE_STRING* UserName, - _Outptr_opt_ PLSA_UNICODE_STRING* DomainName - ); + _Outptr_ PLSA_UNICODE_STRING * UserName, + _Outptr_opt_ PLSA_UNICODE_STRING * DomainName); PLSA_UNICODE_STRING userName = NULL; if (NT_SUCCESS(LsaGetUserName(&userName, NULL))) { ffStrbufSetNWS(&platform->userName, userName->Length / sizeof(wchar_t), userName->Buffer); diff --git a/src/common/impl/binary_apple.c b/src/common/impl/binary_apple.c index 248be543c..d3358460d 100644 --- a/src/common/impl/binary_apple.c +++ b/src/common/impl/binary_apple.c @@ -20,8 +20,9 @@ typedef struct { static inline void wrapMunmap(FFMemoryMapping* mapping) { assert(mapping); - if (mapping->data == NULL || mapping->data == MAP_FAILED) + if (mapping->data == NULL || mapping->data == MAP_FAILED) { return; + } munmap((void*) mapping->data, mapping->length); } diff --git a/src/common/impl/smbios.c b/src/common/impl/smbios.c index 7deeb8f29..028bcd9c1 100644 --- a/src/common/impl/smbios.c +++ b/src/common/impl/smbios.c @@ -506,24 +506,25 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { return false; #elif defined(__linux__) FF_DEBUG("Using Linux implementation - trying /sys/firmware/dmi/tables/DMI"); - if (ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", buffer)) + if (ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", buffer)) { return true; + } FF_DEBUG("Failed to read /sys/firmware/dmi/tables/DMI, falling back to memory-mapped implementation"); #endif { - #if !defined(__sun) && !defined(__NetBSD__) + #if !defined(__sun) && !defined(__NetBSD__) FF_DEBUG("Using memory-mapped implementation"); FF_STRBUF_AUTO_DESTROY strEntryAddress = ffStrbufCreate(); - #ifdef __FreeBSD__ + #ifdef __FreeBSD__ FF_DEBUG("Using FreeBSD kenv implementation"); if (!ffSettingsGetFreeBSDKenv("hint.smbios.0.mem", &strEntryAddress)) { FF_DEBUG("Failed to get SMBIOS address from FreeBSD kenv"); return false; // non-UEFI systems } FF_DEBUG("Got SMBIOS address from kenv: %s", strEntryAddress.chars); - #elif defined(__linux__) + #elif defined(__linux__) { FF_DEBUG("Using Linux EFI systab implementation"); FF_STRBUF_AUTO_DESTROY systab = ffStrbufCreate(); @@ -538,7 +539,7 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { } FF_DEBUG("Found SMBIOS entry in systab: %s", strEntryAddress.chars); } - #endif + #endif off_t entryAddress = (off_t) strtol(strEntryAddress.chars, NULL, 16); if (entryAddress == 0) { @@ -562,14 +563,14 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { return false; } FF_DEBUG("Successfully read SMBIOS entry point data"); - #else + #else // Sun or NetBSD FF_DEBUG("Using %s specific implementation", - #ifdef __NetBSD__ + #ifdef __NetBSD__ "NetBSD" - #else + #else "SunOS" - #endif + #endif ); FF_AUTO_CLOSE_FD int fd = open("/dev/smbios", O_RDONLY | O_CLOEXEC); @@ -580,7 +581,7 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { FF_DEBUG("/dev/smbios opened successfully with fd=%d", fd); FFSmbiosEntryPoint entryPoint; - #ifdef __NetBSD__ + #ifdef __NetBSD__ off_t addr = (off_t) ffSysctlGetInt64("machdep.smbios", 0); if (addr == 0) { FF_DEBUG("Failed to get SMBIOS address from sysctl"); @@ -593,15 +594,15 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { return false; } FF_DEBUG("Successfully read SMBIOS entry point"); - #else + #else FF_DEBUG("Reading SMBIOS entry point from /dev/smbios"); if (ffReadFDData(fd, sizeof(entryPoint), &entryPoint) < 1) { FF_DEBUG("Failed to read SMBIOS entry point: %s", strerror(errno)); return false; } FF_DEBUG("Successfully read SMBIOS entry point"); - #endif #endif + #endif uint32_t tableLength = 0; off_t tableAddress = 0;