From abc6c0593c543c5cf61137c65163787cb1a244da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 15 Apr 2026 16:16:46 +0800 Subject: [PATCH] Chore: `IndentPPDirectives: BeforeHash` [ci skip] --- .clang-format | 2 +- src/common/FFstrbuf.h | 6 +- src/common/arrayUtils.h | 16 +- src/common/attributes.h | 2 +- src/common/dbus.h | 8 +- src/common/debug.h | 4 +- src/common/impl/FFPlatform_unix.c | 22 +- src/common/impl/binary_linux.c | 10 +- src/common/impl/dbus.c | 4 +- src/common/impl/init.c | 6 +- src/common/impl/io_unix.c | 16 +- src/common/impl/library.c | 42 +- src/common/impl/netif.c | 4 +- src/common/impl/netif_apple.c | 10 +- src/common/impl/netif_bsd.c | 18 +- src/common/impl/networking_common.c | 8 +- src/common/impl/networking_linux.c | 58 +- src/common/impl/parsing.c | 6 +- src/common/impl/path.c | 30 +- src/common/impl/processing_linux.c | 66 +-- src/common/impl/properties.c | 2 +- src/common/impl/settings.c | 14 +- src/common/impl/smbios.c | 82 +-- src/common/impl/time.c | 6 +- src/common/io.h | 48 +- src/common/library.h | 72 +-- src/common/mallocHelper.h | 12 +- src/common/netif.h | 4 +- src/common/networking.h | 6 +- src/common/processing.h | 2 +- src/common/thread.h | 54 +- src/common/time.h | 8 +- src/common/wcwidth.h | 2 +- src/common/windows/com.hpp | 8 +- src/common/windows/nt.h | 2 +- src/common/windows/registry.h | 16 +- src/common/windows/unicode.hpp | 6 +- src/common/windows/wmi.hpp | 12 +- src/detection/bios/bios_windows.c | 20 +- src/detection/bluetooth/bluetooth_linux.c | 4 +- .../bluetoothradio/bluetoothradio_linux.c | 4 +- src/detection/bootmgr/bootmgr_bsd.c | 6 +- src/detection/brightness/brightness_apple.c | 8 +- src/detection/brightness/brightness_bsd.c | 10 +- src/detection/brightness/brightness_linux.c | 30 +- src/detection/camera/camera_linux.c | 6 +- src/detection/cpu/cpu.c | 82 +-- src/detection/cpu/cpu_apple.c | 4 +- src/detection/cpu/cpu_bsd.c | 4 +- src/detection/cpu/cpu_linux.c | 28 +- src/detection/cpuusage/cpuusage_bsd.c | 8 +- src/detection/de/de_linux.c | 12 +- src/detection/disk/disk.c | 2 +- src/detection/disk/disk.h | 4 +- src/detection/disk/disk_bsd.c | 36 +- src/detection/disk/disk_linux.c | 10 +- src/detection/diskio/diskio_bsd.c | 18 +- .../displayserver/displayserver_apple.c | 2 +- .../displayserver/linux/displayserver_linux.c | 2 +- src/detection/displayserver/linux/drm.c | 18 +- .../linux/wayland/global-output.c | 6 +- .../kde-output-device-v2-client-protocol.h | 124 ++--- .../wayland/kde-output-device-v2-protocol.c | 8 +- .../kde-output-order-v1-client-protocol.h | 2 +- .../wayland/kde-output-order-v1-protocol.c | 6 +- .../displayserver/linux/wayland/kde-output.c | 10 +- .../displayserver/linux/wayland/wayland.c | 40 +- .../displayserver/linux/wayland/wayland.h | 8 +- ...t-management-unstable-v1-client-protocol.h | 24 +- ...r-output-management-unstable-v1-protocol.c | 24 +- .../xdg-output-unstable-v1-client-protocol.h | 4 +- .../wayland/xdg-output-unstable-v1-protocol.c | 6 +- .../displayserver/linux/wayland/zwlr-output.c | 4 +- src/detection/displayserver/linux/wmde.c | 24 +- src/detection/displayserver/linux/xcb.c | 18 +- src/detection/displayserver/linux/xlib.c | 12 +- src/detection/dns/dns_linux.c | 4 +- src/detection/gamepad/gamepad_bsd.c | 4 +- src/detection/gpu/d3dkmthk.h | 26 +- src/detection/gpu/gpu.h | 4 +- src/detection/gpu/gpu_apple.c | 4 +- src/detection/gpu/gpu_bsd.c | 10 +- src/detection/gpu/gpu_driver_specific.h | 14 +- src/detection/gpu/gpu_drm.c | 44 +- src/detection/gpu/gpu_linux.c | 38 +- src/detection/gpu/gpu_nvidia.c | 20 +- src/detection/gpu/gpu_pci.c | 26 +- src/detection/gpu/gpu_windows.c | 28 +- src/detection/gpu/gpu_windows.cpp | 14 +- src/detection/keyboard/keyboard_bsd.c | 4 +- src/detection/libc/libc_android.c | 6 +- src/detection/libc/libc_bsd.c | 8 +- src/detection/libc/libc_linux.c | 6 +- src/detection/libc/libc_windows.cpp | 2 +- src/detection/lm/lm_linux.c | 6 +- src/detection/loadavg/loadavg_bsd.c | 10 +- src/detection/localip/localip.h | 12 +- src/detection/localip/localip_linux.c | 502 +++++++++--------- src/detection/media/media_linux.c | 4 +- src/detection/mouse/mouse_bsd.c | 4 +- src/detection/opencl/opencl.c | 40 +- src/detection/opengl/opengl_linux.c | 42 +- src/detection/opengl/opengl_shared.c | 32 +- src/detection/os/os_linux.c | 4 +- src/detection/packages/packages.c | 6 +- src/detection/packages/packages_linux.c | 10 +- .../physicaldisk/physicaldisk_apple.c | 2 +- src/detection/physicaldisk/physicaldisk_bsd.c | 14 +- .../physicaldisk/physicaldisk_nbsd.c | 2 +- .../physicaldisk/physicaldisk_obsd.c | 2 +- src/detection/processes/processes_bsd.c | 6 +- src/detection/sound/audio_oss_sunos.h | 28 +- src/detection/sound/sound_apple.c | 2 +- src/detection/sound/sound_bsd.c | 2 +- src/detection/sound/sound_linux.c | 4 +- src/detection/sound/sound_sunos.c | 6 +- .../terminalfont/terminalfont_android.c | 6 +- src/detection/terminalshell/terminalshell.c | 30 +- .../terminalshell/terminalshell_linux.c | 6 +- .../terminalsize/terminalsize_linux.c | 2 +- src/detection/tpm/tpm_apple.c | 4 +- src/detection/users/users_linux.c | 16 +- src/detection/version/version.c | 70 +-- src/detection/vulkan/vulkan.c | 20 +- src/detection/wifi/wifi_linux.c | 10 +- src/detection/wm/wm_linux.c | 8 +- src/detection/zpool/zpool.c | 26 +- src/logo/image/im6.c | 6 +- src/logo/image/im7.c | 6 +- src/logo/image/image.c | 108 ++-- src/logo/image/image.h | 2 +- src/modules/disk/disk.c | 2 +- src/modules/separator/separator.c | 2 +- 133 files changed, 1329 insertions(+), 1329 deletions(-) diff --git a/.clang-format b/.clang-format index 0a8dba15d..17a551e82 100644 --- a/.clang-format +++ b/.clang-format @@ -42,7 +42,7 @@ SpacesInLineCommentPrefix: SpacesInContainerLiterals: true SortIncludes: Never -IndentPPDirectives: AfterHash +IndentPPDirectives: BeforeHash PPIndentWidth: 4 IndentCaseLabels: true diff --git a/src/common/FFstrbuf.h b/src/common/FFstrbuf.h index 41ddd004f..2c9a09b9b 100644 --- a/src/common/FFstrbuf.h +++ b/src/common/FFstrbuf.h @@ -11,15 +11,15 @@ #include #ifdef FF_USE_SYSTEM_YYJSON -# include + #include #else -# include "3rdparty/yyjson/yyjson.h" + #include "3rdparty/yyjson/yyjson.h" #endif #ifdef _WIN32 // #include __stdcall char* StrStrIA(const char* lpFirst, const char* lpSrch); -# define strcasestr StrStrIA + #define strcasestr StrStrIA #endif #define FASTFETCH_STRBUF_DEFAULT_ALLOC 32 diff --git a/src/common/arrayUtils.h b/src/common/arrayUtils.h index e248cd29b..83a49d6aa 100644 --- a/src/common/arrayUtils.h +++ b/src/common/arrayUtils.h @@ -3,14 +3,14 @@ #include #ifdef __has_builtin -# if !__cplusplus && FF_SUPPORTS_COUNT_OF -# define ARRAY_SIZE(x) _Countof(x) -# elif __has_builtin(__is_array) -# define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); }) -# elif __has_builtin(__builtin_types_compatible_p) -# define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); }) -# endif + #if !__cplusplus && FF_SUPPORTS_COUNT_OF + #define ARRAY_SIZE(x) _Countof(x) + #elif __has_builtin(__is_array) + #define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); }) + #elif __has_builtin(__builtin_types_compatible_p) + #define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); }) + #endif #endif #ifndef ARRAY_SIZE -# define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x)))) + #define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x)))) #endif diff --git a/src/common/attributes.h b/src/common/attributes.h index 9d8664126..2a91c01ed 100644 --- a/src/common/attributes.h +++ b/src/common/attributes.h @@ -1,7 +1,7 @@ #pragma once #ifdef _MSC_VER -# define __attribute__(x) + #define __attribute__(x) #endif #define FF_A_FALLTHROUGH __attribute__((__fallthrough__)) diff --git a/src/common/dbus.h b/src/common/dbus.h index b364e1b91..864040241 100644 --- a/src/common/dbus.h +++ b/src/common/dbus.h @@ -1,10 +1,10 @@ #pragma once #ifdef FF_HAVE_DBUS -# include + #include -# include "common/FFstrbuf.h" -# include "common/library.h" + #include "common/FFstrbuf.h" + #include "common/library.h" typedef struct FFDBusLibrary { FF_LIBRARY_SYMBOL(dbus_bus_get) @@ -41,6 +41,6 @@ static inline DBusMessage* ffDBusGetAllProperties(FFDBusData* dbus, const char* return ffDBusGetMethodReply(dbus, busName, objectPath, "org.freedesktop.DBus.Properties", "GetAll", interface, NULL); } -# define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData) + #define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData) #endif // FF_HAVE_DBUS diff --git a/src/common/debug.h b/src/common/debug.h index 70b0a82b3..a378fc841 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -17,13 +17,13 @@ static inline const char* ffFindFileName(const char* file) { } #ifndef NDEBUG -# define FF_DEBUG_PRINT(file_, line_, format_, ...) \ + #define FF_DEBUG_PRINT(file_, line_, format_, ...) \ do { \ if (instance.config.display.debugMode) \ fprintf(stderr, "[%s%4d, %s] " format_ "\n", ffFindFileName(file_), line_, ffTimeToTimeStr(ffTimeGetNow()), ##__VA_ARGS__); \ } while (0) #else -# define FF_DEBUG_PRINT(file_, line_, format_, ...) \ + #define FF_DEBUG_PRINT(file_, line_, format_, ...) \ do { \ } while (0) #endif diff --git a/src/common/impl/FFPlatform_unix.c b/src/common/impl/FFPlatform_unix.c index 50dd47996..8320a1771 100644 --- a/src/common/impl/FFPlatform_unix.c +++ b/src/common/impl/FFPlatform_unix.c @@ -12,17 +12,17 @@ #include #ifdef __APPLE__ -# include -# include + #include + #include #elif defined(__FreeBSD__) || defined(__NetBSD__) -# include + #include #elif defined(__OpenBSD__) -# include -# include -# include "common/path.h" + #include + #include + #include "common/path.h" #elif defined(__HAIKU__) -# include -# include + #include + #include #endif static void getExePath(FFPlatform* platform) { @@ -43,15 +43,15 @@ static void getExePath(FFPlatform* platform) { size_t exePathLen = sizeof(exePath); if (sysctl( (int[]) { CTL_KERN, -# ifdef __FreeBSD__ + #ifdef __FreeBSD__ KERN_PROC, KERN_PROC_PATHNAME, (pid_t) platform->pid -# else + #else KERN_PROC_ARGS, (pid_t) platform->pid, KERN_PROC_PATHNAME -# endif + #endif }, 4, exePath, diff --git a/src/common/impl/binary_linux.c b/src/common/impl/binary_linux.c index 450b55981..240e75870 100644 --- a/src/common/impl/binary_linux.c +++ b/src/common/impl/binary_linux.c @@ -2,12 +2,12 @@ #if defined(FF_HAVE_ELF) || defined(__sun) || (defined(__FreeBSD__) && !defined(__DragonFly__)) || defined(__OpenBSD__) || defined(__NetBSD__) -# include "common/io.h" -# include "common/library.h" -# include "common/stringUtils.h" + #include "common/io.h" + #include "common/library.h" + #include "common/stringUtils.h" -# include // #1254 -# include + #include // #1254 + #include /** * Structure to hold dynamically loaded libelf function pointers diff --git a/src/common/impl/dbus.c b/src/common/impl/dbus.c index 4d4d44b58..e8ef68fdd 100644 --- a/src/common/impl/dbus.c +++ b/src/common/impl/dbus.c @@ -2,8 +2,8 @@ #ifdef FF_HAVE_DBUS -# include "common/thread.h" -# include "common/stringUtils.h" + #include "common/thread.h" + #include "common/stringUtils.h" static bool loadLibSymbols(FFDBusLibrary* lib) { FF_LIBRARY_LOAD(dbus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4); diff --git a/src/common/impl/init.c b/src/common/impl/init.c index 77d1f5d80..767eb7fdc 100644 --- a/src/common/impl/init.c +++ b/src/common/impl/init.c @@ -11,10 +11,10 @@ #include #include #ifdef _WIN32 -# include -# include "common/windows/unicode.h" + #include + #include "common/windows/unicode.h" #else -# include + #include #endif FFinstance instance; // Global singleton diff --git a/src/common/impl/io_unix.c b/src/common/impl/io_unix.c index a9ee941b9..65cc9121a 100644 --- a/src/common/impl/io_unix.c +++ b/src/common/impl/io_unix.c @@ -8,15 +8,15 @@ #include #include #ifndef __APPLE__ -# include + #include #else -# include + #include #endif #if FF_HAVE_WORDEXP -# include + #include #else -# include + #include #endif static void createSubfolders(const char* fileName) { @@ -112,12 +112,12 @@ bool ffPathExpandEnv(const char* in, FFstrbuf* out) { glob_t gb; if (glob(in, GLOB_NOSORT -# ifdef GLOB_TILDE + #ifdef GLOB_TILDE | GLOB_TILDE -# endif -# ifdef GLOB_BRACE + #endif + #ifdef GLOB_BRACE | GLOB_BRACE -# endif + #endif , NULL, &gb) != 0) diff --git a/src/common/impl/library.c b/src/common/impl/library.c index 74403e2bd..863f851f3 100644 --- a/src/common/impl/library.c +++ b/src/common/impl/library.c @@ -2,35 +2,35 @@ #include "common/library.h" #if _WIN32 -# include "common/debug.h" -# include "common/windows/nt.h" -# include -# include + #include "common/debug.h" + #include "common/windows/nt.h" + #include + #include #endif #ifndef FF_DISABLE_DLOPEN -# include + #include -// Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer) -# if !defined(__SANITIZE_ADDRESS__) && defined(__has_feature) -# if __has_feature(address_sanitizer) -# define __SANITIZE_ADDRESS__ -# endif -# endif + // Clang doesn't define __SANITIZE_ADDRESS__ but defines __has_feature(address_sanitizer) + #if !defined(__SANITIZE_ADDRESS__) && defined(__has_feature) + #if __has_feature(address_sanitizer) + #define __SANITIZE_ADDRESS__ + #endif + #endif -# ifndef FF_DLOPEN_FLAGS -# ifdef __SANITIZE_ADDRESS__ -# define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE -# else -# define FF_DLOPEN_FLAGS RTLD_LAZY -# endif -# endif + #ifndef FF_DLOPEN_FLAGS + #ifdef __SANITIZE_ADDRESS__ + #define FF_DLOPEN_FLAGS RTLD_LAZY | RTLD_NODELETE + #else + #define FF_DLOPEN_FLAGS RTLD_LAZY + #endif + #endif static void* libraryLoad(const char* path, int maxVersion) { void* result = dlopen(path, FF_DLOPEN_FLAGS); -# ifdef _WIN32 + #ifdef _WIN32 // libX.dll.1 never exists on Windows, while libX-1.dll may exist FF_UNUSED(maxVersion) @@ -48,7 +48,7 @@ static void* libraryLoad(const char* path, int maxVersion) { strcpy(mempcpy(absPath, instance.state.platform.exePath.chars, pathLen + 1), path); return dlopen(absPath, FF_DLOPEN_FLAGS); -# else + #else if (result != NULL || maxVersion < 0) { return result; @@ -70,7 +70,7 @@ static void* libraryLoad(const char* path, int maxVersion) { ffStrbufSubstrBefore(&pathbuf, originalLength); } -# endif + #endif return result; } diff --git a/src/common/impl/netif.c b/src/common/impl/netif.c index 9f9ca5b8a..1525a185a 100644 --- a/src/common/impl/netif.c +++ b/src/common/impl/netif.c @@ -1,8 +1,8 @@ #include "common/netif.h" #ifndef _WIN32 -# include -# include + #include + #include #endif const FFNetifDefaultRouteResult* ffNetifGetDefaultRouteV4(void) { diff --git a/src/common/impl/netif_apple.c b/src/common/impl/netif_apple.c index f4e0a2f90..b37ea2cb9 100644 --- a/src/common/impl/netif_apple.c +++ b/src/common/impl/netif_apple.c @@ -11,13 +11,13 @@ #define ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n)) #if __APPLE__ -// https://github.com/apple-oss-distributions/network_cmds/blob/8f38231438e6a4d16ef8015e97e12c2c05105644/rtsol.tproj/if.c#L243 -# define ROUNDUP(a) ROUNDUP2((a), sizeof(uint32_t)) + // https://github.com/apple-oss-distributions/network_cmds/blob/8f38231438e6a4d16ef8015e97e12c2c05105644/rtsol.tproj/if.c#L243 + #define ROUNDUP(a) ROUNDUP2((a), sizeof(uint32_t)) #elif __sun -// https://github.com/illumos/illumos-gate/blob/95b8c88950fa7b19af46bc63230137cf96b0bff7/usr/src/cmd/cmd-inet/usr.sbin/route.c#L339 -# define ROUNDUP(a) ROUNDUP2((a), sizeof(long)) + // https://github.com/illumos/illumos-gate/blob/95b8c88950fa7b19af46bc63230137cf96b0bff7/usr/src/cmd/cmd-inet/usr.sbin/route.c#L339 + #define ROUNDUP(a) ROUNDUP2((a), sizeof(long)) #else -# error unknown platform + #error unknown platform #endif static struct sockaddr* diff --git a/src/common/impl/netif_bsd.c b/src/common/impl/netif_bsd.c index a163cb766..72ef96b74 100644 --- a/src/common/impl/netif_bsd.c +++ b/src/common/impl/netif_bsd.c @@ -12,19 +12,19 @@ #define ROUNDUP2(a, n) ((a) > 0 ? (1 + (((a) - 1U) | ((n) - 1))) : (n)) #if __DragonFly__ -// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/cf0aa2f1e47a3f0a6055fe427563cb3f3e627064/sys/net/route.h#L315C9-L315C19 -# define ROUNDUP(a) ROUNDUP2((a), sizeof(long)) + // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/cf0aa2f1e47a3f0a6055fe427563cb3f3e627064/sys/net/route.h#L315C9-L315C19 + #define ROUNDUP(a) ROUNDUP2((a), sizeof(long)) #elif __FreeBSD__ -// https://github.com/freebsd/freebsd-src/blob/e4c0ecba44b20ebb2e4d80978c2cb6d16b730cb9/sys/net/route.h#L368C9-L368C16 -# define ROUNDUP(a) ROUNDUP2((a), sizeof(long)) + // https://github.com/freebsd/freebsd-src/blob/e4c0ecba44b20ebb2e4d80978c2cb6d16b730cb9/sys/net/route.h#L368C9-L368C16 + #define ROUNDUP(a) ROUNDUP2((a), sizeof(long)) #elif __NetBSD__ -// https://github.com/NetBSD/src/blob/29beb637d057520c0ed37ac2cde966f7cc0cadf4/sys/net/route.h#L330 -# define ROUNDUP(a) ROUNDUP2((a), sizeof(uint64_t)) + // https://github.com/NetBSD/src/blob/29beb637d057520c0ed37ac2cde966f7cc0cadf4/sys/net/route.h#L330 + #define ROUNDUP(a) ROUNDUP2((a), sizeof(uint64_t)) #elif __OpenBSD__ -// https://github.com/openbsd/src/blob/ca647cfa4ec3ccb8360714bc0ebc32a394f7fb6a/regress/sys/netinet/bindconnect/bindconnect.c#L250 -# define ROUNDUP(a) ROUNDUP2((a), sizeof(long)) + // https://github.com/openbsd/src/blob/ca647cfa4ec3ccb8360714bc0ebc32a394f7fb6a/regress/sys/netinet/bindconnect/bindconnect.c#L250 + #define ROUNDUP(a) ROUNDUP2((a), sizeof(long)) #else -# error unknown platform + #error unknown platform #endif static struct sockaddr* diff --git a/src/common/impl/networking_common.c b/src/common/impl/networking_common.c index 543f87623..ac0930756 100644 --- a/src/common/impl/networking_common.c +++ b/src/common/impl/networking_common.c @@ -5,7 +5,7 @@ #include "common/debug.h" #ifdef FF_HAVE_ZLIB -# include + #include struct FFZlibLibrary { FF_LIBRARY_SYMBOL(inflateInit2_) @@ -19,11 +19,11 @@ const char* ffNetworkingLoadZlibLibrary(void) { if (!zlibData.inited) { zlibData.inited = true; FF_LIBRARY_LOAD_MESSAGE(zlib, -# ifdef _WIN32 + #ifdef _WIN32 "zlib1" -# else + #else "libz" -# endif + #endif FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflateInit2_) diff --git a/src/common/impl/networking_linux.c b/src/common/impl/networking_linux.c index 0f28947ea..f63bc47aa 100644 --- a/src/common/impl/networking_linux.c +++ b/src/common/impl/networking_linux.c @@ -20,56 +20,56 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { #if defined(TCP_FASTOPEN) || __APPLE__ if (!state->tfo) { -# if __linux__ || __GNU__ + #if __linux__ || __GNU__ // Linux doesn't support sendto() on unconnected sockets FF_DEBUG("TCP Fast Open disabled, skipping"); return "TCP Fast Open disabled"; -# endif + #endif } else { FF_DEBUG("Attempting to use TCP Fast Open to connect"); -# ifndef __APPLE__ // On macOS, TCP_FASTOPEN doesn't seem to be needed + #ifndef __APPLE__ // On macOS, TCP_FASTOPEN doesn't seem to be needed // Set TCP Fast Open int flag = 1; if (setsockopt(state->sockfd, IPPROTO_TCP, -# ifdef __APPLE__ + #ifdef __APPLE__ // https://github.com/rust-lang/libc/pull/3135 0x218 // TCP_FASTOPEN_FORCE_ENABLE -# else + #else TCP_FASTOPEN -# endif + #endif , &flag, sizeof(flag)) != 0) { FF_DEBUG("Failed to set TCP_FASTOPEN option: %s", strerror(errno)); return "setsockopt(TCP_FASTOPEN) failed"; } else { -# if __linux__ || __GNU__ + #if __linux__ || __GNU__ FF_DEBUG("Successfully set TCP_FASTOPEN option, queue length: %d", flag); -# elif defined(__APPLE__) + #elif defined(__APPLE__) FF_DEBUG("Successfully set TCP_FASTOPEN_FORCE_ENABLE option"); -# else + #else FF_DEBUG("Successfully set TCP_FASTOPEN option"); -# endif + #endif } -# endif + #endif } -# ifndef __APPLE__ + #ifndef __APPLE__ FF_DEBUG("Using sendto() + MSG_DONTWAIT to send %u bytes of data", state->command.length); ssize_t sent = sendto(state->sockfd, state->command.chars, state->command.length, -# ifdef MSG_FASTOPEN + #ifdef MSG_FASTOPEN MSG_FASTOPEN | -# endif -# ifdef MSG_NOSIGNAL + #endif + #ifdef MSG_NOSIGNAL MSG_NOSIGNAL | -# endif + #endif MSG_DONTWAIT, state->addr->ai_addr, state->addr->ai_addrlen); -# else + #else if (fcntl(state->sockfd, F_SETFL, O_NONBLOCK) == -1) { FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno)); return "fcntl(F_SETFL) failed"; @@ -97,20 +97,20 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno)); return "fcntl(F_SETFL) failed"; } -# endif + #endif if (sent > 0 || (errno == EAGAIN || errno == EWOULDBLOCK -# ifdef __APPLE__ + #ifdef __APPLE__ // On macOS EINPROGRESS means the connection cannot be completed immediately // On Linux, it means the TFO cookie is not available locally || errno == EINPROGRESS -# endif + #endif )) { FF_DEBUG( -# ifdef __APPLE__ + #ifdef __APPLE__ "connectx()" -# else + #else "sendto()" -# endif + #endif " %s (sent=%zd, %s)", errno == 0 ? "succeeded" : "was in progress", sent, @@ -122,18 +122,18 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { } FF_DEBUG( -# ifdef __APPLE__ + #ifdef __APPLE__ "connectx()" -# else + #else "sendto()" -# endif + #endif " failed: %s", strerror(errno)); -# ifdef __APPLE__ + #ifdef __APPLE__ return "connectx() failed"; -# else + #else return "sendto() failed"; -# endif + #endif #else FF_UNUSED(state); return "TFO support is not available"; diff --git a/src/common/impl/parsing.c b/src/common/impl/parsing.c index b6de9d648..ad8c41c8d 100644 --- a/src/common/impl/parsing.c +++ b/src/common/impl/parsing.c @@ -4,8 +4,8 @@ #include #ifdef _WIN32 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wformat" + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wformat" #endif void ffParseSemver(FFstrbuf* buffer, const FFstrbuf* major, const FFstrbuf* minor, const FFstrbuf* patch) { @@ -124,5 +124,5 @@ void ffParseGTK(FFstrbuf* buffer, const FFstrbuf* gtk2, const FFstrbuf* gtk3, co } #ifdef _WIN32 -# pragma GCC diagnostic pop + #pragma GCC diagnostic pop #endif diff --git a/src/common/impl/path.c b/src/common/impl/path.c index 59c163651..03662502c 100644 --- a/src/common/impl/path.c +++ b/src/common/impl/path.c @@ -9,17 +9,17 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) { return "$PATH not set"; } -# ifdef _WIN32 + #ifdef _WIN32 const bool appendExe = !ffStrEndsWithIgnCase(name, ".exe"); -# endif + #endif for (char* token = path; *token; path = token + 1) { token = strchr(path, -# ifdef _WIN32 + #ifdef _WIN32 ';' -# else + #else ':' -# endif + #endif ); if (!token) { token = path + strlen(path); @@ -27,25 +27,25 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) { ffStrbufSetNS(result, (uint32_t) (token - path), path); ffStrbufEnsureEndsWithC(result, -# ifdef _WIN32 + #ifdef _WIN32 '\\' -# else + #else '/' -# endif + #endif ); ffStrbufAppendS(result, name); -# ifdef _WIN32 + #ifdef _WIN32 if (appendExe) { ffStrbufAppendS(result, ".exe"); } if (!ffPathExists(result->chars, FF_PATHTYPE_FILE)) { continue; } -# else + #else if (access(result->chars, X_OK) != 0) { continue; } -# endif + #endif return NULL; } @@ -53,10 +53,10 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) { return "Executable not found"; } #else -# include -# include -# include -# include + #include + #include + #include + #include const char* ffFindExecutableInPath(const char* name, FFstrbuf* result) { char buffer[MAX_PATH + 1]; diff --git a/src/common/impl/processing_linux.c b/src/common/impl/processing_linux.c index 41f44a25a..6fda83ce6 100644 --- a/src/common/impl/processing_linux.c +++ b/src/common/impl/processing_linux.c @@ -13,28 +13,28 @@ #include #if !(__ANDROID__ || __OpenBSD__) -# include + #include #endif #if defined(__FreeBSD__) || defined(__APPLE__) -# include -# include -# include + #include + #include + #include #endif #if defined(__APPLE__) -# include + #include #elif defined(__sun) -# include + #include #elif defined(__OpenBSD__) -# include -# include -# include + #include + #include + #include #elif defined(__NetBSD__) -# include -# include + #include + #include #elif defined(__HAIKU__) -# include -# include + #include + #include #endif #ifndef environ @@ -234,9 +234,9 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons // For interpreters, try to find the real script path in the arguments if (ffStrStartsWith(name, "python") -# ifndef __ANDROID__ + #ifndef __ANDROID__ || ffStrEquals(name, "guile") // for shepherd -# endif + #endif ) { // `cmdline` always ends with a trailing '\0', and ffReadFileBuffer appends another \0 // So `exe->chars` is always double '\0' terminated @@ -341,15 +341,15 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons static_assert(ARG_MAX > PATH_MAX, ""); if (exePath && sysctl((int[]) { CTL_KERN, -# if __FreeBSD__ + #if __FreeBSD__ KERN_PROC, KERN_PROC_PATHNAME, pid -# else + #else KERN_PROC_ARGS, pid, KERN_PROC_PATHNAME -# endif + #endif }, 4, args, @@ -361,15 +361,15 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons size = ARG_MAX; if (sysctl( (int[]) { CTL_KERN, -# if __FreeBSD__ + #if __FreeBSD__ KERN_PROC, KERN_PROC_ARGS, pid -# else + #else KERN_PROC_ARGS, pid, KERN_PROC_ARGV, -# endif + #endif }, 4, args, @@ -476,9 +476,9 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i #if defined(__linux__) || defined(__GNU__) char procFilePath[64]; -# if __linux__ + #if __linux__ if (ppid || tty) -# endif + #endif { snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/stat", (int) pid); char buf[PROC_FILE_BUFFSIZ]; @@ -509,9 +509,9 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i pState = end + 2; // skip ") " } -# if !__linux__ + #if !__linux__ if (ppid || tty) -# endif + #endif { int ppid_, tty_; if (sscanf(pState + 2, "%d %*d %*d %d", &ppid_, &tty_) < 2) { @@ -526,7 +526,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i } } } -# if __linux__ + #if __linux__ else { snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int) pid); ssize_t nRead = ffReadFileBuffer(procFilePath, name); @@ -535,7 +535,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i } ffStrbufTrimRightSpace(name); } -# endif + #endif #elif defined(__APPLE__) @@ -558,12 +558,12 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i #elif defined(__FreeBSD__) -# ifdef __DragonFly__ -# define ki_comm kp_comm -# define ki_ppid kp_ppid -# define ki_tdev kp_tdev -# define ki_flag kp_flags -# endif + #ifdef __DragonFly__ + #define ki_comm kp_comm + #define ki_ppid kp_ppid + #define ki_tdev kp_tdev + #define ki_flag kp_flags + #endif struct kinfo_proc proc; size_t size = sizeof(proc); diff --git a/src/common/impl/properties.c b/src/common/impl/properties.c index 1e7427f30..33192b75d 100644 --- a/src/common/impl/properties.c +++ b/src/common/impl/properties.c @@ -6,7 +6,7 @@ #include #include #ifdef _WIN32 -# include "common/windows/getline.h" + #include "common/windows/getline.h" #endif bool ffParsePropLinePointer(const char** line, const char* start, FFstrbuf* buffer) { diff --git a/src/common/impl/settings.c b/src/common/impl/settings.c index 6e9d55372..e62342ded 100644 --- a/src/common/impl/settings.c +++ b/src/common/impl/settings.c @@ -7,7 +7,7 @@ #include #ifdef FF_HAVE_GIO -# include + #include typedef struct GVariantGetters { FF_LIBRARY_SYMBOL(g_variant_dup_string) @@ -124,7 +124,7 @@ FFvariant ffSettingsGetGSettings(const char* schemaName, const char* path, const #endif // FF_HAVE_GIO #ifdef FF_HAVE_DCONF -# include + #include typedef struct DConfData { FF_LIBRARY_SYMBOL(dconf_client_read_full) @@ -200,7 +200,7 @@ FFvariant ffSettingsGetGnome(const char* dconfKey, const char* gsettingsSchemaNa } #ifdef FF_HAVE_DBUS -# include "common/dbus.h" + #include "common/dbus.h" FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, FFvarianttype type) { FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; @@ -248,7 +248,7 @@ FFvariant ffSettingsGetXFConf(const char* channelName, const char* propertyName, return FF_VARIANT_NULL; } -# define FF_DBUS_ITER_CONTINUE(dbus, iterator) \ + #define FF_DBUS_ITER_CONTINUE(dbus, iterator) \ { \ if (!(dbus).lib->ffdbus_message_iter_next(iterator)) \ break; \ @@ -334,7 +334,7 @@ FFvariant ffSettingsGetXFConfFirstMatch(const char* channelName, const char* pro #endif // FF_HAVE_DBUS #ifdef FF_HAVE_SQLITE3 -# include + #include typedef struct SQLiteData { FF_LIBRARY_SYMBOL(sqlite3_open_v2) @@ -454,7 +454,7 @@ bool ffSettingsGetSQLite3String(const char* dbPath, const char* query, FFstrbuf* #endif // FF_HAVE_SQLITE3 #ifdef __ANDROID__ -# include + #include bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) { ffStrbufEnsureFree(result, PROP_VALUE_MAX); int len = __system_property_get(propName, result->chars + result->length); @@ -466,7 +466,7 @@ bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result) { return true; } #elif defined(__FreeBSD__) -# include + #include bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result) { // https://wiki.ghostbsd.org/index.php/Kenv ffStrbufEnsureFree(result, KENV_MVALLEN); diff --git a/src/common/impl/smbios.c b/src/common/impl/smbios.c index 94f006d64..5710347ac 100644 --- a/src/common/impl/smbios.c +++ b/src/common/impl/smbios.c @@ -141,21 +141,21 @@ static bool parseSmbiosTable(const uint8_t* data, uint32_t length) { } #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__) || defined(__OpenBSD__) || defined(__GNU__) -# include -# include -# include -# include -# include + #include + #include + #include + #include + #include -# ifdef __linux__ -# include "common/properties.h" -# elif defined(__FreeBSD__) -# include "common/settings.h" -# elif defined(__NetBSD__) -# include "common/sysctl.h" -# endif + #ifdef __linux__ + #include "common/properties.h" + #elif defined(__FreeBSD__) + #include "common/settings.h" + #elif defined(__NetBSD__) + #include "common/sysctl.h" + #endif -# ifdef __linux__ + #ifdef __linux__ bool ffGetSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* buffer) { // /sys/class/dmi/id/* are all pseudo-files with very small content // so reading the whole file at once is efficient @@ -186,10 +186,10 @@ bool ffGetSmbiosValue(const char* devicesPath, const char* classPath, FFstrbuf* ffStrbufClear(buffer); return false; } -# endif + #endif static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffer) { -# if !defined(__FreeBSD__) // Either causes kernel panic or returns EFAULT + #if !defined(__FreeBSD__) // Either causes kernel panic or returns EFAULT // -1: unknown, 0: failed before (stop trying), 1: succeeded before static int preadState = -1; if (preadState != 0) { @@ -208,7 +208,7 @@ static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffe } else { FF_DEBUG("Skipping pread due to cached failure; using mmap"); } -# endif + #endif off_t alignedAddress = address & ~((off_t) instance.state.platform.sysinfo.pageSize - 1); size_t pageOffset = (size_t) (address - alignedAddress); @@ -270,11 +270,11 @@ typedef union FFSmbiosEntryPoint { static bool fillTableBufferFallback(FFstrbuf* buffer) { const char* devMem = -# if __HAIKU__ + #if __HAIKU__ "/dev/misc/mem"; -# else + #else "/dev/mem"; // kern.securelevel must be -1 -# endif + #endif FF_DEBUG("Using physical memory searching implementation: %s", devMem); uint32_t tableLength = 0; @@ -355,7 +355,7 @@ static bool fillTableBufferFallback(FFstrbuf* buffer) { return true; } -# ifdef __OpenBSD__ + #ifdef __OpenBSD__ static bool detectSmbiosTableLength(const uint8_t* data, uint32_t bufferLength, uint32_t* tableLength) { const uint8_t* p = data; const uint8_t* end = data + bufferLength; @@ -500,26 +500,26 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { ffStrbufClear(buffer); return false; } -# else + #else static bool fillTableBufferPlatform(FFstrbuf* buffer) { -# if __HAIKU__ && __GNU__ + #if __HAIKU__ && __GNU__ return false; -# elif defined(__linux__) + #elif defined(__linux__) FF_DEBUG("Using Linux implementation - trying /sys/firmware/dmi/tables/DMI"); if (!ffAppendFileBuffer("/sys/firmware/dmi/tables/DMI", buffer)) -# else + #else { -# 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(); @@ -534,7 +534,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) { @@ -558,14 +558,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); @@ -576,7 +576,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"); @@ -589,15 +589,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 + #endif uint32_t tableLength = 0; off_t tableAddress = 0; @@ -649,11 +649,11 @@ static bool fillTableBufferPlatform(FFstrbuf* buffer) { return false; } } -# endif + #endif return true; } -# endif + #endif const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { static FFstrbuf buffer; @@ -684,9 +684,9 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { return &smbiosTable; } #elif defined(_WIN32) -# include "common/windows/nt.h" + #include "common/windows/nt.h" -# pragma GCC diagnostic ignored "-Wmultichar" + #pragma GCC diagnostic ignored "-Wmultichar" typedef struct FFRawSmbiosData { uint8_t Used20CallingMethod; @@ -754,7 +754,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { return &smbiosTable; } #elif defined(__APPLE__) -# include "common/apple/cf_helpers.h" + #include "common/apple/cf_helpers.h" const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable() { static CFDataRef smbiosDataBuffer; diff --git a/src/common/impl/time.c b/src/common/impl/time.c index 3de9bb1f1..c60d1fece 100644 --- a/src/common/impl/time.c +++ b/src/common/impl/time.c @@ -5,8 +5,8 @@ char ffTimeInternalBuffer[64]; // Reduce memory usage and prevent redundant allocations #ifdef _WIN32 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wformat" + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wformat" #endif const char* ffTimeToFullStr(uint64_t msec) { @@ -45,7 +45,7 @@ const char* ffTimeToTimeStr(uint64_t msec) { } #ifdef _WIN32 -# pragma GCC diagnostic pop + #pragma GCC diagnostic pop #endif FFTimeGetAgeResult ffTimeGetAge(uint64_t birthMs, uint64_t nowMs) { diff --git a/src/common/io.h b/src/common/io.h index c9b707a53..f7aec0b42 100644 --- a/src/common/io.h +++ b/src/common/io.h @@ -4,36 +4,36 @@ #include "common/FFlist.h" #ifdef _WIN32 -# include -# include -# include -# include "common/windows/nt.h" + #include + #include + #include + #include "common/windows/nt.h" typedef HANDLE FFNativeFD; -# define FF_INVALID_FD INVALID_HANDLE_VALUE + #define FF_INVALID_FD INVALID_HANDLE_VALUE #else -# include -# include -# include -# include -# include -# include + #include + #include + #include + #include + #include + #include typedef int FFNativeFD; -# define FF_INVALID_FD (-1) -// procfs's file can be changed between read calls such as /proc/meminfo and /proc/uptime. -// one safe way to read correct data is reading the whole file in a single read syscall -# define PROC_FILE_BUFFSIZ (32 * 1024) + #define FF_INVALID_FD (-1) + // procfs's file can be changed between read calls such as /proc/meminfo and /proc/uptime. + // one safe way to read correct data is reading the whole file in a single read syscall + #define PROC_FILE_BUFFSIZ (32 * 1024) #endif #ifdef _WIN32 -# ifndef O_CLOEXEC -# define O_CLOEXEC 0 -# endif -# ifndef O_RDONLY -# define O_RDONLY 0 -# endif -# ifndef O_DIRECTORY -# define O_DIRECTORY 0200000 -# endif + #ifndef O_CLOEXEC + #define O_CLOEXEC 0 + #endif + #ifndef O_RDONLY + #define O_RDONLY 0 + #endif + #ifndef O_DIRECTORY + #define O_DIRECTORY 0200000 + #endif // Only O_RDONLY is supported HANDLE openat(HANDLE dfd, const char* fileName, int oflag); diff --git a/src/common/library.h b/src/common/library.h index bdf4e66ea..97500ac9e 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -4,22 +4,22 @@ #ifndef FF_DISABLE_DLOPEN -# if defined(_WIN32) -# define FF_DLOPEN_FLAGS 0 + #if defined(_WIN32) + #define FF_DLOPEN_FLAGS 0 FF_A_NODISCARD void* dlopen(const char* path, int mode); FF_A_NODISCARD void* dlsym(void* handle, const char* symbol); int dlclose(void* handle); -# else -# include -# endif + #else + #include + #endif -# ifdef _WIN32 -# define FF_LIBRARY_EXTENSION ".dll" -# elif defined(__APPLE__) -# define FF_LIBRARY_EXTENSION ".dylib" -# else -# define FF_LIBRARY_EXTENSION ".so" -# endif + #ifdef _WIN32 + #define FF_LIBRARY_EXTENSION ".dll" + #elif defined(__APPLE__) + #define FF_LIBRARY_EXTENSION ".dylib" + #else + #define FF_LIBRARY_EXTENSION ".so" + #endif static inline void ffLibraryUnload(void** handle) { assert(handle); @@ -28,78 +28,78 @@ static inline void ffLibraryUnload(void** handle) { } } -# if __cplusplus -# define __auto_type auto -# endif + #if __cplusplus + #define __auto_type auto + #endif -# define FF_LIBRARY_SYMBOL(symbolName) \ + #define FF_LIBRARY_SYMBOL(symbolName) \ __typeof__(&symbolName) ff##symbolName; -# define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ + #define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ void* FF_A_CLEANUP(ffLibraryUnload) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL); \ if (libraryObjectName == NULL) \ return returnValue; -# define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \ + #define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \ FF_LIBRARY_LOAD(libraryObjectName, "dlopen(" libraryFileName ") failed", libraryFileName, maxVersion, ##__VA_ARGS__) -# define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \ + #define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \ symbolMapping = (__typeof__(&symbolName)) dlsym(library, #symbolName); \ if (symbolMapping == NULL) \ return returnValue; -# define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ + #define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue); -# define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \ + #define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \ __auto_type ff##symbolName = (__typeof__(&symbolName)) dlsym(library, #symbolName); -# define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \ + #define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \ __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed"); -# define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \ + #define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, returnValue); -# define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \ + #define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, "dlsym " #symbolName " failed"); -# define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \ + #define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff##symbolName, symbolName, returnValue); void* ffLibraryLoad(const char* path, int maxVersion, ...); #else -# define FF_LIBRARY_EXTENSION "" + #define FF_LIBRARY_EXTENSION "" -# define FF_LIBRARY_SYMBOL(symbolName) \ + #define FF_LIBRARY_SYMBOL(symbolName) \ __typeof__(&symbolName) ff##symbolName; -# define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ + #define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ FF_A_UNUSED void* libraryObjectName = NULL; // Placeholder -# define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \ + #define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \ FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__) -# define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \ + #define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \ symbolMapping = (__typeof__(&symbolName)) &symbolName; -# define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ + #define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue); -# define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \ + #define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \ FF_A_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName; -# define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \ + #define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \ FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed"); -# define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \ + #define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, returnValue); -# define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \ + #define FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(library, varName, symbolName) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, "dlsym " #symbolName " failed"); -# define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \ + #define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff##symbolName, symbolName, returnValue); #endif diff --git a/src/common/mallocHelper.h b/src/common/mallocHelper.h index d35fe210b..5b24df471 100644 --- a/src/common/mallocHelper.h +++ b/src/common/mallocHelper.h @@ -4,13 +4,13 @@ #include #if FF_HAVE_MALLOC_USABLE_SIZE || FF_HAVE_MSVC_MSIZE -# if __has_include() -# include -# else -# include // For DragonFly BSD -# endif + #if __has_include() + #include + #else + #include // For DragonFly BSD + #endif #elif FF_HAVE_MALLOC_SIZE -# include + #include #endif static inline void ffWrapFree(const void* pPtr) { diff --git a/src/common/netif.h b/src/common/netif.h index b79c47807..d3984df42 100644 --- a/src/common/netif.h +++ b/src/common/netif.h @@ -3,8 +3,8 @@ #include "fastfetch.h" #ifndef _WIN32 -# include -# include + #include + #include #endif typedef enum FF_A_PACKED FFNetifDefaultRouteResultStatus { diff --git a/src/common/networking.h b/src/common/networking.h index d4efb62ca..2554e2231 100644 --- a/src/common/networking.h +++ b/src/common/networking.h @@ -4,7 +4,7 @@ #include "common/FFstrbuf.h" #ifdef _WIN32 -# include + #include #endif struct addrinfo; @@ -17,9 +17,9 @@ typedef struct FFNetworkingState { int sockfd; struct addrinfo* addr; -# ifdef FF_HAVE_THREADS + #ifdef FF_HAVE_THREADS FFThreadType thread; -# endif + #endif #endif FFstrbuf command; diff --git a/src/common/processing.h b/src/common/processing.h index 5c347675a..51105c8ba 100644 --- a/src/common/processing.h +++ b/src/common/processing.h @@ -3,7 +3,7 @@ #include "common/FFstrbuf.h" #ifndef _WIN32 -# include // pid_t + #include // pid_t #endif typedef struct FFProcessHandle { diff --git a/src/common/thread.h b/src/common/thread.h index 8af7c0790..64d8478d9 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -3,12 +3,12 @@ #include "fastfetch.h" #ifdef FF_HAVE_THREADS -# if defined(_WIN32) -# include -# include -# include -# include -# define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT + #if defined(_WIN32) + #include + #include + #include + #include + #define FF_THREAD_MUTEX_INITIALIZER SRWLOCK_INIT typedef SRWLOCK FFThreadMutex; typedef HANDLE FFThreadType; static inline void ffThreadMutexLock(FFThreadMutex* mutex) { @@ -20,12 +20,12 @@ static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { static inline FFThreadType ffThreadCreate(unsigned(__stdcall* func)(void*), void* data) { return (FFThreadType) _beginthreadex(NULL, 0, func, data, 0, NULL); } -# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \ + #define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \ static __stdcall unsigned fn##ThreadMain(void* data) { \ fn((paramType) data); \ return 0; \ } -# define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \ + #define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \ static __stdcall unsigned fn##ThreadMain() { \ fn(); \ return 0; \ @@ -42,16 +42,16 @@ static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout) { NtClose(thread); return true; } -# else -# include -# include -# if FF_HAVE_PTHREAD_NP -# include -# endif + #else + #include + #include + #if FF_HAVE_PTHREAD_NP + #include + #endif typedef pthread_t FFThreadType; -# if __APPLE__ -# include -# define FF_THREAD_MUTEX_INITIALIZER OS_UNFAIR_LOCK_INIT + #if __APPLE__ + #include + #define FF_THREAD_MUTEX_INITIALIZER OS_UNFAIR_LOCK_INIT typedef os_unfair_lock FFThreadMutex; static inline void ffThreadMutexLock(os_unfair_lock* mutex) { os_unfair_lock_lock(mutex); @@ -59,8 +59,8 @@ static inline void ffThreadMutexLock(os_unfair_lock* mutex) { static inline void ffThreadMutexUnlock(os_unfair_lock* mutex) { os_unfair_lock_unlock(mutex); } -# else -# define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER + #else + #define FF_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER typedef pthread_mutex_t FFThreadMutex; static inline void ffThreadMutexLock(FFThreadMutex* mutex) { pthread_mutex_lock(mutex); @@ -68,18 +68,18 @@ static inline void ffThreadMutexLock(FFThreadMutex* mutex) { static inline void ffThreadMutexUnlock(FFThreadMutex* mutex) { pthread_mutex_unlock(mutex); } -# endif + #endif static inline FFThreadType ffThreadCreate(void* (*func)(void*), void* data) { FFThreadType newThread = 0; pthread_create(&newThread, NULL, func, data); return newThread; } -# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \ + #define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) \ static void* fn##ThreadMain(void* data) { \ fn((paramType) data); \ return NULL; \ } -# define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \ + #define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) \ static void* fn##ThreadMain() { \ fn(); \ return NULL; \ @@ -88,7 +88,7 @@ static inline void ffThreadDetach(FFThreadType thread) { pthread_detach(thread); } static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeout) { -# if HAVE_TIMEDJOIN_NP + #if HAVE_TIMEDJOIN_NP if (timeout > 0) { struct timespec ts; if (clock_gettime(CLOCK_REALTIME, &ts) == 0) { @@ -101,15 +101,15 @@ static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeou return true; } } -# endif + #endif pthread_join(thread, NULL); return true; } -# endif + #endif #else // FF_HAVE_THREADS -# define FF_THREAD_MUTEX_INITIALIZER 0 + #define FF_THREAD_MUTEX_INITIALIZER 0 typedef char FFThreadMutex; static inline void ffThreadMutexLock(FF_A_UNUSED FFThreadMutex* mutex) {} static inline void ffThreadMutexUnlock(FF_A_UNUSED FFThreadMutex* mutex) {} -# define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) + #define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) #endif // FF_HAVE_THREADS diff --git a/src/common/time.h b/src/common/time.h index 97c5c269e..23529fe79 100644 --- a/src/common/time.h +++ b/src/common/time.h @@ -4,11 +4,11 @@ #include #include #ifdef _WIN32 -# include -# include "common/windows/nt.h" -# include + #include + #include "common/windows/nt.h" + #include #elif defined(__HAIKU__) -# include + #include #endif #include "common/arrayUtils.h" diff --git a/src/common/wcwidth.h b/src/common/wcwidth.h index 9f65aab47..af00837af 100644 --- a/src/common/wcwidth.h +++ b/src/common/wcwidth.h @@ -3,7 +3,7 @@ #include #ifdef FF_HAVE_WCWIDTH -# include + #include // Should be char32_t but it's not defined on macOS static_assert(sizeof(wchar_t) == sizeof(uint32_t), "wcwidth implementation requires wchar_t to be 32 bits"); diff --git a/src/common/windows/com.hpp b/src/common/windows/com.hpp index 977233e10..16bb1ac71 100644 --- a/src/common/windows/com.hpp +++ b/src/common/windows/com.hpp @@ -2,7 +2,7 @@ #ifdef __cplusplus -# include + #include const char* ffInitCom(void); @@ -13,9 +13,9 @@ static inline void ffReleaseComObject(void* ppUnknown) { } } -# define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject) + #define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject) #else -// Win32 COM headers requires C++ compiler -# error Must be included in C++ source file + // Win32 COM headers requires C++ compiler + #error Must be included in C++ source file #endif diff --git a/src/common/windows/nt.h b/src/common/windows/nt.h index 38f2f3f37..1c2d08269 100644 --- a/src/common/windows/nt.h +++ b/src/common/windows/nt.h @@ -63,7 +63,7 @@ typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX { } PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX; #ifndef NtCurrentProcess -# define NtCurrentProcess() ((HANDLE) (LONG_PTR) - 1) + #define NtCurrentProcess() ((HANDLE) (LONG_PTR) - 1) #endif typedef struct _CURDIR { diff --git a/src/common/windows/registry.h b/src/common/windows/registry.h index 14910057b..974537241 100644 --- a/src/common/windows/registry.h +++ b/src/common/windows/registry.h @@ -5,14 +5,14 @@ #include "common/io.h" #ifndef HKEY_CURRENT_USER -# define HKEY_CLASSES_ROOT ((HKEY) (ULONG_PTR) ((LONG) 0x80000000)) -# define HKEY_CURRENT_USER ((HKEY) (ULONG_PTR) ((LONG) 0x80000001)) -# define HKEY_LOCAL_MACHINE ((HKEY) (ULONG_PTR) ((LONG) 0x80000002)) -# define HKEY_USERS ((HKEY) (ULONG_PTR) ((LONG) 0x80000003)) -# define HKEY_PERFORMANCE_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000004)) -# define HKEY_CURRENT_CONFIG ((HKEY) (ULONG_PTR) ((LONG) 0x80000005)) -# define HKEY_DYN_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000006)) -# define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY) (ULONG_PTR) ((LONG) 0x80000007)) + #define HKEY_CLASSES_ROOT ((HKEY) (ULONG_PTR) ((LONG) 0x80000000)) + #define HKEY_CURRENT_USER ((HKEY) (ULONG_PTR) ((LONG) 0x80000001)) + #define HKEY_LOCAL_MACHINE ((HKEY) (ULONG_PTR) ((LONG) 0x80000002)) + #define HKEY_USERS ((HKEY) (ULONG_PTR) ((LONG) 0x80000003)) + #define HKEY_PERFORMANCE_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000004)) + #define HKEY_CURRENT_CONFIG ((HKEY) (ULONG_PTR) ((LONG) 0x80000005)) + #define HKEY_DYN_DATA ((HKEY) (ULONG_PTR) ((LONG) 0x80000006)) + #define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY) (ULONG_PTR) ((LONG) 0x80000007)) #endif typedef struct FFRegValueArg { diff --git a/src/common/windows/unicode.hpp b/src/common/windows/unicode.hpp index b2b534dbe..f9c355aa6 100644 --- a/src/common/windows/unicode.hpp +++ b/src/common/windows/unicode.hpp @@ -3,10 +3,10 @@ #ifdef __cplusplus extern "C" { -# include "unicode.h" + #include "unicode.h" } -# include + #include static inline void ffStrbufInitWSV(FFstrbuf* result, const std::wstring_view source) { return ffStrbufInitNWS(result, (uint32_t) source.size(), source.data()); @@ -22,6 +22,6 @@ static inline void ffStrbufSetWSV(FFstrbuf* result, const std::wstring_view sour #else -# error Must be included in C++ source file + #error Must be included in C++ source file #endif diff --git a/src/common/windows/wmi.hpp b/src/common/windows/wmi.hpp index d620ab927..47334f78e 100644 --- a/src/common/windows/wmi.hpp +++ b/src/common/windows/wmi.hpp @@ -3,13 +3,13 @@ #ifdef __cplusplus extern "C" { -# include "fastfetch.h" + #include "fastfetch.h" } -# include -# include + #include + #include -# include "variant.hpp" + #include "variant.hpp" enum class FFWmiNamespace { CIMV2, @@ -92,6 +92,6 @@ struct FFWmiQuery { }; #else -// Win32 COM headers requires C++ compiler -# error Must be included in C++ source file + // Win32 COM headers requires C++ compiler + #error Must be included in C++ source file #endif //__cplusplus diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index 868519e3c..42b7674a4 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -2,21 +2,21 @@ #include "common/smbios.h" #ifdef _WIN32 -# include "common/windows/registry.h" + #include "common/windows/registry.h" -# include -# include "common/windows/nt.h" + #include + #include "common/windows/nt.h" #elif __OpenBSD__ -# include "common/io.h" + #include "common/io.h" -# include -# include + #include + #include #elif __sun -# include -# include + #include + #include #elif __APPLE__ -# include "common/apple/cf_helpers.h" -# include + #include "common/apple/cf_helpers.h" + #include #endif typedef struct FFSmbiosBios { diff --git a/src/detection/bluetooth/bluetooth_linux.c b/src/detection/bluetooth/bluetooth_linux.c index 79ac59c7b..a5adfcf70 100644 --- a/src/detection/bluetooth/bluetooth_linux.c +++ b/src/detection/bluetooth/bluetooth_linux.c @@ -2,8 +2,8 @@ #include "common/stringUtils.h" #ifdef FF_HAVE_DBUS -# include "common/dbus.h" -# include "common/io.h" + #include "common/dbus.h" + #include "common/io.h" /* Example dbus reply, striped to only the relevant parts: array [ //root diff --git a/src/detection/bluetoothradio/bluetoothradio_linux.c b/src/detection/bluetoothradio/bluetoothradio_linux.c index faedfe721..0e545f0d4 100644 --- a/src/detection/bluetoothradio/bluetoothradio_linux.c +++ b/src/detection/bluetoothradio/bluetoothradio_linux.c @@ -2,8 +2,8 @@ #include "common/stringUtils.h" #ifdef FF_HAVE_DBUS -# include "common/dbus.h" -# include "common/io.h" + #include "common/dbus.h" + #include "common/io.h" /* Example dbus reply: array [ diff --git a/src/detection/bootmgr/bootmgr_bsd.c b/src/detection/bootmgr/bootmgr_bsd.c index 47fad6de3..cfaa41d26 100644 --- a/src/detection/bootmgr/bootmgr_bsd.c +++ b/src/detection/bootmgr/bootmgr_bsd.c @@ -3,9 +3,9 @@ #include "common/io.h" #ifdef __OpenBSD__ -# include + #include #else -# include + #include #endif #include #include @@ -16,7 +16,7 @@ typedef uint16_t efi_char; #endif #ifndef EFI_GLOBAL_VARIABLE -# define EFI_GLOBAL_VARIABLE { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } } + #define EFI_GLOBAL_VARIABLE { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } } #endif const char* ffDetectBootmgr(FFBootmgrResult* result) { diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index f7ffb6b5e..39f173b6b 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -14,10 +14,10 @@ extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) FF_A_ extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) FF_A_WEAK_IMPORT; extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) FF_A_WEAK_IMPORT; #else -// DDC/CI (Intel) -# include -# include -# include + // DDC/CI (Intel) + #include + #include + #include extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service) FF_A_WEAK_IMPORT; #endif diff --git a/src/detection/brightness/brightness_bsd.c b/src/detection/brightness/brightness_bsd.c index 818737159..525bb1c5a 100644 --- a/src/detection/brightness/brightness_bsd.c +++ b/src/detection/brightness/brightness_bsd.c @@ -2,12 +2,12 @@ #if __has_include() -# include "common/io.h" + #include "common/io.h" -# include -# include -# include -# include + #include + #include + #include + #include const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { // https://man.freebsd.org/cgi/man.cgi?query=backlight&sektion=9 diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 2bbf7fbc6..876d8fbda 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -78,19 +78,19 @@ static const char* detectWithBacklight(FFlist* result) { } #ifdef FF_HAVE_DDCUTIL -# include "detection/displayserver/displayserver.h" -# include "common/library.h" -# include "common/mallocHelper.h" + #include "detection/displayserver/displayserver.h" + #include "common/library.h" + #include "common/mallocHelper.h" -# include -# include + #include + #include -// Try to be compatible with ddcutil 2.0 -# if DDCUTIL_VMAJOR >= 2 + // Try to be compatible with ddcutil 2.0 + #if DDCUTIL_VMAJOR >= 2 double ddca_set_default_sleep_multiplier(double multiplier); // ddcutil 1.4 -# else + #else DDCA_Status ddca_init(const char* libopts, int syslog_level, int opts); -# endif + #endif static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { FF_LIBRARY_LOAD_MESSAGE(libddcutil, "libddcutil" FF_LIBRARY_EXTENSION, 5); @@ -100,7 +100,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_free_any_vcp_value) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_close_display) -# ifndef FF_DISABLE_DLOPEN + #ifndef FF_DISABLE_DLOPEN FF_LIBRARY_LOAD_SYMBOL_LAZY(libddcutil, ddca_init) if (ffddca_init) { FF_SUPPRESS_IO(); @@ -116,15 +116,15 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl libddcutil = NULL; // Don't dlclose libddcutil. See https://github.com/rockowitz/ddcutil/issues/330 } -# else -# if DDCUTIL_VMAJOR >= 2 + #else + #if DDCUTIL_VMAJOR >= 2 if (ddca_init(NULL, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0) { return "ddca_init() failed"; } -# else + #else ddca_set_default_sleep_multiplier(options->ddcciSleep / 40.0); -# endif -# endif + #endif + #endif FF_AUTO_FREE DDCA_Display_Info_List* infoList = NULL; if (ffddca_get_display_info_list2(false, &infoList) < 0) { diff --git a/src/detection/camera/camera_linux.c b/src/detection/camera/camera_linux.c index 71b446111..2fea2b4b2 100644 --- a/src/detection/camera/camera_linux.c +++ b/src/detection/camera/camera_linux.c @@ -6,10 +6,10 @@ #include #if FF_HAVE_LINUX_VIDEODEV2 -# include + #include #elif __has_include() // OpenBSD -# include -# define FF_HAVE_LINUX_VIDEODEV2 1 + #include + #define FF_HAVE_LINUX_VIDEODEV2 1 #endif const char* ffDetectCamera(FFlist* result) { diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index 456b4a947..aadcdc452 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -80,7 +80,7 @@ const char* ffCPUQualcommCodeToName(uint32_t code) { #if defined(__x86_64__) || defined(__i386__) -# include + #include void ffCPUDetectByCpuid(FFCPUResult* cpu) { uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0; @@ -150,9 +150,9 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) { // https://en.wikipedia.org/wiki/AArch64#ARM-A_(application_architecture) // Worth noting: Apple M1 is marked as ARMv8.5-A on Wikipedia, but it lacks BTI (mandatory in v8.5) -# ifdef __linux__ -# include "common/io.h" -# include + #ifdef __linux__ + #include "common/io.h" + #include // #include void ffCPUDetectByCpuid(FFCPUResult* cpu) { @@ -286,8 +286,8 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) { } } } -# elif __APPLE__ -# include + #elif __APPLE__ + #include // #include // Not available in macOS 14- void ffCPUDetectByCpuid(FFCPUResult* cpu) { @@ -298,8 +298,8 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) { return; } -// Helper macro to test bit in 80-bit capability mask -# define FF_HAS_CAP(bit) \ + // Helper macro to test bit in 80-bit capability mask + #define FF_HAS_CAP(bit) \ (((bit) < 64) ? ((caps[0] >> (bit)) & 1ULL) : ((caps[1] >> ((bit) - 64U)) & 1ULL)) cpu->march = "unknown"; @@ -397,39 +397,39 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) { } } -# undef HAS_CAP + #undef HAS_CAP } -# elif _WIN32 -# include + #elif _WIN32 + #include -// Missing from winnt.h of MinGW-w64 -# define PF_ARM_LSE2_AVAILABLE 62 -# define PF_RESERVED_FEATURE 63 -# define PF_ARM_SHA3_INSTRUCTIONS_AVAILABLE 64 -# define PF_ARM_SHA512_INSTRUCTIONS_AVAILABLE 65 -# define PF_ARM_V82_I8MM_INSTRUCTIONS_AVAILABLE 66 -# define PF_ARM_V82_FP16_INSTRUCTIONS_AVAILABLE 67 -# define PF_ARM_V86_BF16_INSTRUCTIONS_AVAILABLE 68 -# define PF_ARM_V86_EBF16_INSTRUCTIONS_AVAILABLE 69 -# define PF_ARM_SME_INSTRUCTIONS_AVAILABLE 70 -# define PF_ARM_SME2_INSTRUCTIONS_AVAILABLE 71 -# define PF_ARM_SME2_1_INSTRUCTIONS_AVAILABLE 72 -# define PF_ARM_SME2_2_INSTRUCTIONS_AVAILABLE 73 -# define PF_ARM_SME_AES_INSTRUCTIONS_AVAILABLE 74 -# define PF_ARM_SME_SBITPERM_INSTRUCTIONS_AVAILABLE 75 -# define PF_ARM_SME_SF8MM4_INSTRUCTIONS_AVAILABLE 76 -# define PF_ARM_SME_SF8MM8_INSTRUCTIONS_AVAILABLE 77 -# define PF_ARM_SME_SF8DP2_INSTRUCTIONS_AVAILABLE 78 -# define PF_ARM_SME_SF8DP4_INSTRUCTIONS_AVAILABLE 79 -# define PF_ARM_SME_SF8FMA_INSTRUCTIONS_AVAILABLE 80 -# define PF_ARM_SME_F8F32_INSTRUCTIONS_AVAILABLE 81 -# define PF_ARM_SME_F8F16_INSTRUCTIONS_AVAILABLE 82 -# define PF_ARM_SME_F16F16_INSTRUCTIONS_AVAILABLE 83 -# define PF_ARM_SME_B16B16_INSTRUCTIONS_AVAILABLE 84 -# define PF_ARM_SME_F64F64_INSTRUCTIONS_AVAILABLE 85 -# define PF_ARM_SME_I16I64_INSTRUCTIONS_AVAILABLE 86 -# define PF_ARM_SME_LUTv2_INSTRUCTIONS_AVAILABLE 87 -# define PF_ARM_SME_FA64_INSTRUCTIONS_AVAILABLE 88 + // Missing from winnt.h of MinGW-w64 + #define PF_ARM_LSE2_AVAILABLE 62 + #define PF_RESERVED_FEATURE 63 + #define PF_ARM_SHA3_INSTRUCTIONS_AVAILABLE 64 + #define PF_ARM_SHA512_INSTRUCTIONS_AVAILABLE 65 + #define PF_ARM_V82_I8MM_INSTRUCTIONS_AVAILABLE 66 + #define PF_ARM_V82_FP16_INSTRUCTIONS_AVAILABLE 67 + #define PF_ARM_V86_BF16_INSTRUCTIONS_AVAILABLE 68 + #define PF_ARM_V86_EBF16_INSTRUCTIONS_AVAILABLE 69 + #define PF_ARM_SME_INSTRUCTIONS_AVAILABLE 70 + #define PF_ARM_SME2_INSTRUCTIONS_AVAILABLE 71 + #define PF_ARM_SME2_1_INSTRUCTIONS_AVAILABLE 72 + #define PF_ARM_SME2_2_INSTRUCTIONS_AVAILABLE 73 + #define PF_ARM_SME_AES_INSTRUCTIONS_AVAILABLE 74 + #define PF_ARM_SME_SBITPERM_INSTRUCTIONS_AVAILABLE 75 + #define PF_ARM_SME_SF8MM4_INSTRUCTIONS_AVAILABLE 76 + #define PF_ARM_SME_SF8MM8_INSTRUCTIONS_AVAILABLE 77 + #define PF_ARM_SME_SF8DP2_INSTRUCTIONS_AVAILABLE 78 + #define PF_ARM_SME_SF8DP4_INSTRUCTIONS_AVAILABLE 79 + #define PF_ARM_SME_SF8FMA_INSTRUCTIONS_AVAILABLE 80 + #define PF_ARM_SME_F8F32_INSTRUCTIONS_AVAILABLE 81 + #define PF_ARM_SME_F8F16_INSTRUCTIONS_AVAILABLE 82 + #define PF_ARM_SME_F16F16_INSTRUCTIONS_AVAILABLE 83 + #define PF_ARM_SME_B16B16_INSTRUCTIONS_AVAILABLE 84 + #define PF_ARM_SME_F64F64_INSTRUCTIONS_AVAILABLE 85 + #define PF_ARM_SME_I16I64_INSTRUCTIONS_AVAILABLE 86 + #define PF_ARM_SME_LUTv2_INSTRUCTIONS_AVAILABLE 87 + #define PF_ARM_SME_FA64_INSTRUCTIONS_AVAILABLE 88 void ffCPUDetectByCpuid(FFCPUResult* cpu) { // ARMv8-A @@ -504,11 +504,11 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) { } } } -# else + #else void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) { // Unsupported system } -# endif + #endif #else diff --git a/src/detection/cpu/cpu_apple.c b/src/detection/cpu/cpu_apple.c index d51501838..30b71568a 100644 --- a/src/detection/cpu/cpu_apple.c +++ b/src/detection/cpu/cpu_apple.c @@ -41,9 +41,9 @@ static double detectCpuTemp(const FFCPUOptions* options, const FFstrbuf* cpuName } #ifdef __aarch64__ -# include "common/apple/cf_helpers.h" + #include "common/apple/cf_helpers.h" -# include + #include static const char* detectFrequency(FFCPUResult* cpu) { // https://github.com/giampaolo/psutil/pull/2222/files diff --git a/src/detection/cpu/cpu_bsd.c b/src/detection/cpu/cpu_bsd.c index 58ee80361..838e95dd7 100644 --- a/src/detection/cpu/cpu_bsd.c +++ b/src/detection/cpu/cpu_bsd.c @@ -4,8 +4,8 @@ #include #if __has_include() -# include -# define FF_HAVE_CPUSET 1 + #include + #define FF_HAVE_CPUSET 1 #endif static const char* detectCpuTemp(const FFCPUOptions* options, double* current) { diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index cdd502473..da73a207c 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -204,7 +204,7 @@ static void detectNumaNodes(FFCPUResult* cpu) { } #ifdef __ANDROID__ -# include "common/settings.h" + #include "common/settings.h" static void detectQualcomm(FFCPUResult* cpu) { // https://en.wikipedia.org/wiki/List_of_Qualcomm_Snapdragon_systems_on_chips @@ -452,7 +452,7 @@ static void detectAndroid(FFCPUResult* cpu) { #endif #if __arm__ || __aarch64__ -# include "cpu_arm.h" + #include "cpu_arm.h" static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId) { char* line = NULL; @@ -925,7 +925,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) { if (false) { } -# if __aarch64__ + #if __aarch64__ else if (ffStrEquals(vendor, "apple")) { // https://elixir.bootlin.com/linux/v6.11/source/arch/arm64/boot/dts/apple if (model[0] == 't') { @@ -942,7 +942,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) { ffStrbufSetStatic(&cpu->vendor, "Apple"); } -# endif + #endif else if (ffStrEquals(vendor, "qcom")) { // https://elixir.bootlin.com/linux/v6.11/source/arch/arm64/boot/dts/qcom if (ffStrStartsWith(model, "x")) { @@ -982,7 +982,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) { } } -# ifdef __loongarch__ + #ifdef __loongarch__ FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) { const char* p = cpuinfo->chars; uint64_t low = 0, high = 0; @@ -1002,17 +1002,17 @@ FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high)); } -# endif + #endif FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) { cpu->coresLogical = (uint16_t) get_nprocs_conf(); cpu->coresOnline = (uint16_t) get_nprocs(); -# if __ANDROID__ + #if __ANDROID__ detectAndroid(cpu); -# elif !__powerpc__ && !__powerpc + #elif !__powerpc__ && !__powerpc detectSocName(cpu); -# endif + #endif detectFrequency(cpu, options); @@ -1036,14 +1036,14 @@ FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCP cpu->frequencyBase = (uint32_t) ffStrbufToUInt(&cpuMHz, 0); } -# if __arm__ || __aarch64__ + #if __arm__ || __aarch64__ uint32_t cpuImplementer = (uint32_t) strtoul(cpuImplementerStr.chars, NULL, 16); ffStrbufSetStatic(&cpu->vendor, hwImplId2Vendor(cpuImplementer)); if (cpu->name.length == 0) { detectArmName(&cpuinfo, cpu, cpuImplementer); } -# elif __riscv__ || __riscv + #elif __riscv__ || __riscv if (cpu->name.length == 0) { if (cpuUarch.length > 0) { if (cpu->name.length > 0) { @@ -1060,17 +1060,17 @@ FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCP ffStrbufAppend(&cpu->name, &cpuIsa); } } -# elif __loongarch__ + #elif __loongarch__ cpu->packages = getLoongarchPropCount(&cpuinfo, "\npackage\t\t\t:"); cpu->coresPhysical = getLoongarchPropCount(&cpuinfo, "\ncore\t\t\t:"); if (cpu->packages > 1) { cpu->coresPhysical *= cpu->packages; } -# elif __s390x__ + #elif __s390x__ if (cpu->name.length) { ffStrbufPrependS(&cpu->name, "Machine "); } -# endif + #endif } if (cpu->coresPhysical == 0) { diff --git a/src/detection/cpuusage/cpuusage_bsd.c b/src/detection/cpuusage/cpuusage_bsd.c index 6989380b1..f690d15d4 100644 --- a/src/detection/cpuusage/cpuusage_bsd.c +++ b/src/detection/cpuusage/cpuusage_bsd.c @@ -7,17 +7,17 @@ #include #if __OpenBSD__ || __NetBSD__ -# include + #include #endif const char* ffGetCpuUsageInfo(FFlist* cpuTimes) { size_t neededLength = 0; #if __OpenBSD__ || __NetBSD__ -# ifdef KERN_CPTIME + #ifdef KERN_CPTIME int ctls[] = { CTL_KERN, KERN_CPTIME }; -# else + #else int ctls[] = { CTL_KERN, KERN_CP_TIME }; -# endif + #endif if (sysctl(ctls, 2, NULL, &neededLength, NULL, 0) != 0) { return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed"; } diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c index 285c03892..3e05886a5 100644 --- a/src/detection/de/de_linux.c +++ b/src/detection/de/de_linux.c @@ -12,14 +12,14 @@ #include #ifdef __FreeBSD__ -# include -# ifndef _PATH_LOCALBASE -# define _PATH_LOCALBASE "/usr/local" -# endif + #include + #ifndef _PATH_LOCALBASE + #define _PATH_LOCALBASE "/usr/local" + #endif #elif __OpenBSD__ -# define _PATH_LOCALBASE "/usr/local" + #define _PATH_LOCALBASE "/usr/local" #elif __NetBSD__ -# define _PATH_LOCALBASE "/usr/pkg" + #define _PATH_LOCALBASE "/usr/pkg" #endif static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { diff --git a/src/detection/disk/disk.c b/src/detection/disk/disk.c index 78f82084b..c86282d63 100644 --- a/src/detection/disk/disk.c +++ b/src/detection/disk/disk.c @@ -31,7 +31,7 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks) { } #ifndef _WIN32 -# include + #include bool ffDiskMatchesFolderPatterns(FFstrbuf* folders, const char* path, char separator) { uint32_t startIndex = 0; diff --git a/src/detection/disk/disk.h b/src/detection/disk/disk.h index f8754001f..57aaf2f22 100644 --- a/src/detection/disk/disk.h +++ b/src/detection/disk/disk.h @@ -4,9 +4,9 @@ #include "modules/disk/option.h" #ifdef _WIN32 -# define FF_DISK_FOLDER_SEPARATOR ';' + #define FF_DISK_FOLDER_SEPARATOR ';' #else -# define FF_DISK_FOLDER_SEPARATOR ':' + #define FF_DISK_FOLDER_SEPARATOR ':' #endif typedef struct FFDisk { diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index 438a01ceb..6e0475f84 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -7,16 +7,16 @@ #include #ifdef __NetBSD__ -# include -# include -# define statfs statvfs -# define f_flags f_flag -# define f_bsize f_frsize + #include + #include + #define statfs statvfs + #define f_flags f_flag + #define f_bsize f_frsize #endif #ifdef __FreeBSD__ -# if __has_include() -# include + #if __has_include() + #include static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) { if (!ffStrStartsWith(fs->f_mntfromname, "/dev/")) { @@ -53,11 +53,11 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) { return NULL; } -# else + #else static const char* detectFsLabel(FF_A_UNUSED struct statfs* fs, FF_A_UNUSED FFDisk* disk) { return "Fastfetch was compiled without libgeom support"; } -# endif + #endif static void detectFsInfo(struct statfs* fs, FFDisk* disk) { if (ffStrbufEqualS(&disk->filesystem, "zfs")) { @@ -75,14 +75,14 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) { detectFsLabel(fs, disk); } #elif __APPLE__ -# include "common/apple/cf_helpers.h" + #include "common/apple/cf_helpers.h" -# include -# include + #include + #include -# ifndef MAC_OS_X_VERSION_10_15 -# define MNT_REMOVABLE 0x00000200 -# endif + #ifndef MAC_OS_X_VERSION_10_15 + #define MNT_REMOVABLE 0x00000200 + #endif struct CmnAttrBuf { uint32_t length; @@ -112,11 +112,11 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk) { } #else static void detectFsInfo(struct statfs* fs, FFDisk* disk) { -# ifdef MNT_IGNORE + #ifdef MNT_IGNORE if (fs->f_flags & MNT_IGNORE) { disk->type = FF_DISK_VOLUME_TYPE_HIDDEN_BIT; } else -# endif + #endif if (!(fs->f_flags & MNT_LOCAL)) { disk->type = FF_DISK_VOLUME_TYPE_EXTERNAL_BIT; } else { @@ -200,7 +200,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) { } #ifdef __OpenBSD__ -# define st_birthtimespec __st_birthtim + #define st_birthtimespec __st_birthtim #endif #ifndef __DragonFly__ struct stat st; diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 7dcf6ecee..a14a7561c 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -11,14 +11,14 @@ #include #if defined(STATX_BTIME) && !defined(__ANDROID__) -# include + #include #endif #ifdef __USE_LARGEFILE64 -# define stat stat64 -# define statvfs statvfs64 -# define dirent dirent64 -# define readdir readdir64 + #define stat stat64 + #define statvfs statvfs64 + #define dirent dirent64 + #define readdir readdir64 #endif static bool isPhysicalDevice(const struct mntent* device) { diff --git a/src/detection/diskio/diskio_bsd.c b/src/detection/diskio/diskio_bsd.c index ffca1235b..b945b6114 100644 --- a/src/detection/diskio/diskio_bsd.c +++ b/src/detection/diskio/diskio_bsd.c @@ -2,14 +2,14 @@ #if __has_include() -# include "common/stringUtils.h" + #include "common/stringUtils.h" -# include -# include -# include -# include -# include -# include + #include + #include + #include + #include + #include + #include const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { FF_A_CLEANUP(geom_deletetree) struct gmesh geomTree = {}; @@ -74,8 +74,8 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { #else -# include -# include + #include + #include const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { if (checkversion() < 0) { diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index cca5f9408..a4cb809aa 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -15,7 +15,7 @@ extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display) FF extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display) FF_A_WEAK_IMPORT; extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) FF_A_WEAK_IMPORT; #else -# include + #include #endif static void detectDisplays(FFDisplayServerResult* ds) { diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index c4aef1404..174aeb37c 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -3,7 +3,7 @@ #include "common/stringUtils.h" #ifdef __FreeBSD__ -# include "common/settings.h" + #include "common/settings.h" #endif static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) { diff --git a/src/detection/displayserver/linux/drm.c b/src/detection/displayserver/linux/drm.c index bee0a003b..8d970bee2 100644 --- a/src/detection/displayserver/linux/drm.c +++ b/src/detection/displayserver/linux/drm.c @@ -4,7 +4,7 @@ #include "common/stringUtils.h" #ifdef __linux__ -# include + #include static const char* drmParseSysfs(FFDisplayServerResult* result) { const char* drmDirPath = "/sys/class/drm/"; @@ -107,11 +107,11 @@ static const char* drmParseSysfs(FFDisplayServerResult* result) { #ifdef FF_HAVE_DRM -# include "common/library.h" + #include "common/library.h" -# include -# include -# include + #include + #include + #include // https://gitlab.freedesktop.org/mesa/drm/-/blob/main/xf86drmMode.c#L1785 // It's not supported on Ubuntu 20.04 @@ -242,14 +242,14 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { const char* path = dev->nodes[DRM_NODE_PRIMARY]; -# if __linux__ + #if __linux__ ffStrbufSetF(&name, "/sys/class/drm/%s/device/power/runtime_status", strrchr(path, '/') + 1); char buffer[8] = ""; if (ffReadFileData(name.chars, strlen("suspend"), buffer) > 0 && ffStrStartsWith(buffer, "suspend")) { continue; } -# endif + #endif FF_AUTO_CLOSE_FD int primaryFd = open(path, O_RDWR | O_CLOEXEC); if (primaryFd < 0) { @@ -356,7 +356,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { ffdrmModeFreeProperty(prop); } -# if __linux__ + #if __linux__ if (name.length == 0) { uint8_t edidData[512]; ssize_t edidLength = 0; @@ -367,7 +367,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { ffEdidGetSerialAndManufactureDate(edidData, &serial, &myear, &mweak); } } -# endif + #endif if (name.length == 0) { const char* connectorTypeName = drmType2Name(conn->connector_type); diff --git a/src/detection/displayserver/linux/wayland/global-output.c b/src/detection/displayserver/linux/wayland/global-output.c index 38b2a01d6..50c4577d3 100644 --- a/src/detection/displayserver/linux/wayland/global-output.c +++ b/src/detection/displayserver/linux/wayland/global-output.c @@ -1,8 +1,8 @@ #ifdef FF_HAVE_WAYLAND -# include "wayland.h" -# include "common/stringUtils.h" -# include "xdg-output-unstable-v1-client-protocol.h" + #include "wayland.h" + #include "common/stringUtils.h" + #include "xdg-output-unstable-v1-client-protocol.h" static void waylandOutputModeListener(void* data, FF_A_UNUSED struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) { WaylandDisplay* display = data; diff --git a/src/detection/displayserver/linux/wayland/kde-output-device-v2-client-protocol.h b/src/detection/displayserver/linux/wayland/kde-output-device-v2-client-protocol.h index 1b47d38af..cc6db8ed8 100644 --- a/src/detection/displayserver/linux/wayland/kde-output-device-v2-client-protocol.h +++ b/src/detection/displayserver/linux/wayland/kde-output-device-v2-client-protocol.h @@ -34,7 +34,7 @@ struct kde_output_device_registry_v2; struct kde_output_device_v2; #ifndef KDE_OUTPUT_DEVICE_REGISTRY_V2_INTERFACE -# define KDE_OUTPUT_DEVICE_REGISTRY_V2_INTERFACE + #define KDE_OUTPUT_DEVICE_REGISTRY_V2_INTERFACE /** * @page page_iface_kde_output_device_registry_v2 kde_output_device_registry_v2 * @section page_iface_kde_output_device_registry_v2_desc Description @@ -57,7 +57,7 @@ struct kde_output_device_v2; extern const struct wl_interface kde_output_device_registry_v2_interface; #endif #ifndef KDE_OUTPUT_DEVICE_V2_INTERFACE -# define KDE_OUTPUT_DEVICE_V2_INTERFACE + #define KDE_OUTPUT_DEVICE_V2_INTERFACE /** * @page page_iface_kde_output_device_v2 kde_output_device_v2 * @section page_iface_kde_output_device_v2_desc Description @@ -114,7 +114,7 @@ extern const struct wl_interface kde_output_device_registry_v2_interface; extern const struct wl_interface kde_output_device_v2_interface; #endif #ifndef KDE_OUTPUT_DEVICE_MODE_V2_INTERFACE -# define KDE_OUTPUT_DEVICE_MODE_V2_INTERFACE + #define KDE_OUTPUT_DEVICE_MODE_V2_INTERFACE /** * @page page_iface_kde_output_device_mode_v2 kde_output_device_mode_v2 * @section page_iface_kde_output_device_mode_v2_desc Description @@ -146,7 +146,7 @@ extern const struct wl_interface kde_output_device_mode_v2_interface; #endif #ifndef KDE_OUTPUT_DEVICE_REGISTRY_V2_ERROR_ENUM -# define KDE_OUTPUT_DEVICE_REGISTRY_V2_ERROR_ENUM + #define KDE_OUTPUT_DEVICE_REGISTRY_V2_ERROR_ENUM /** * @ingroup iface_kde_output_device_registry_v2 * kde_output_device_registry_v2 error values @@ -256,7 +256,7 @@ kde_output_device_registry_v2_destroy(struct kde_output_device_registry_v2* kde_ // } #ifndef KDE_OUTPUT_DEVICE_V2_SUBPIXEL_ENUM -# define KDE_OUTPUT_DEVICE_V2_SUBPIXEL_ENUM + #define KDE_OUTPUT_DEVICE_V2_SUBPIXEL_ENUM /** * @ingroup iface_kde_output_device_v2 * subpixel geometry information @@ -275,7 +275,7 @@ enum kde_output_device_v2_subpixel { #endif /* KDE_OUTPUT_DEVICE_V2_SUBPIXEL_ENUM */ #ifndef KDE_OUTPUT_DEVICE_V2_TRANSFORM_ENUM -# define KDE_OUTPUT_DEVICE_V2_TRANSFORM_ENUM + #define KDE_OUTPUT_DEVICE_V2_TRANSFORM_ENUM /** * @ingroup iface_kde_output_device_v2 * transform from framebuffer to output @@ -304,7 +304,7 @@ enum kde_output_device_v2_transform { #endif /* KDE_OUTPUT_DEVICE_V2_TRANSFORM_ENUM */ #ifndef KDE_OUTPUT_DEVICE_V2_CAPABILITY_ENUM -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_ENUM + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_ENUM /** * @ingroup iface_kde_output_device_v2 * describes capabilities of the outputdevice @@ -384,58 +384,58 @@ enum kde_output_device_v2_capability { */ KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_BRIGHTNESS = 0x4000, }; -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_HIGH_DYNAMIC_RANGE_SINCE_VERSION 3 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_WIDE_COLOR_GAMUT_SINCE_VERSION 3 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_ROTATE_SINCE_VERSION 4 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_ICC_PROFILE_SINCE_VERSION 5 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_BRIGHTNESS_SINCE_VERSION 9 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_BUILT_IN_COLOR_SINCE_VERSION 12 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_DDC_CI_SINCE_VERSION 14 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_MAX_BITS_PER_COLOR_SINCE_VERSION 15 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_EDR_SINCE_VERSION 16 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_SHARPNESS_SINCE_VERSION 17 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_CUSTOM_MODES_SINCE_VERSION 18 -/** - * @ingroup iface_kde_output_device_v2 - */ -# define KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_BRIGHTNESS_SINCE_VERSION 19 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_HIGH_DYNAMIC_RANGE_SINCE_VERSION 3 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_WIDE_COLOR_GAMUT_SINCE_VERSION 3 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_ROTATE_SINCE_VERSION 4 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_ICC_PROFILE_SINCE_VERSION 5 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_BRIGHTNESS_SINCE_VERSION 9 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_BUILT_IN_COLOR_SINCE_VERSION 12 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_DDC_CI_SINCE_VERSION 14 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_MAX_BITS_PER_COLOR_SINCE_VERSION 15 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_EDR_SINCE_VERSION 16 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_SHARPNESS_SINCE_VERSION 17 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_CUSTOM_MODES_SINCE_VERSION 18 + /** + * @ingroup iface_kde_output_device_v2 + */ + #define KDE_OUTPUT_DEVICE_V2_CAPABILITY_AUTO_BRIGHTNESS_SINCE_VERSION 19 #endif /* KDE_OUTPUT_DEVICE_V2_CAPABILITY_ENUM */ #ifndef KDE_OUTPUT_DEVICE_V2_VRR_POLICY_ENUM -# define KDE_OUTPUT_DEVICE_V2_VRR_POLICY_ENUM + #define KDE_OUTPUT_DEVICE_V2_VRR_POLICY_ENUM /** * @ingroup iface_kde_output_device_v2 * describes vrr policy @@ -450,7 +450,7 @@ enum kde_output_device_v2_vrr_policy { #endif /* KDE_OUTPUT_DEVICE_V2_VRR_POLICY_ENUM */ #ifndef KDE_OUTPUT_DEVICE_V2_RGB_RANGE_ENUM -# define KDE_OUTPUT_DEVICE_V2_RGB_RANGE_ENUM + #define KDE_OUTPUT_DEVICE_V2_RGB_RANGE_ENUM /** * @ingroup iface_kde_output_device_v2 * describes RGB range policy @@ -465,7 +465,7 @@ enum kde_output_device_v2_rgb_range { #endif /* KDE_OUTPUT_DEVICE_V2_RGB_RANGE_ENUM */ #ifndef KDE_OUTPUT_DEVICE_V2_AUTO_ROTATE_POLICY_ENUM -# define KDE_OUTPUT_DEVICE_V2_AUTO_ROTATE_POLICY_ENUM + #define KDE_OUTPUT_DEVICE_V2_AUTO_ROTATE_POLICY_ENUM /** * @ingroup iface_kde_output_device_v2 * describes when auto rotate should be used @@ -478,7 +478,7 @@ enum kde_output_device_v2_auto_rotate_policy { #endif /* KDE_OUTPUT_DEVICE_V2_AUTO_ROTATE_POLICY_ENUM */ #ifndef KDE_OUTPUT_DEVICE_V2_COLOR_PROFILE_SOURCE_ENUM -# define KDE_OUTPUT_DEVICE_V2_COLOR_PROFILE_SOURCE_ENUM + #define KDE_OUTPUT_DEVICE_V2_COLOR_PROFILE_SOURCE_ENUM /** * @ingroup iface_kde_output_device_v2 * which source the compositor should use for the color profile on an output @@ -491,7 +491,7 @@ enum kde_output_device_v2_color_profile_source { #endif /* KDE_OUTPUT_DEVICE_V2_COLOR_PROFILE_SOURCE_ENUM */ #ifndef KDE_OUTPUT_DEVICE_V2_COLOR_POWER_TRADEOFF_ENUM -# define KDE_OUTPUT_DEVICE_V2_COLOR_POWER_TRADEOFF_ENUM + #define KDE_OUTPUT_DEVICE_V2_COLOR_POWER_TRADEOFF_ENUM /** * @ingroup iface_kde_output_device_v2 * tradeoff between power and accuracy @@ -514,7 +514,7 @@ enum kde_output_device_v2_color_power_tradeoff { #endif /* KDE_OUTPUT_DEVICE_V2_COLOR_POWER_TRADEOFF_ENUM */ #ifndef KDE_OUTPUT_DEVICE_V2_EDR_POLICY_ENUM -# define KDE_OUTPUT_DEVICE_V2_EDR_POLICY_ENUM + #define KDE_OUTPUT_DEVICE_V2_EDR_POLICY_ENUM /** * @ingroup iface_kde_output_device_v2 * when the compositor may make use of EDR @@ -1190,7 +1190,7 @@ kde_output_device_v2_destroy(struct kde_output_device_v2* kde_output_device_v2) // } #ifndef KDE_OUTPUT_DEVICE_MODE_V2_FLAGS_ENUM -# define KDE_OUTPUT_DEVICE_MODE_V2_FLAGS_ENUM + #define KDE_OUTPUT_DEVICE_MODE_V2_FLAGS_ENUM /** * @ingroup iface_kde_output_device_mode_v2 * mode flags diff --git a/src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c b/src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c index 7d15867f7..bcafaf152 100644 --- a/src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c +++ b/src/detection/displayserver/linux/wayland/kde-output-device-v2-protocol.c @@ -12,10 +12,10 @@ * SPDX-License-Identifier: MIT-CMU */ -# include -# include -# include -# include + #include + #include + #include + #include extern const struct wl_interface kde_output_device_mode_v2_interface; extern const struct wl_interface kde_output_device_v2_interface; diff --git a/src/detection/displayserver/linux/wayland/kde-output-order-v1-client-protocol.h b/src/detection/displayserver/linux/wayland/kde-output-order-v1-client-protocol.h index 2b6fe9875..b9928c3fe 100644 --- a/src/detection/displayserver/linux/wayland/kde-output-order-v1-client-protocol.h +++ b/src/detection/displayserver/linux/wayland/kde-output-order-v1-client-protocol.h @@ -26,7 +26,7 @@ extern "C" { struct kde_output_order_v1; #ifndef KDE_OUTPUT_ORDER_V1_INTERFACE -# define KDE_OUTPUT_ORDER_V1_INTERFACE + #define KDE_OUTPUT_ORDER_V1_INTERFACE /** * @page page_iface_kde_output_order_v1 kde_output_order_v1 * @section page_iface_kde_output_order_v1_desc Description diff --git a/src/detection/displayserver/linux/wayland/kde-output-order-v1-protocol.c b/src/detection/displayserver/linux/wayland/kde-output-order-v1-protocol.c index 378d7546f..00db32af5 100644 --- a/src/detection/displayserver/linux/wayland/kde-output-order-v1-protocol.c +++ b/src/detection/displayserver/linux/wayland/kde-output-order-v1-protocol.c @@ -8,9 +8,9 @@ * SPDX-License-Identifier: MIT-CMU */ -# include -# include -# include "wayland-util.h" + #include + #include + #include "wayland-util.h" static const struct wl_interface* kde_output_order_v1_types[] = { NULL, diff --git a/src/detection/displayserver/linux/wayland/kde-output.c b/src/detection/displayserver/linux/wayland/kde-output.c index 8d502c45c..26be57e60 100644 --- a/src/detection/displayserver/linux/wayland/kde-output.c +++ b/src/detection/displayserver/linux/wayland/kde-output.c @@ -1,10 +1,10 @@ #ifdef FF_HAVE_WAYLAND -# include "wayland.h" -# include "kde-output-device-v2-client-protocol.h" -# include "kde-output-order-v1-client-protocol.h" -# include "common/edidHelper.h" -# include "common/base64.h" + #include "wayland.h" + #include "kde-output-device-v2-client-protocol.h" + #include "kde-output-order-v1-client-protocol.h" + #include "common/edidHelper.h" + #include "common/base64.h" typedef struct WaylandKdeMode { int32_t width; diff --git a/src/detection/displayserver/linux/wayland/wayland.c b/src/detection/displayserver/linux/wayland/wayland.c index 6e22539ab..91b7d4069 100644 --- a/src/detection/displayserver/linux/wayland/wayland.c +++ b/src/detection/displayserver/linux/wayland/wayland.c @@ -8,26 +8,26 @@ #ifdef FF_HAVE_WAYLAND -# include + #include -# include "common/properties.h" + #include "common/properties.h" -# include "wayland.h" -# include "wlr-output-management-unstable-v1-client-protocol.h" -# include "kde-output-device-v2-client-protocol.h" -# include "kde-output-order-v1-client-protocol.h" -# include "xdg-output-unstable-v1-client-protocol.h" + #include "wayland.h" + #include "wlr-output-management-unstable-v1-client-protocol.h" + #include "kde-output-device-v2-client-protocol.h" + #include "kde-output-order-v1-client-protocol.h" + #include "xdg-output-unstable-v1-client-protocol.h" -# if __FreeBSD__ -# include -# include -# include -# endif + #if __FreeBSD__ + #include + #include + #include + #endif static bool waylandDetectWM(int fd, FFDisplayServerResult* result) { -# if __linux__ || __GNU__ || (__FreeBSD__ && !__DragonFly__) + #if __linux__ || __GNU__ || (__FreeBSD__ && !__DragonFly__) -# if __linux__ || __GNU__ + #if __linux__ || __GNU__ struct ucred ucred = {}; socklen_t len = sizeof(ucred); if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1 || ucred.pid <= 0) { @@ -39,7 +39,7 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) { if (!ffReadFileBuffer(procPath.chars, &result->wmProcessName)) { return false; } -# else + #else struct xucred ucred = {}; socklen_t len = sizeof(ucred); if (getsockopt(fd, AF_UNSPEC, LOCAL_PEERCRED, &ucred, &len) == -1 || ucred.cr_pid <= 0) { @@ -53,7 +53,7 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) { return false; } result->wmProcessName.length = (uint32_t) size - 1; -# endif + #endif // #1135: wl-restart is a special case const char* filename = strrchr(result->wmProcessName.chars, '/'); @@ -72,10 +72,10 @@ static bool waylandDetectWM(int fd, FFDisplayServerResult* result) { return true; -# else + #else FF_UNUSED(fd, result); return false; -# endif + #endif } static void waylandGlobalAddListener(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) { @@ -148,11 +148,11 @@ void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const cha } display->type = ffdsGetDisplayType(name); -# if __linux__ + #if __linux__ if (!display->edidName.length) { matchDrmConnector(name, display); } -# endif + #endif display->id = ffWaylandGenerateIdFromName(name); ffStrbufAppendS(&display->name, name); } diff --git a/src/detection/displayserver/linux/wayland/wayland.h b/src/detection/displayserver/linux/wayland/wayland.h index b7ea76d2b..ac0a1d386 100644 --- a/src/detection/displayserver/linux/wayland/wayland.h +++ b/src/detection/displayserver/linux/wayland/wayland.h @@ -2,12 +2,12 @@ #ifdef FF_HAVE_WAYLAND -# include "common/library.h" -# include "common/stringUtils.h" + #include "common/library.h" + #include "common/stringUtils.h" -# include + #include -# include "../displayserver_linux.h" + #include "../displayserver_linux.h" typedef enum FF_A_PACKED WaylandProtocolType { FF_WAYLAND_PROTOCOL_TYPE_NONE, diff --git a/src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-client-protocol.h b/src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-client-protocol.h index da3a25430..2b0584d75 100644 --- a/src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-client-protocol.h +++ b/src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-client-protocol.h @@ -69,7 +69,7 @@ struct zwlr_output_manager_v1; struct zwlr_output_mode_v1; #ifndef ZWLR_OUTPUT_MANAGER_V1_INTERFACE -# define ZWLR_OUTPUT_MANAGER_V1_INTERFACE + #define ZWLR_OUTPUT_MANAGER_V1_INTERFACE /** * @page page_iface_zwlr_output_manager_v1 zwlr_output_manager_v1 * @section page_iface_zwlr_output_manager_v1_desc Description @@ -138,7 +138,7 @@ struct zwlr_output_mode_v1; extern const struct wl_interface zwlr_output_manager_v1_interface; #endif #ifndef ZWLR_OUTPUT_HEAD_V1_INTERFACE -# define ZWLR_OUTPUT_HEAD_V1_INTERFACE + #define ZWLR_OUTPUT_HEAD_V1_INTERFACE /** * @page page_iface_zwlr_output_head_v1 zwlr_output_head_v1 * @section page_iface_zwlr_output_head_v1_desc Description @@ -179,7 +179,7 @@ extern const struct wl_interface zwlr_output_manager_v1_interface; extern const struct wl_interface zwlr_output_head_v1_interface; #endif #ifndef ZWLR_OUTPUT_MODE_V1_INTERFACE -# define ZWLR_OUTPUT_MODE_V1_INTERFACE + #define ZWLR_OUTPUT_MODE_V1_INTERFACE /** * @page page_iface_zwlr_output_mode_v1 zwlr_output_mode_v1 * @section page_iface_zwlr_output_mode_v1_desc Description @@ -210,7 +210,7 @@ extern const struct wl_interface zwlr_output_head_v1_interface; extern const struct wl_interface zwlr_output_mode_v1_interface; #endif #ifndef ZWLR_OUTPUT_CONFIGURATION_V1_INTERFACE -# define ZWLR_OUTPUT_CONFIGURATION_V1_INTERFACE + #define ZWLR_OUTPUT_CONFIGURATION_V1_INTERFACE /** * @page page_iface_zwlr_output_configuration_v1 zwlr_output_configuration_v1 * @section page_iface_zwlr_output_configuration_v1_desc Description @@ -245,7 +245,7 @@ extern const struct wl_interface zwlr_output_mode_v1_interface; extern const struct wl_interface zwlr_output_configuration_v1_interface; #endif #ifndef ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_INTERFACE -# define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_INTERFACE + #define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_INTERFACE /** * @page page_iface_zwlr_output_configuration_head_v1 zwlr_output_configuration_head_v1 * @section page_iface_zwlr_output_configuration_head_v1_desc Description @@ -408,7 +408,7 @@ zwlr_output_manager_v1_destroy(struct zwlr_output_manager_v1* zwlr_output_manage // } #ifndef ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENUM -# define ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENUM + #define ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENUM enum zwlr_output_head_v1_adaptive_sync_state { /** * adaptive sync is disabled @@ -896,7 +896,7 @@ zwlr_output_mode_v1_destroy(struct zwlr_output_mode_v1* zwlr_output_mode_v1) { // } #ifndef ZWLR_OUTPUT_CONFIGURATION_V1_ERROR_ENUM -# define ZWLR_OUTPUT_CONFIGURATION_V1_ERROR_ENUM + #define ZWLR_OUTPUT_CONFIGURATION_V1_ERROR_ENUM enum zwlr_output_configuration_v1_error { /** * head has been configured twice @@ -1119,7 +1119,7 @@ zwlr_output_configuration_v1_get_version(struct zwlr_output_configuration_v1* zw // } #ifndef ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ENUM -# define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ENUM + #define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ENUM enum zwlr_output_configuration_head_v1_error { /** * property has already been set @@ -1147,10 +1147,10 @@ enum zwlr_output_configuration_head_v1_error { */ ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_INVALID_ADAPTIVE_SYNC_STATE = 6, }; -/** - * @ingroup iface_zwlr_output_configuration_head_v1 - */ -# define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_INVALID_ADAPTIVE_SYNC_STATE_SINCE_VERSION 4 + /** + * @ingroup iface_zwlr_output_configuration_head_v1 + */ + #define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_INVALID_ADAPTIVE_SYNC_STATE_SINCE_VERSION 4 #endif /* ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_ERROR_ENUM */ #define ZWLR_OUTPUT_CONFIGURATION_HEAD_V1_SET_MODE 0 diff --git a/src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c b/src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c index 0f183f18e..a231fd481 100644 --- a/src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c +++ b/src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c @@ -27,20 +27,20 @@ * THIS SOFTWARE. */ -# include -# include -# include -# include + #include + #include + #include + #include -# ifndef __has_attribute -# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ -# endif + #ifndef __has_attribute + #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ + #endif -# if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) -# define WL_PRIVATE __attribute__((visibility("hidden"))) -# else -# define WL_PRIVATE -# endif + #if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) + #define WL_PRIVATE __attribute__((visibility("hidden"))) + #else + #define WL_PRIVATE + #endif extern const struct wl_interface zwlr_output_configuration_head_v1_interface; extern const struct wl_interface zwlr_output_configuration_v1_interface; diff --git a/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-client-protocol.h b/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-client-protocol.h index 3edaa641b..51784c6c1 100644 --- a/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-client-protocol.h +++ b/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-client-protocol.h @@ -78,7 +78,7 @@ struct zxdg_output_manager_v1; struct zxdg_output_v1; #ifndef ZXDG_OUTPUT_MANAGER_V1_INTERFACE -# define ZXDG_OUTPUT_MANAGER_V1_INTERFACE + #define ZXDG_OUTPUT_MANAGER_V1_INTERFACE /** * @page page_iface_zxdg_output_manager_v1 zxdg_output_manager_v1 * @section page_iface_zxdg_output_manager_v1_desc Description @@ -95,7 +95,7 @@ struct zxdg_output_v1; extern const struct wl_interface zxdg_output_manager_v1_interface; #endif #ifndef ZXDG_OUTPUT_V1_INTERFACE -# define ZXDG_OUTPUT_V1_INTERFACE + #define ZXDG_OUTPUT_V1_INTERFACE /** * @page page_iface_zxdg_output_v1 zxdg_output_v1 * @section page_iface_zxdg_output_v1_desc Description diff --git a/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c b/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c index dde8b15ea..76f62575d 100644 --- a/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c +++ b/src/detection/displayserver/linux/wayland/xdg-output-unstable-v1-protocol.c @@ -24,9 +24,9 @@ * DEALINGS IN THE SOFTWARE. */ -# include -# include -# include + #include + #include + #include extern const struct wl_interface wl_output_interface; extern const struct wl_interface zxdg_output_v1_interface; diff --git a/src/detection/displayserver/linux/wayland/zwlr-output.c b/src/detection/displayserver/linux/wayland/zwlr-output.c index 9521dff94..1caae8454 100644 --- a/src/detection/displayserver/linux/wayland/zwlr-output.c +++ b/src/detection/displayserver/linux/wayland/zwlr-output.c @@ -1,7 +1,7 @@ #ifdef FF_HAVE_WAYLAND -# include "wayland.h" -# include "wlr-output-management-unstable-v1-client-protocol.h" + #include "wayland.h" + #include "wlr-output-management-unstable-v1-client-protocol.h" static void waylandZwlrTransformListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t transform) { WaylandDisplay* wldata = (WaylandDisplay*) data; diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 0afb33aa8..d4ccf0801 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -9,18 +9,18 @@ #include #if __FreeBSD__ -# include -# include -# include + #include + #include + #include #elif __OpenBSD__ -# include -# include -# include + #include + #include + #include #elif __sun -# include + #include #elif __NetBSD__ -# include -# include + #include + #include #endif static const char* parseEnv(void) { @@ -273,9 +273,9 @@ static const char* getFromProcesses(FFDisplayServerResult* result) { uint32_t userId = instance.state.platform.uid; #if __FreeBSD__ -# ifdef __DragonFly__ -# define ki_comm kp_comm -# endif + #ifdef __DragonFly__ + #define ki_comm kp_comm + #endif int request[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, (int) userId }; size_t length = 0; diff --git a/src/detection/displayserver/linux/xcb.c b/src/detection/displayserver/linux/xcb.c index 7fbbb204a..e6b5cd07c 100644 --- a/src/detection/displayserver/linux/xcb.c +++ b/src/detection/displayserver/linux/xcb.c @@ -2,16 +2,16 @@ #ifdef FF_HAVE_XCB_RANDR -# include "common/library.h" -# include "common/properties.h" -# include "common/edidHelper.h" -# include "common/mallocHelper.h" -# include "common/stringUtils.h" + #include "common/library.h" + #include "common/properties.h" + #include "common/edidHelper.h" + #include "common/mallocHelper.h" + #include "common/stringUtils.h" -# include -# include -# include -# include + #include + #include + #include + #include typedef struct XcbRandrData { FF_LIBRARY_SYMBOL(xcb_randr_get_screen_resources_current) diff --git a/src/detection/displayserver/linux/xlib.c b/src/detection/displayserver/linux/xlib.c index bc69329a7..c97308fe8 100644 --- a/src/detection/displayserver/linux/xlib.c +++ b/src/detection/displayserver/linux/xlib.c @@ -2,13 +2,13 @@ #ifdef FF_HAVE_XRANDR -# include "common/library.h" -# include "common/properties.h" -# include "common/edidHelper.h" -# include "common/stringUtils.h" + #include "common/library.h" + #include "common/properties.h" + #include "common/edidHelper.h" + #include "common/stringUtils.h" -# include -# include + #include + #include typedef struct XrandrData { FF_LIBRARY_SYMBOL(XInternAtom) diff --git a/src/detection/dns/dns_linux.c b/src/detection/dns/dns_linux.c index ecdb5f1c2..9f1a4429b 100644 --- a/src/detection/dns/dns_linux.c +++ b/src/detection/dns/dns_linux.c @@ -6,9 +6,9 @@ #include "common/debug.h" #ifdef __HAIKU__ -# define RESOLV_CONF "/system/settings/network/resolv.conf" + #define RESOLV_CONF "/system/settings/network/resolv.conf" #else -# define RESOLV_CONF "/etc/resolv.conf" + #define RESOLV_CONF "/etc/resolv.conf" #endif static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FFlist* results) { diff --git a/src/detection/gamepad/gamepad_bsd.c b/src/detection/gamepad/gamepad_bsd.c index 99addca76..b67b8fd2d 100644 --- a/src/detection/gamepad/gamepad_bsd.c +++ b/src/detection/gamepad/gamepad_bsd.c @@ -6,9 +6,9 @@ #include #if __has_include() -# include // FreeBSD + #include // FreeBSD #else -# include // DragonFly + #include // DragonFly #endif #define MAX_UHID_JOYS 64 diff --git a/src/detection/gpu/d3dkmthk.h b/src/detection/gpu/d3dkmthk.h index cdc0a7592..da0087bae 100644 --- a/src/detection/gpu/d3dkmthk.h +++ b/src/detection/gpu/d3dkmthk.h @@ -6,12 +6,12 @@ #include #if _WIN32 -# include -# include + #include + #include #else -# include -# include -# include + #include + #include + #include typedef struct _LUID { uint32_t LowPart; @@ -40,8 +40,8 @@ typedef union { int64_t QuadPart; } LARGE_INTEGER; typedef int32_t NTSTATUS; // 0 for success, -1 for failure -# define NT_SUCCESS(Status) ((NTSTATUS) (Status) >= 0) -# define _In_range_(low, hi) + #define NT_SUCCESS(Status) ((NTSTATUS) (Status) >= 0) + #define _In_range_(low, hi) #endif #define D3DKMT_ALIGN64 alignas(8) @@ -330,12 +330,12 @@ EXTERN_C _Check_return_ NTSTATUS APIENTRY D3DKMTQueryStatistics(_In_ CONST D3DKM #else -// Ref: https://github.com/microsoft/WSL2-Linux-Kernel/blob/linux-msft-wsl-6.6.y/include/uapi/misc/d3dkmthk.h -# define LX_DXOPENADAPTERFROMLUID _IOWR(0x47, 0x01, D3DKMT_OPENADAPTERFROMLUID) -# define LX_DXQUERYADAPTERINFO _IOWR(0x47, 0x09, D3DKMT_QUERYADAPTERINFO) -# define LX_DXENUMADAPTERS2 _IOWR(0x47, 0x14, D3DKMT_ENUMADAPTERS2) -# define LX_DXCLOSEADAPTER _IOWR(0x47, 0x15, D3DKMT_CLOSEADAPTER) -# define LX_DXQUERYSTATISTICS _IOWR(0x47, 0x43, D3DKMT_QUERYSTATISTICS) + // Ref: https://github.com/microsoft/WSL2-Linux-Kernel/blob/linux-msft-wsl-6.6.y/include/uapi/misc/d3dkmthk.h + #define LX_DXOPENADAPTERFROMLUID _IOWR(0x47, 0x01, D3DKMT_OPENADAPTERFROMLUID) + #define LX_DXQUERYADAPTERINFO _IOWR(0x47, 0x09, D3DKMT_QUERYADAPTERINFO) + #define LX_DXENUMADAPTERS2 _IOWR(0x47, 0x14, D3DKMT_ENUMADAPTERS2) + #define LX_DXCLOSEADAPTER _IOWR(0x47, 0x15, D3DKMT_CLOSEADAPTER) + #define LX_DXQUERYSTATISTICS _IOWR(0x47, 0x43, D3DKMT_QUERYSTATISTICS) extern int dxgfd; // File descriptor for /dev/dxg, initialized in gpu_wsl.c diff --git a/src/detection/gpu/gpu.h b/src/detection/gpu/gpu.h index 8692d5e4b..dab2f44ce 100644 --- a/src/detection/gpu/gpu.h +++ b/src/detection/gpu/gpu.h @@ -66,14 +66,14 @@ typedef struct FFGpuDriverPciBusId { void ffGPUFillVendorAndName(uint8_t subclass, uint16_t vendor, uint16_t device, FFGPUResult* gpu); void ffGPUQueryAmdGpuName(uint16_t deviceId, uint8_t revisionId, FFGPUResult* gpu); -# if FF_HAVE_DRM + #if FF_HAVE_DRM const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath); const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath); const char* ffDrmDetectI915(FFGPUResult* gpu, int fd); const char* ffDrmDetectXe(FFGPUResult* gpu, int fd); const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd); const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd); -# endif // FF_HAVE_DRM + #endif // FF_HAVE_DRM const char* ffGPUDetectDriverSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFGpuDriverPciBusId pciBusId); #endif // defined(XXX) diff --git a/src/detection/gpu/gpu_apple.c b/src/detection/gpu/gpu_apple.c index dec6770b0..3b8de206f 100644 --- a/src/detection/gpu/gpu_apple.c +++ b/src/detection/gpu/gpu_apple.c @@ -48,9 +48,9 @@ static double detectGpuTemp(const FFstrbuf* gpuName) { } #ifdef __aarch64__ -# include "common/apple/cf_helpers.h" + #include "common/apple/cf_helpers.h" -# include + #include static const char* detectFrequency(FFGPUResult* gpu) { // https://github.com/giampaolo/psutil/pull/2222/files diff --git a/src/detection/gpu/gpu_bsd.c b/src/detection/gpu/gpu_bsd.c index 6957346bd..0d8ca02f6 100644 --- a/src/detection/gpu/gpu_bsd.c +++ b/src/detection/gpu/gpu_bsd.c @@ -6,9 +6,9 @@ #include #include #if __has_include() -# include // FreeBSD + #include // FreeBSD #else -# include // DragonFly + #include // DragonFly #endif static void fillGPUTypeGeneric(FFGPUResult* gpu) { @@ -31,10 +31,10 @@ static void fillGPUTypeGeneric(FFGPUResult* gpu) { } #if FF_HAVE_DRM -# include "common/library.h" -# include "common/stringUtils.h" + #include "common/library.h" + #include "common/stringUtils.h" -# include + #include static const char* detectByDrm(const FFGPUOptions* options, FFlist* gpus) { FF_LIBRARY_LOAD_MESSAGE(libdrm, "libdrm" FF_LIBRARY_EXTENSION, 2) diff --git a/src/detection/gpu/gpu_driver_specific.h b/src/detection/gpu/gpu_driver_specific.h index 995744238..3ddfb69b7 100644 --- a/src/detection/gpu/gpu_driver_specific.h +++ b/src/detection/gpu/gpu_driver_specific.h @@ -44,7 +44,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName); #ifndef FF_GPU_DRIVER_DLLNAME_PATH_PREFIX -# define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX + #define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX #endif FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) { @@ -66,18 +66,18 @@ FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, #ifdef _WIN32 else if (vendor == FF_GPU_VENDOR_NAME_INTEL) { *pDetectFn = ffDetectIntelGpuInfo; -# ifdef _WIN64 + #ifdef _WIN64 *pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "ControlLib.dll"; -# else + #else *pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "ControlLib32.dll"; -# endif + #endif } else if (vendor == FF_GPU_VENDOR_NAME_AMD) { *pDetectFn = ffDetectAmdGpuInfo; -# ifdef _WIN64 + #ifdef _WIN64 *pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "atiadlxx.dll"; -# else + #else *pDllName = FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "atiadlxy.dll"; -# endif + #endif } #endif else { diff --git a/src/detection/gpu/gpu_drm.c b/src/detection/gpu/gpu_drm.c index 52f589030..2e077ad82 100644 --- a/src/detection/gpu/gpu_drm.c +++ b/src/detection/gpu/gpu_drm.c @@ -1,19 +1,19 @@ #include "gpu.h" #if FF_HAVE_DRM -# include -# include -# include + #include + #include + #include -# include "common/io.h" -# include "common/library.h" -# include "common/mallocHelper.h" -# include "common/stringUtils.h" + #include "common/io.h" + #include "common/library.h" + #include "common/mallocHelper.h" + #include "common/stringUtils.h" -# include "intel_drm.h" -# include "asahi_drm.h" -# include -# include + #include "intel_drm.h" + #include "asahi_drm.h" + #include + #include const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath) { FF_AUTO_CLOSE_FD int fd = open(renderPath, O_RDONLY | O_CLOEXEC); @@ -76,12 +76,12 @@ const char* ffDrmDetectRadeon(const FFGPUOptions* options, FFGPUResult* gpu, con return NULL; } -# ifdef FF_HAVE_DRM_AMDGPU -# include -# include + #ifdef FF_HAVE_DRM_AMDGPU + #include + #include const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, const char* renderPath) { -# if FF_HAVE_DRM_AMDGPU + #if FF_HAVE_DRM_AMDGPU FF_LIBRARY_LOAD_MESSAGE(libdrm, "libdrm_amdgpu" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, amdgpu_device_initialize) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, amdgpu_get_marketing_name) @@ -117,7 +117,7 @@ const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, con gpu->frequency = (uint32_t) (gpuInfo.max_engine_clk / 1000u); gpu->index = FF_GPU_INDEX_UNSET; gpu->type = gpuInfo.ids_flags & AMDGPU_IDS_FLAGS_FUSION ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE; -# define FF_VRAM_CASE(name, value) \ + #define FF_VRAM_CASE(name, value) \ case value /* AMDGPU_VRAM_TYPE_ ## name */: \ ffStrbufSetStatic(&gpu->memoryType, #name); \ break @@ -158,12 +158,12 @@ const char* ffDrmDetectAmdgpu(const FFGPUOptions* options, FFGPUResult* gpu, con ffamdgpu_device_deinitialize(handle); return NULL; -# else + #else FF_UNUSED(options, gpu, renderPath); return "Fastfetch is compiled without libdrm support"; -# endif + #endif } -# endif + #endif const char* ffDrmDetectI915(FFGPUResult* gpu, int fd) { { @@ -326,9 +326,9 @@ const char* ffDrmDetectAsahi(FFGPUResult* gpu, int fd) { return "Failed to query Asahi GPU information"; } -# ifndef DRM_IOCTL_NOUVEAU_GETPARAM -# define DRM_IOCTL_NOUVEAU_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GETPARAM, struct drm_nouveau_getparam) -# endif + #ifndef DRM_IOCTL_NOUVEAU_GETPARAM + #define DRM_IOCTL_NOUVEAU_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GETPARAM, struct drm_nouveau_getparam) + #endif const char* ffDrmDetectNouveau(FFGPUResult* gpu, int fd) { struct drm_nouveau_getparam getparam = {}; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index d636a7c96..de5093f69 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -13,26 +13,26 @@ #include #ifdef FF_HAVE_DRM_AMDGPU -# include -# include -# include + #include + #include + #include #endif #ifdef FF_HAVE_DRM -# include "intel_drm.h" -# include -# include + #include "intel_drm.h" + #include + #include #endif #if defined(FF_HAVE_DRM) && defined(__aarch64__) -// https://github.com/alyssarosenzweig/linux/blob/agx-uapi-v7/include/uapi/drm/asahi_drm.h -// Found in kernel-headers-6.14.4-400.asahi.fc42.aarch64 -# if __has_include() -# include -# else -# include "asahi_drm.h" -# endif -# define FF_HAVE_DRM_ASAHI 1 + // https://github.com/alyssarosenzweig/linux/blob/agx-uapi-v7/include/uapi/drm/asahi_drm.h + // Found in kernel-headers-6.14.4-400.asahi.fc42.aarch64 + #if __has_include() + #include + #else + #include "asahi_drm.h" + #endif + #define FF_HAVE_DRM_ASAHI 1 #endif static bool pciDetectDriver(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer, FF_A_UNUSED const char* drmKey) { @@ -108,12 +108,12 @@ static const char* drmDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult if (ffStrbufEqualS(&gpu->driver, "radeon")) { return ffDrmDetectRadeon(options, gpu, buffer->chars); } else { -# if FF_HAVE_DRM_AMDGPU + #if FF_HAVE_DRM_AMDGPU return ffDrmDetectAmdgpu(options, gpu, buffer->chars); -# else + #else FF_UNUSED(options, gpu, drmKey, buffer); return "Fastfetch is not compiled with libdrm_amdgpu support"; -# endif + #endif } #else FF_UNUSED(options, gpu, drmKey, buffer); @@ -503,14 +503,14 @@ FF_A_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const ch } ffStrbufSetStatic(&gpu->vendor, FF_GPU_VENDOR_NAME_APPLE); -# if FF_HAVE_DRM_ASAHI + #if FF_HAVE_DRM_ASAHI ffStrbufSetS(buffer, "/dev/dri/"); ffStrbufAppendS(buffer, drmKey); FF_AUTO_CLOSE_FD int fd = open(buffer->chars, O_RDONLY | O_CLOEXEC); if (fd >= 0) { return ffDrmDetectAsahi(gpu, fd); } -# endif + #endif return NULL; } diff --git a/src/detection/gpu/gpu_nvidia.c b/src/detection/gpu/gpu_nvidia.c index 9bb1be902..85776dd82 100644 --- a/src/detection/gpu/gpu_nvidia.c +++ b/src/detection/gpu/gpu_nvidia.c @@ -23,7 +23,7 @@ struct FFNvmlData { #if defined(_WIN32) && !defined(FF_DISABLE_DLOPEN) -# include "nvapi.h" + #include "nvapi.h" struct FFNvapiData { FF_LIBRARY_SYMBOL(nvapi_Unload) @@ -39,15 +39,15 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) { nvapiData.inited = true; FF_LIBRARY_LOAD_MESSAGE(libnvapi, -# ifdef _WIN64 + #ifdef _WIN64 "nvapi64.dll" -# else + #else "nvapi.dll" -# endif + #endif , 1); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvapi, nvapi_QueryInterface) -# define FF_NVAPI_INTERFACE(iName, iOffset) \ + #define FF_NVAPI_INTERFACE(iName, iOffset) \ __typeof__(&iName) ff##iName = ffnvapi_QueryInterface(iOffset); \ if (ff##iName == NULL) return "nvapi_QueryInterface " #iName " failed"; @@ -56,7 +56,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) { FF_NVAPI_INTERFACE(nvapi_EnumPhysicalGPUs, NVAPI_INTERFACE_OFFSET_ENUM_PHYSICAL_GPUS) FF_NVAPI_INTERFACE(nvapi_GPU_GetRamType, NVAPI_INTERFACE_OFFSET_GPU_GET_RAM_TYPE) FF_NVAPI_INTERFACE(nvapi_GPU_GetGPUType, NVAPI_INTERFACE_OFFSET_GPU_GET_GPU_TYPE) -# undef FF_NVAPI_INTERFACE + #undef FF_NVAPI_INTERFACE if (ffnvapi_Initialize() < 0) { return "NvAPI_Initialize() failed"; @@ -94,7 +94,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) { NvApiGPUMemoryType memType; if (result->memoryType && nvapiData.ffnvapi_GPU_GetRamType(gpuHandle, &memType) == 0) { switch (memType) { -# define FF_NVAPI_MEMORY_TYPE(type) \ + #define FF_NVAPI_MEMORY_TYPE(type) \ case NVAPI_GPU_MEMORY_TYPE_##type: \ ffStrbufSetStatic(result->memoryType, #type); \ break; @@ -115,7 +115,7 @@ static const char* detectMoreByNvapi(FFGpuDriverResult* result) { FF_NVAPI_MEMORY_TYPE(GDDR6) FF_NVAPI_MEMORY_TYPE(GDDR6X) FF_NVAPI_MEMORY_TYPE(GDDR7) -# undef FF_NVAPI_MEMORY_TYPE + #undef FF_NVAPI_MEMORY_TYPE default: ffStrbufSetF(result->memoryType, "Unknown (%d)", memType); break; @@ -236,12 +236,12 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR unsigned int value; if (nvmlData.ffnvmlDeviceGetIndex(device, &value) == NVML_SUCCESS) { *result.index = value; -# ifdef _WIN32 + #ifdef _WIN32 // Don't bother loading nvapi for GPU type detection only if (result.memoryType) { detectMoreByNvapi(&result); } -# endif + #endif } } diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index 5ae93b471..0fede273b 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -5,21 +5,21 @@ #include #ifdef __FreeBSD__ -# include -# ifndef _PATH_LOCALBASE -# define _PATH_LOCALBASE "/usr/local" -# endif + #include + #ifndef _PATH_LOCALBASE + #define _PATH_LOCALBASE "/usr/local" + #endif #elif __OpenBSD__ -# define _PATH_LOCALBASE "/usr/local" + #define _PATH_LOCALBASE "/usr/local" #elif __NetBSD__ -# define _PATH_LOCALBASE "/usr/pkg" + #define _PATH_LOCALBASE "/usr/pkg" #endif #if FF_HAVE_EMBEDDED_PCIIDS -# include "fastfetch_pciids.c.inc" + #include "fastfetch_pciids.c.inc" #endif #if FF_HAVE_EMBEDDED_AMDGPUIDS -# include "fastfetch_amdgpuids.c.inc" + #include "fastfetch_amdgpuids.c.inc" #endif #define FF_STR_INDIR(x) #x @@ -39,7 +39,7 @@ static const FFstrbuf* loadPciIds() { #else // FF_CUSTOM_PCI_IDS_PATH -# if __linux__ + #if __linux__ ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/hwdata/pci.ids", &pciids); if (pciids.length == 0) { ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/share/misc/pci.ids", &pciids); // debian? @@ -47,16 +47,16 @@ static const FFstrbuf* loadPciIds() { ffReadFileBuffer(FASTFETCH_TARGET_DIR_USR "/local/share/hwdata/pci.ids", &pciids); } } -# elif __OpenBSD__ || __FreeBSD__ || __NetBSD__ + #elif __OpenBSD__ || __FreeBSD__ || __NetBSD__ ffReadFileBuffer(_PATH_LOCALBASE "/share/hwdata/pci.ids", &pciids); if (pciids.length == 0) { ffReadFileBuffer(_PATH_LOCALBASE "/share/pciids/pci.ids", &pciids); } -# elif __sun + #elif __sun ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/usr/share/hwdata/pci.ids", &pciids); -# elif __HAIKU__ + #elif __HAIKU__ ffReadFileBuffer(FASTFETCH_TARGET_DIR_ROOT "/system/data/hwdata/pci.ids", &pciids); -# endif + #endif #endif // FF_CUSTOM_PCI_IDS_PATH diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index f0cd1d000..37968b9fd 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -1,6 +1,6 @@ #include "detection/gpu/gpu.h" #if __linux__ -# define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "/usr/lib/wsl/lib/" + #define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX "/usr/lib/wsl/lib/" #endif #include "detection/gpu/gpu_driver_specific.h" #include "common/debug.h" @@ -9,16 +9,16 @@ #include "d3dkmthk.h" #if _WIN32 -# include "common/windows/unicode.h" -# include "common/windows/registry.h" + #include "common/windows/unicode.h" + #include "common/windows/registry.h" -# if FF_WIN81_COMPAT -# include "common/mallocHelper.h" -# include -# include -# include + #if FF_WIN81_COMPAT + #include "common/mallocHelper.h" + #include + #include + #include -# define GUID_DEVCLASS_DISPLAY_STRING L"{4d36e968-e325-11ce-bfc1-08002be10318}" // Found in + #define GUID_DEVCLASS_DISPLAY_STRING L"{4d36e968-e325-11ce-bfc1-08002be10318}" // Found in static bool queryDeviceIdsFallback(D3DKMT_ADAPTERADDRESS adapterAddress, D3DKMT_DEVICE_IDS* outDeviceIds) { FF_DEBUG("KMTQAITYPE_PHYSICALADAPTERDEVICEIDS failed. Attempting queryDeviceIdsFallback: bus=%u device=%u function=%u", @@ -128,7 +128,7 @@ static bool queryDeviceIdsFallback(D3DKMT_ADAPTERADDRESS adapterAddress, D3DKMT_ FF_DEBUG("Cache miss for adapter address: bus=%u device=%u function=%u", adapterAddress.BusNumber, adapterAddress.DeviceNumber, adapterAddress.FunctionNumber); return false; } -# endif // FF_WIN81_COMPAT + #endif // FF_WIN81_COMPAT static bool queryVendorNameViaRegistry(FFstrbuf* vendor, D3DKMT_HANDLE hAdapter) { // `KMTQAITYPE_QUERY_ADAPTER_UNIQUE_GUID` reports the GUID value used by the adapter's registry key (DirectX and Video) @@ -158,10 +158,10 @@ static bool queryVendorNameViaRegistry(FFstrbuf* vendor, D3DKMT_HANDLE hAdapter) } #else -# include -# include -# include -# include + #include + #include + #include + #include int dxgfd = -2; diff --git a/src/detection/gpu/gpu_windows.cpp b/src/detection/gpu/gpu_windows.cpp index a64bad96f..ae6f00ef9 100644 --- a/src/detection/gpu/gpu_windows.cpp +++ b/src/detection/gpu/gpu_windows.cpp @@ -6,9 +6,9 @@ extern "C" { #if __has_include() && __has_include() -# include -# include -# include "common/windows/util.hpp" + #include + #include + #include "common/windows/util.hpp" static IDXCoreAdapterFactory* loadDxCoreFactory() { static bool initialized = false; @@ -23,14 +23,14 @@ static IDXCoreAdapterFactory* loadDxCoreFactory() { // DXCoreCreateAdapterFactory is a reloaded function, so we can't use FF_LIBRARY_LOAD_SYMBOL_MESSAGE here typedef HRESULT (*DXCoreCreateAdapterFactory_t)(REFIID riid, void** ppvFactory); -# ifndef FF_DISABLE_DLOPEN + #ifndef FF_DISABLE_DLOPEN auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) dlsym(dxcore, "DXCoreCreateAdapterFactory"); if (ffDXCoreCreateAdapterFactory == nullptr) { return NULL; } -# else + #else auto ffDXCoreCreateAdapterFactory = (DXCoreCreateAdapterFactory_t) DXCoreCreateAdapterFactory; -# endif + #endif HRESULT hr = ffDXCoreCreateAdapterFactory(IID_PPV_ARGS(&factory)); if (FAILED(hr)) { @@ -72,7 +72,7 @@ extern "C" const char* ffGPUDetectTypeWithDXCore(LUID adapterLuid, FFGPUResult* #else -# warning "DXCore headers not available, GPU type detection may be less accurate" + #warning "DXCore headers not available, GPU type detection may be less accurate" extern "C" const char* ffGPUDetectTypeWithDXCore(LUID adapterLuid, FFGPUResult* gpu) { FF_UNUSED(adapterLuid, gpu); diff --git a/src/detection/keyboard/keyboard_bsd.c b/src/detection/keyboard/keyboard_bsd.c index eee6d3a52..4b0ee574a 100644 --- a/src/detection/keyboard/keyboard_bsd.c +++ b/src/detection/keyboard/keyboard_bsd.c @@ -7,9 +7,9 @@ #include #if __has_include() -# include // FreeBSD + #include // FreeBSD #else -# include // DragonFly + #include // DragonFly #endif static const char* detectByIoctl(FFlist* devices) { diff --git a/src/detection/libc/libc_android.c b/src/detection/libc/libc_android.c index 5042807a6..2aec4ed20 100644 --- a/src/detection/libc/libc_android.c +++ b/src/detection/libc/libc_android.c @@ -10,11 +10,11 @@ const char* ffDetectLibc(FFLibcResult* result) { result->name = "ndk-bionic"; result->version = FF_STR(__NDK_MAJOR__) "." FF_STR(__NDK_MINOR__) "." FF_STR(__NDK_BUILD__) -# if __NDK_BETA__ + #if __NDK_BETA__ "-beta" FF_STR(__NDK_BETA__) -# elif __NDK_CANARY__ + #elif __NDK_CANARY__ "-canary" -# endif + #endif ; return NULL; diff --git a/src/detection/libc/libc_bsd.c b/src/detection/libc/libc_bsd.c index 07cd72706..bd73165c0 100644 --- a/src/detection/libc/libc_bsd.c +++ b/src/detection/libc/libc_bsd.c @@ -6,14 +6,14 @@ const char* ffDetectLibc(FFLibcResult* result) { #ifdef __DragonFly__ // We define `__FreeBSD__` on DragonFly BSD for simplification result->name = "DF"; -# ifdef FF_DF_VERSION + #ifdef FF_DF_VERSION result->version = FF_DF_VERSION; -# endif + #endif #elif __FreeBSD__ result->name = "FBSD"; -# ifdef FF_FBSD_VERSION + #ifdef FF_FBSD_VERSION result->version = FF_FBSD_VERSION; -# endif + #endif #endif return NULL; diff --git a/src/detection/libc/libc_linux.c b/src/detection/libc/libc_linux.c index e43b60e81..53186a356 100644 --- a/src/detection/libc/libc_linux.c +++ b/src/detection/libc/libc_linux.c @@ -14,11 +14,11 @@ const char* ffDetectLibc(FFLibcResult* result) { result->version = FF_STR(__GLIBC__) "." FF_STR(__GLIBC_MINOR__); #else result->name = "musl"; -# ifdef FF_MUSL_VERSION + #ifdef FF_MUSL_VERSION result->version = FF_MUSL_VERSION; -# else + #else result->version = NULL; -# endif + #endif #endif return NULL; diff --git a/src/detection/libc/libc_windows.cpp b/src/detection/libc/libc_windows.cpp index daa1d27b7..c94062a4b 100644 --- a/src/detection/libc/libc_windows.cpp +++ b/src/detection/libc/libc_windows.cpp @@ -3,7 +3,7 @@ extern "C" { } #ifdef __MINGW32__ -# include <_mingw.h> + #include <_mingw.h> #endif template diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index 9f00e1cac..140205d31 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -36,9 +36,9 @@ static const char* getSshdVersion(FFstrbuf* version) { } #ifdef FF_HAVE_ZLIB -# include "common/library.h" -# include -# include + #include "common/library.h" + #include + #include static const char* getSddmVersion(FFstrbuf* version) { FF_LIBRARY_LOAD_MESSAGE(zlib, "libz" FF_LIBRARY_EXTENSION, 2) diff --git a/src/detection/loadavg/loadavg_bsd.c b/src/detection/loadavg/loadavg_bsd.c index 9311caccb..83896b299 100644 --- a/src/detection/loadavg/loadavg_bsd.c +++ b/src/detection/loadavg/loadavg_bsd.c @@ -3,11 +3,11 @@ #include #if __FreeBSD__ || __OpenBSD__ || __NetBSD__ -# include -# include -# if __FreeBSD__ -# include -# endif + #include + #include + #if __FreeBSD__ + #include + #endif #endif const char* ffDetectLoadavg(double result[3]) { diff --git a/src/detection/localip/localip.h b/src/detection/localip/localip.h index d845d0d94..d3b9015bf 100644 --- a/src/detection/localip/localip.h +++ b/src/detection/localip/localip.h @@ -4,16 +4,16 @@ #include "modules/localip/option.h" #ifndef IN6_IS_ADDR_GLOBAL -/* Global Unicast: 2000::/3 (001...) */ -# define IN6_IS_ADDR_GLOBAL(a) (((a)->s6_addr[0] & 0xE0) == 0x20) + /* Global Unicast: 2000::/3 (001...) */ + #define IN6_IS_ADDR_GLOBAL(a) (((a)->s6_addr[0] & 0xE0) == 0x20) #endif #ifndef IN6_IS_ADDR_UNIQUE_LOCAL -/* Unique Local: fc00::/7 (1111 110...) */ -# define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] & 0xFE) == 0xFC) + /* Unique Local: fc00::/7 (1111 110...) */ + #define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] & 0xFE) == 0xFC) #endif #ifndef IN6_IS_ADDR_LINKLOCAL -/* Link-Local: fe80::/10 (1111 1110 10...) */ -# define IN6_IS_ADDR_LINKLOCAL(a) (((a)->s6_addr[0] == 0xFE) && (((a)->s6_addr[1] & 0xC0) == 0x80)) + /* Link-Local: fe80::/10 (1111 1110 10...) */ + #define IN6_IS_ADDR_LINKLOCAL(a) (((a)->s6_addr[0] == 0xFE) && (((a)->s6_addr[1] & 0xC0) == 0x80)) #endif typedef struct FFLocalIpResult { diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 2a116704e..53fe9fc56 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -16,27 +16,27 @@ #include #ifdef __linux__ -# include -# include -# include -# include + #include + #include + #include + #include #endif #if __has_include() -# include + #include #endif #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) || defined(__HAIKU__) -# include -# include + #include + #include #elif !defined(__GNU__) -# include + #include #endif #if defined(__sun) || defined(__HAIKU__) -# include + #include #endif #if defined(__sun) -# include + #include static inline void kstatFreeWrap(kstat_ctl_t** pkc) { assert(pkc); @@ -135,16 +135,16 @@ static FFLocalIpIpv6Type getIpv6Type(struct ifaddrs* ifa) { static int sockfd = 0; if (sockfd == 0) { sockfd = socket(AF_INET6, SOCK_DGRAM -# ifdef SOCK_CLOEXEC + #ifdef SOCK_CLOEXEC | SOCK_CLOEXEC -# endif + #endif , 0); -# ifndef SOCK_CLOEXEC + #ifndef SOCK_CLOEXEC if (sockfd > 0) { fcntl(sockfd, F_SETFD, FD_CLOEXEC); } -# endif + #endif } if (sockfd < 0) { return result; @@ -158,15 +158,15 @@ static FFLocalIpIpv6Type getIpv6Type(struct ifaddrs* ifa) { return result; } -# ifdef IN6_IFF_PREFER_SOURCE + #ifdef IN6_IFF_PREFER_SOURCE if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_PREFER_SOURCE) { result |= FF_LOCALIP_IPV6_TYPE_PREFERRED_BIT; } -# endif + #endif if (ifr6.ifr_ifru.ifru_flags6 & (IN6_IFF_DEPRECATED | IN6_IFF_TEMPORARY | IN6_IFF_TENTATIVE | IN6_IFF_DUPLICATED -# ifdef IN6_IFF_OPTIMISTIC + #ifdef IN6_IFF_OPTIMISTIC | IN6_IFF_OPTIMISTIC -# endif + #endif )) result |= FF_LOCALIP_IPV6_TYPE_SECONDARY_BIT; return result; @@ -519,11 +519,11 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { #if !defined(__sun) && !defined(__GNU__) if (options->showType & FF_LOCALIP_TYPE_MAC_BIT) { if (adapter->mac->ifa_addr) { -# if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ || __HAIKU__ + #if __FreeBSD__ || __OpenBSD__ || __APPLE__ || __NetBSD__ || __HAIKU__ uint8_t* ptr = (uint8_t*) LLADDR((struct sockaddr_dl*) adapter->mac->ifa_addr); -# else + #else uint8_t* ptr = ((struct sockaddr_ll*) adapter->mac->ifa_addr)->sll_addr; -# endif + #endif ffStrbufSetF(&item->mac, "%02x:%02x:%02x:%02x:%02x:%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); FF_DEBUG("Added MAC address %s for interface %s", item->mac.chars, adapter->mac->ifa_name); } else { @@ -584,379 +584,379 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { if (ioctl(sockfd, SIOCGIFMEDIA, &ifmr) == 0 && (IFM_TYPE(ifmr.ifm_active) & IFM_ETHER)) { FF_DEBUG("Interface %s media type: 0x%x", iface->name.chars, (unsigned) IFM_SUBTYPE(ifmr.ifm_active)); switch (IFM_SUBTYPE(ifmr.ifm_active)) { -# ifdef IFM_HPNA_1 + #ifdef IFM_HPNA_1 case IFM_HPNA_1: -# endif + #endif iface->speed = 1; break; -# ifdef IFM_1000_CX + #ifdef IFM_1000_CX case IFM_1000_CX: -# endif -# ifdef IFM_1000_CX_SGMII + #endif + #ifdef IFM_1000_CX_SGMII case IFM_1000_CX_SGMII: -# endif -# ifdef IFM_1000_KX + #endif + #ifdef IFM_1000_KX case IFM_1000_KX: -# endif -# ifdef IFM_1000_LX + #endif + #ifdef IFM_1000_LX case IFM_1000_LX: -# endif -# ifdef IFM_1000_SGMII + #endif + #ifdef IFM_1000_SGMII case IFM_1000_SGMII: -# endif -# ifdef IFM_1000_SX + #endif + #ifdef IFM_1000_SX case IFM_1000_SX: -# endif -# ifdef IFM_1000_T + #endif + #ifdef IFM_1000_T case IFM_1000_T: -# endif + #endif iface->speed = 1000; break; -# ifdef IFM_100G_AUI2 + #ifdef IFM_100G_AUI2 case IFM_100G_AUI2: -# endif -# ifdef IFM_100G_AUI2_AC + #endif + #ifdef IFM_100G_AUI2_AC case IFM_100G_AUI2_AC: -# endif -# ifdef IFM_100G_AUI4 + #endif + #ifdef IFM_100G_AUI4 case IFM_100G_AUI4: -# endif -# ifdef IFM_100G_AUI4_AC + #endif + #ifdef IFM_100G_AUI4_AC case IFM_100G_AUI4_AC: -# endif -# ifdef IFM_100G_CAUI2 + #endif + #ifdef IFM_100G_CAUI2 case IFM_100G_CAUI2: -# endif -# ifdef IFM_100G_CAUI2_AC + #endif + #ifdef IFM_100G_CAUI2_AC case IFM_100G_CAUI2_AC: -# endif -# ifdef IFM_100G_CAUI4 + #endif + #ifdef IFM_100G_CAUI4 case IFM_100G_CAUI4: -# endif -# ifdef IFM_100G_CAUI4_AC + #endif + #ifdef IFM_100G_CAUI4_AC case IFM_100G_CAUI4_AC: -# endif -# ifdef IFM_100G_CP2 + #endif + #ifdef IFM_100G_CP2 case IFM_100G_CP2: -# endif -# ifdef IFM_100G_CR4 + #endif + #ifdef IFM_100G_CR4 case IFM_100G_CR4: -# endif -# ifdef IFM_100G_CR_PAM4 + #endif + #ifdef IFM_100G_CR_PAM4 case IFM_100G_CR_PAM4: -# endif -# ifdef IFM_100G_DR + #endif + #ifdef IFM_100G_DR case IFM_100G_DR: -# endif -# ifdef IFM_100G_KR2_PAM4 + #endif + #ifdef IFM_100G_KR2_PAM4 case IFM_100G_KR2_PAM4: -# endif -# ifdef IFM_100G_KR4 + #endif + #ifdef IFM_100G_KR4 case IFM_100G_KR4: -# endif -# ifdef IFM_100G_KR_PAM4 + #endif + #ifdef IFM_100G_KR_PAM4 case IFM_100G_KR_PAM4: -# endif -# ifdef IFM_100G_LR4 + #endif + #ifdef IFM_100G_LR4 case IFM_100G_LR4: -# endif -# ifdef IFM_100G_SR2 + #endif + #ifdef IFM_100G_SR2 case IFM_100G_SR2: -# endif -# ifdef IFM_100G_SR4 + #endif + #ifdef IFM_100G_SR4 case IFM_100G_SR4: -# endif + #endif iface->speed = 100000; break; -# ifdef IFM_100_FX + #ifdef IFM_100_FX case IFM_100_FX: -# endif -# ifdef IFM_100_SGMII + #endif + #ifdef IFM_100_SGMII case IFM_100_SGMII: -# endif -# ifdef IFM_100_T + #endif + #ifdef IFM_100_T case IFM_100_T: -# endif -# ifdef IFM_100_T2 + #endif + #ifdef IFM_100_T2 case IFM_100_T2: -# endif -# ifdef IFM_100_T4 + #endif + #ifdef IFM_100_T4 case IFM_100_T4: -# endif -# ifdef IFM_100_TX + #endif + #ifdef IFM_100_TX case IFM_100_TX: -# endif -# ifdef IFM_100_VG + #endif + #ifdef IFM_100_VG case IFM_100_VG: -# endif + #endif iface->speed = 100; break; -# ifdef IFM_10G_AOC + #ifdef IFM_10G_AOC case IFM_10G_AOC: -# endif -# ifdef IFM_10G_CR1 + #endif + #ifdef IFM_10G_CR1 case IFM_10G_CR1: -# endif -# ifdef IFM_10G_CX4 + #endif + #ifdef IFM_10G_CX4 case IFM_10G_CX4: -# endif -# ifdef IFM_10G_ER + #endif + #ifdef IFM_10G_ER case IFM_10G_ER: -# endif -# ifdef IFM_10G_KR + #endif + #ifdef IFM_10G_KR case IFM_10G_KR: -# endif -# ifdef IFM_10G_KX4 + #endif + #ifdef IFM_10G_KX4 case IFM_10G_KX4: -# endif -# ifdef IFM_10G_LR + #endif + #ifdef IFM_10G_LR case IFM_10G_LR: -# endif -# ifdef IFM_10G_LRM + #endif + #ifdef IFM_10G_LRM case IFM_10G_LRM: -# endif -# ifdef IFM_10G_SFI + #endif + #ifdef IFM_10G_SFI case IFM_10G_SFI: -# endif -# ifdef IFM_10G_SR + #endif + #ifdef IFM_10G_SR case IFM_10G_SR: -# endif -# ifdef IFM_10G_T + #endif + #ifdef IFM_10G_T case IFM_10G_T: -# endif -# ifdef IFM_10G_TWINAX + #endif + #ifdef IFM_10G_TWINAX case IFM_10G_TWINAX: -# endif -# ifdef IFM_10G_TWINAX_LONG + #endif + #ifdef IFM_10G_TWINAX_LONG case IFM_10G_TWINAX_LONG: -# endif + #endif iface->speed = 10000; break; -# ifdef IFM_10_2 + #ifdef IFM_10_2 case IFM_10_2: -# endif -# ifdef IFM_10_5 + #endif + #ifdef IFM_10_5 case IFM_10_5: -# endif -# ifdef IFM_10_FL + #endif + #ifdef IFM_10_FL case IFM_10_FL: -# endif -# ifdef IFM_10_STP + #endif + #ifdef IFM_10_STP case IFM_10_STP: -# endif -# ifdef IFM_10_T + #endif + #ifdef IFM_10_T case IFM_10_T: -# endif + #endif iface->speed = 10; break; -# ifdef IFM_200G_AUI4 + #ifdef IFM_200G_AUI4 case IFM_200G_AUI4: -# endif -# ifdef IFM_200G_AUI4_AC + #endif + #ifdef IFM_200G_AUI4_AC case IFM_200G_AUI4_AC: -# endif -# ifdef IFM_200G_AUI8 + #endif + #ifdef IFM_200G_AUI8 case IFM_200G_AUI8: -# endif -# ifdef IFM_200G_AUI8_AC + #endif + #ifdef IFM_200G_AUI8_AC case IFM_200G_AUI8_AC: -# endif -# ifdef IFM_200G_CR4_PAM4 + #endif + #ifdef IFM_200G_CR4_PAM4 case IFM_200G_CR4_PAM4: -# endif -# ifdef IFM_200G_DR4 + #endif + #ifdef IFM_200G_DR4 case IFM_200G_DR4: -# endif -# ifdef IFM_200G_FR4 + #endif + #ifdef IFM_200G_FR4 case IFM_200G_FR4: -# endif -# ifdef IFM_200G_KR4_PAM4 + #endif + #ifdef IFM_200G_KR4_PAM4 case IFM_200G_KR4_PAM4: -# endif -# ifdef IFM_200G_LR4 + #endif + #ifdef IFM_200G_LR4 case IFM_200G_LR4: -# endif -# ifdef IFM_200G_SR4 + #endif + #ifdef IFM_200G_SR4 case IFM_200G_SR4: -# endif + #endif iface->speed = 200000; break; -# ifdef IFM_20G_KR2 + #ifdef IFM_20G_KR2 case IFM_20G_KR2: -# endif + #endif iface->speed = 20000; break; -# ifdef IFM_2500_KX + #ifdef IFM_2500_KX case IFM_2500_KX: -# endif -# ifdef IFM_2500_SX + #endif + #ifdef IFM_2500_SX case IFM_2500_SX: -# endif -# ifdef IFM_2500_T + #endif + #ifdef IFM_2500_T case IFM_2500_T: -# endif -# ifdef IFM_2500_X + #endif + #ifdef IFM_2500_X case IFM_2500_X: -# endif + #endif iface->speed = 2500; break; -# ifdef IFM_25G_ACC + #ifdef IFM_25G_ACC case IFM_25G_ACC: -# endif -# ifdef IFM_25G_AOC + #endif + #ifdef IFM_25G_AOC case IFM_25G_AOC: -# endif -# ifdef IFM_25G_AUI + #endif + #ifdef IFM_25G_AUI case IFM_25G_AUI: -# endif -# ifdef IFM_25G_CR + #endif + #ifdef IFM_25G_CR case IFM_25G_CR: -# endif -# ifdef IFM_25G_CR1 + #endif + #ifdef IFM_25G_CR1 case IFM_25G_CR1: -# endif -# ifdef IFM_25G_CR_S + #endif + #ifdef IFM_25G_CR_S case IFM_25G_CR_S: -# endif -# ifdef IFM_25G_KR + #endif + #ifdef IFM_25G_KR case IFM_25G_KR: -# endif -# ifdef IFM_25G_KR1 + #endif + #ifdef IFM_25G_KR1 case IFM_25G_KR1: -# endif -# ifdef IFM_25G_KR_S + #endif + #ifdef IFM_25G_KR_S case IFM_25G_KR_S: -# endif -# ifdef IFM_25G_LR + #endif + #ifdef IFM_25G_LR case IFM_25G_LR: -# endif -# ifdef IFM_25G_PCIE + #endif + #ifdef IFM_25G_PCIE case IFM_25G_PCIE: -# endif -# ifdef IFM_25G_SR + #endif + #ifdef IFM_25G_SR case IFM_25G_SR: -# endif -# ifdef IFM_25G_T + #endif + #ifdef IFM_25G_T case IFM_25G_T: -# endif + #endif iface->speed = 25000; break; -# ifdef IFM_400G_AUI8 + #ifdef IFM_400G_AUI8 case IFM_400G_AUI8: -# endif -# ifdef IFM_400G_AUI8_AC + #endif + #ifdef IFM_400G_AUI8_AC case IFM_400G_AUI8_AC: -# endif -# ifdef IFM_400G_DR4 + #endif + #ifdef IFM_400G_DR4 case IFM_400G_DR4: -# endif -# ifdef IFM_400G_FR8 + #endif + #ifdef IFM_400G_FR8 case IFM_400G_FR8: -# endif -# ifdef IFM_400G_LR8 + #endif + #ifdef IFM_400G_LR8 case IFM_400G_LR8: -# endif + #endif iface->speed = 400000; break; -# ifdef IFM_40G_CR4 + #ifdef IFM_40G_CR4 case IFM_40G_CR4: -# endif -# ifdef IFM_40G_ER4 + #endif + #ifdef IFM_40G_ER4 case IFM_40G_ER4: -# endif -# ifdef IFM_40G_KR4 + #endif + #ifdef IFM_40G_KR4 case IFM_40G_KR4: -# endif -# ifdef IFM_40G_LR4 + #endif + #ifdef IFM_40G_LR4 case IFM_40G_LR4: -# endif -# ifdef IFM_40G_SR4 + #endif + #ifdef IFM_40G_SR4 case IFM_40G_SR4: -# endif -# ifdef IFM_40G_XLAUI + #endif + #ifdef IFM_40G_XLAUI case IFM_40G_XLAUI: -# endif -# ifdef IFM_40G_XLAUI_AC + #endif + #ifdef IFM_40G_XLAUI_AC case IFM_40G_XLAUI_AC: -# endif -# ifdef IFM_40G_XLPPI + #endif + #ifdef IFM_40G_XLPPI case IFM_40G_XLPPI: -# endif -# ifdef IFM_40G_LM4 + #endif + #ifdef IFM_40G_LM4 case IFM_40G_LM4: -# endif + #endif iface->speed = 40000; break; -# ifdef IFM_5000_KR + #ifdef IFM_5000_KR case IFM_5000_KR: -# endif -# ifdef IFM_5000_KR1 + #endif + #ifdef IFM_5000_KR1 case IFM_5000_KR1: -# endif -# ifdef IFM_5000_KR_S + #endif + #ifdef IFM_5000_KR_S case IFM_5000_KR_S: -# endif -# ifdef IFM_5000_T + #endif + #ifdef IFM_5000_T case IFM_5000_T: -# endif + #endif iface->speed = 5000; break; -# ifdef IFM_50G_AUI1 + #ifdef IFM_50G_AUI1 case IFM_50G_AUI1: -# endif -# ifdef IFM_50G_AUI1_AC + #endif + #ifdef IFM_50G_AUI1_AC case IFM_50G_AUI1_AC: -# endif -# ifdef IFM_50G_AUI2 + #endif + #ifdef IFM_50G_AUI2 case IFM_50G_AUI2: -# endif -# ifdef IFM_50G_AUI2_AC + #endif + #ifdef IFM_50G_AUI2_AC case IFM_50G_AUI2_AC: -# endif -# ifdef IFM_50G_CP + #endif + #ifdef IFM_50G_CP case IFM_50G_CP: -# endif -# ifdef IFM_50G_CR2 + #endif + #ifdef IFM_50G_CR2 case IFM_50G_CR2: -# endif -# ifdef IFM_50G_FR + #endif + #ifdef IFM_50G_FR case IFM_50G_FR: -# endif -# ifdef IFM_50G_KR2 + #endif + #ifdef IFM_50G_KR2 case IFM_50G_KR2: -# endif -# ifdef IFM_50G_KR_PAM4 + #endif + #ifdef IFM_50G_KR_PAM4 case IFM_50G_KR_PAM4: -# endif -# ifdef IFM_50G_LAUI2 + #endif + #ifdef IFM_50G_LAUI2 case IFM_50G_LAUI2: -# endif -# ifdef IFM_50G_LAUI2_AC + #endif + #ifdef IFM_50G_LAUI2_AC case IFM_50G_LAUI2_AC: -# endif -# ifdef IFM_50G_LR + #endif + #ifdef IFM_50G_LR case IFM_50G_LR: -# endif -# ifdef IFM_50G_LR2 + #endif + #ifdef IFM_50G_LR2 case IFM_50G_LR2: -# endif -# ifdef IFM_50G_PCIE + #endif + #ifdef IFM_50G_PCIE case IFM_50G_PCIE: -# endif -# ifdef IFM_50G_SR + #endif + #ifdef IFM_50G_SR case IFM_50G_SR: -# endif -# ifdef IFM_50G_SR2 + #endif + #ifdef IFM_50G_SR2 case IFM_50G_SR2: -# endif -# ifdef IFM_50G_KR4 + #endif + #ifdef IFM_50G_KR4 case IFM_50G_KR4: -# endif + #endif iface->speed = 50000; break; -# ifdef IFM_56G_R4 + #ifdef IFM_56G_R4 case IFM_56G_R4: -# endif + #endif iface->speed = 56000; break; default: diff --git a/src/detection/media/media_linux.c b/src/detection/media/media_linux.c index 461a4bc07..a3922bc31 100644 --- a/src/detection/media/media_linux.c +++ b/src/detection/media/media_linux.c @@ -9,9 +9,9 @@ #define FF_DBUS_MPRIS_PREFIX "org.mpris.MediaPlayer2." #ifdef FF_HAVE_DBUS -# include "common/dbus.h" + #include "common/dbus.h" -# define FF_DBUS_ITER_CONTINUE(dbus, iterator) \ + #define FF_DBUS_ITER_CONTINUE(dbus, iterator) \ { \ if (!(dbus)->lib->ffdbus_message_iter_next(iterator)) \ break; \ diff --git a/src/detection/mouse/mouse_bsd.c b/src/detection/mouse/mouse_bsd.c index f7d0ace7f..da7783b0b 100644 --- a/src/detection/mouse/mouse_bsd.c +++ b/src/detection/mouse/mouse_bsd.c @@ -6,9 +6,9 @@ #include #if __has_include() -# include // FreeBSD + #include // FreeBSD #else -# include // DragonFly + #include // DragonFly #endif #define MAX_UHID_MICE 64 diff --git a/src/detection/opencl/opencl.c b/src/detection/opencl/opencl.c index e76a4b89b..880eb7e01 100644 --- a/src/detection/opencl/opencl.c +++ b/src/detection/opencl/opencl.c @@ -2,24 +2,24 @@ #include "detection/gpu/gpu.h" #if !defined(FF_HAVE_OPENCL) && defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_15) -# define FF_HAVE_OPENCL 1 + #define FF_HAVE_OPENCL 1 #endif #ifdef FF_HAVE_OPENCL -# include "common/library.h" -# include "common/parsing.h" -# include "common/stringUtils.h" -# include + #include "common/library.h" + #include "common/parsing.h" + #include "common/stringUtils.h" + #include -# define CL_TARGET_OPENCL_VERSION 110 -# ifndef __APPLE__ -# include -# include -# else -# include -# include -# endif + #define CL_TARGET_OPENCL_VERSION 110 + #ifndef __APPLE__ + #include + #include + #else + #include + #include + #endif typedef struct OpenCLData { FF_LIBRARY_SYMBOL(clGetPlatformIDs) @@ -34,10 +34,10 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { cl_int ret = data->ffclGetPlatformIDs(ARRAY_SIZE(platforms), platforms, &numPlatforms); if (ret != CL_SUCCESS) { switch (ret) { -# ifdef CL_PLATFORM_NOT_FOUND_KHR // not available on macOS + #ifdef CL_PLATFORM_NOT_FOUND_KHR // not available on macOS case CL_PLATFORM_NOT_FOUND_KHR: return "clGetPlatformIDs() failed: CL_PLATFORM_NOT_FOUND_KHR"; -# endif + #endif case CL_INVALID_VALUE: return "clGetPlatformIDs() failed: CL_INVALID_VALUE"; case CL_OUT_OF_HOST_MEMORY: @@ -166,13 +166,13 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result) { static const char* detectOpenCL(FFOpenCLResult* result) { OpenCLData data; -# ifndef __APPLE__ + #ifndef __APPLE__ FF_LIBRARY_LOAD_MESSAGE(opencl, -# ifdef _WIN32 + #ifdef _WIN32 "OpenCL" FF_LIBRARY_EXTENSION, -1, -# endif + #endif "libOpenCL" FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(opencl, data, clGetPlatformIDs); @@ -182,7 +182,7 @@ static const char* detectOpenCL(FFOpenCLResult* result) { return openCLHandleData(&data, result); -# else + #else data.ffclGetPlatformIDs = clGetPlatformIDs; data.ffclGetPlatformInfo = clGetPlatformInfo; @@ -191,7 +191,7 @@ static const char* detectOpenCL(FFOpenCLResult* result) { return openCLHandleData(&data, result); -# endif + #endif } #endif // defined(FF_HAVE_OPENCL) diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index 6d28115fd..5f88b7eb3 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -5,25 +5,25 @@ #include #if __ANDROID__ && !defined(FF_HAVE_EGL) -// On Android, installing OpenGL headers is enough (mesa-dev) -# if __has_include() -# define FF_HAVE_EGL 1 -# endif + // On Android, installing OpenGL headers is enough (mesa-dev) + #if __has_include() + #define FF_HAVE_EGL 1 + #endif #endif #if defined(FF_HAVE_EGL) || defined(FF_HAVE_GLX) -# define FF_HAVE_GL 1 + #define FF_HAVE_GL 1 -# include "common/library.h" + #include "common/library.h" -# include + #include void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString); #endif // FF_HAVE_GL #ifdef FF_HAVE_GLX -# include + #include typedef struct GLXData { FF_LIBRARY_SYMBOL(glGetString) @@ -128,11 +128,11 @@ static const char* detectByGlx(FFOpenGLResult* result) { GLXData data; FF_LIBRARY_LOAD_MESSAGE(glx, -# if !__OpenBSD__ && !__NetBSD__ + #if !__OpenBSD__ && !__NetBSD__ "libGLX" -# else + #else "libGL" -# endif + #endif FF_LIBRARY_EXTENSION, 1); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, glXGetProcAddress); @@ -160,34 +160,34 @@ const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) { #if FF_HAVE_GL if (options->library == FF_OPENGL_LIBRARY_GLX) { -# ifdef FF_HAVE_GLX + #ifdef FF_HAVE_GLX return detectByGlx(result); -# else + #else return "fastfetch was compiled without glx support"; -# endif + #endif } if (options->library == FF_OPENGL_LIBRARY_EGL) { -# ifdef FF_HAVE_EGL + #ifdef FF_HAVE_EGL const char* ffOpenGLDetectByEGL(FFOpenGLResult * result); return ffOpenGLDetectByEGL(result); -# else + #else return "fastfetch was compiled without egl support"; -# endif + #endif } const char* error = ""; // not NULL dummy value -# ifdef FF_HAVE_EGL + #ifdef FF_HAVE_EGL const char* ffOpenGLDetectByEGL(FFOpenGLResult * result); error = ffOpenGLDetectByEGL(result); -# endif + #endif -# ifdef FF_HAVE_GLX + #ifdef FF_HAVE_GLX if (error != NULL) { error = detectByGlx(result); } -# endif + #endif return error; diff --git a/src/detection/opengl/opengl_shared.c b/src/detection/opengl/opengl_shared.c index e0fa69456..307e71d1b 100644 --- a/src/detection/opengl/opengl_shared.c +++ b/src/detection/opengl/opengl_shared.c @@ -3,19 +3,19 @@ #include "common/library.h" #if __has_include() -# include + #include #elif __APPLE__ -# define GL_SILENCE_DEPRECATION 1 -# include + #define GL_SILENCE_DEPRECATION 1 + #include #else -# define FF_HAVE_NO_GL 1 + #define FF_HAVE_NO_GL 1 #endif #ifndef FF_HAVE_NO_GL -# ifndef GL_SHADING_LANGUAGE_VERSION // For WGL -# define GL_SHADING_LANGUAGE_VERSION 0x8B8C -# endif + #ifndef GL_SHADING_LANGUAGE_VERSION // For WGL + #define GL_SHADING_LANGUAGE_VERSION 0x8B8C + #endif void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglGetString) { ffStrbufAppendS(&result->version, (const char*) ffglGetString(GL_VERSION)); @@ -24,13 +24,13 @@ void ffOpenGLHandleResult(FFOpenGLResult* result, __typeof__(&glGetString) ffglG ffStrbufAppendS(&result->slv, (const char*) ffglGetString(GL_SHADING_LANGUAGE_VERSION)); } -# if defined(FF_HAVE_EGL) || __has_include() -# include "common/io.h" + #if defined(FF_HAVE_EGL) || __has_include() + #include "common/io.h" -# define EGL_EGL_PROTOTYPES 1 -# define EGL_EGLEXT_PROTOTYPES 1 -# include -# include + #define EGL_EGL_PROTOTYPES 1 + #define EGL_EGLEXT_PROTOTYPES 1 + #include + #include typedef struct EGLData { FF_LIBRARY_SYMBOL(glGetString) @@ -140,7 +140,7 @@ static const char* eglHandleData(FFOpenGLResult* result, EGLData* data) { return "eglGetProcAddress(glGetString) returned NULL"; } -# if EGL_VERSION_1_5 + #if EGL_VERSION_1_5 PFNEGLGETPLATFORMDISPLAYEXTPROC ffeglGetPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC) data->ffeglGetProcAddress("eglGetPlatformDisplay"); if (ffeglGetPlatformDisplay) { FF_DEBUG("Trying eglGetPlatformDisplay(EGL_PLATFORM_SURFACELESS_MESA)"); @@ -151,7 +151,7 @@ static const char* eglHandleData(FFOpenGLResult* result, EGLData* data) { } if (!ffeglGetPlatformDisplay || data->display == EGL_NO_DISPLAY) -# endif + #endif { FF_DEBUG("Trying eglGetDisplay(EGL_DEFAULT_DISPLAY)"); @@ -209,6 +209,6 @@ const char* ffOpenGLDetectByEGL(FFOpenGLResult* result) { return error; } -# endif // FF_HAVE_EGL + #endif // FF_HAVE_EGL #endif // FF_HAVE_NO_GL diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 026b6ce00..f8d9aac3e 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -293,9 +293,9 @@ static bool detectBedrock(FFOSResult* os) { static void detectOS(FFOSResult* os) { #ifdef FF_CUSTOM_OS_RELEASE_PATH parseOsRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os); -# ifdef FF_CUSTOM_LSB_RELEASE_PATH + #ifdef FF_CUSTOM_LSB_RELEASE_PATH parseLsbRelease(FF_STR(FF_CUSTOM_LSB_RELEASE_PATH), os); -# endif + #endif return; #endif diff --git a/src/detection/packages/packages.c b/src/detection/packages/packages.c index 6007c98f7..a21227383 100644 --- a/src/detection/packages/packages.c +++ b/src/detection/packages/packages.c @@ -6,7 +6,7 @@ #include #ifdef __APPLE__ -# define st_mtim st_mtimespec + #define st_mtim st_mtimespec #endif void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options); @@ -100,11 +100,11 @@ uint32_t ffPackagesGetNumElements(const char* dirname, bool isdir) { bool ok = false; if (entry->d_name[0] != '.') { -# if !defined(__sun) && !defined(__HAIKU__) + #if !defined(__sun) && !defined(__HAIKU__) if (entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK) { ok = entry->d_type == (isdir ? DT_DIR : DT_REG); } else -# endif + #endif { struct stat stbuf; if (fstatat(dirfd(dirp), entry->d_name, &stbuf, 0) == 0) { diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 7f73fa142..949862f81 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -162,11 +162,11 @@ static uint32_t getSnap(FFstrbuf* baseDir) { } #ifdef FF_HAVE_RPM -# include "common/library.h" -# include -# include -# include -# include + #include "common/library.h" + #include + #include + #include + #include static uint32_t getRpmFromLibrpm(void) { FF_LIBRARY_LOAD(rpm, 0, "librpm" FF_LIBRARY_EXTENSION, 12) diff --git a/src/detection/physicaldisk/physicaldisk_apple.c b/src/detection/physicaldisk/physicaldisk_apple.c index 9f8be1454..f4c5cd6ca 100644 --- a/src/detection/physicaldisk/physicaldisk_apple.c +++ b/src/detection/physicaldisk/physicaldisk_apple.c @@ -8,7 +8,7 @@ #include #include #ifdef MAC_OS_X_VERSION_10_15 -# include + #include #endif #ifdef MAC_OS_X_VERSION_10_15 diff --git a/src/detection/physicaldisk/physicaldisk_bsd.c b/src/detection/physicaldisk/physicaldisk_bsd.c index e87d249c4..eda060905 100644 --- a/src/detection/physicaldisk/physicaldisk_bsd.c +++ b/src/detection/physicaldisk/physicaldisk_bsd.c @@ -2,14 +2,14 @@ #if __has_include() -# include "common/stringUtils.h" + #include "common/stringUtils.h" -# include -# include -# include -# include -# include -# include + #include + #include + #include + #include + #include + #include const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) { struct gmesh geomTree; diff --git a/src/detection/physicaldisk/physicaldisk_nbsd.c b/src/detection/physicaldisk/physicaldisk_nbsd.c index acef9ac80..0733f3b5b 100644 --- a/src/detection/physicaldisk/physicaldisk_nbsd.c +++ b/src/detection/physicaldisk/physicaldisk_nbsd.c @@ -108,7 +108,7 @@ static void logScsiSense(const char* diskName, const char* operation, const scsi rawSense.length ? rawSense.chars : "empty"); } #else -# define logScsiSense(...) ((void) 0) + #define logScsiSense(...) ((void) 0) #endif const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) { diff --git a/src/detection/physicaldisk/physicaldisk_obsd.c b/src/detection/physicaldisk/physicaldisk_obsd.c index 2958c631a..6e89a9975 100644 --- a/src/detection/physicaldisk/physicaldisk_obsd.c +++ b/src/detection/physicaldisk/physicaldisk_obsd.c @@ -105,7 +105,7 @@ static void logScsiSense(const char* diskName, const char* operation, const scsi rawSense.length ? rawSense.chars : "empty"); } #else -# define logScsiSense(...) ((void) 0) + #define logScsiSense(...) ((void) 0) #endif const char* ffDetectPhysicalDisk(FFlist* result, FFPhysicalDiskOptions* options) { diff --git a/src/detection/processes/processes_bsd.c b/src/detection/processes/processes_bsd.c index a68477852..e3f02b8db 100644 --- a/src/detection/processes/processes_bsd.c +++ b/src/detection/processes/processes_bsd.c @@ -2,12 +2,12 @@ #include #ifdef __FreeBSD__ -# include -# include + #include + #include #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) { diff --git a/src/detection/sound/audio_oss_sunos.h b/src/detection/sound/audio_oss_sunos.h index c5f47e9f1..4e0e7604f 100644 --- a/src/detection/sound/audio_oss_sunos.h +++ b/src/detection/sound/audio_oss_sunos.h @@ -765,21 +765,21 @@ typedef unsigned short oss_peaks_t[MAX_PEAK_CHANNELS]; * opposite endian formats). */ #if defined(_BIG_ENDIAN) -# define AFMT_S16_NE AFMT_S16_BE -# define AFMT_U16_NE AFMT_U16_BE -# define AFMT_S32_NE AFMT_S32_BE -# define AFMT_S24_NE AFMT_S24_BE -# define AFMT_S16_OE AFMT_S16_LE -# define AFMT_S32_OE AFMT_S32_LE -# define AFMT_S24_OE AFMT_S24_LE + #define AFMT_S16_NE AFMT_S16_BE + #define AFMT_U16_NE AFMT_U16_BE + #define AFMT_S32_NE AFMT_S32_BE + #define AFMT_S24_NE AFMT_S24_BE + #define AFMT_S16_OE AFMT_S16_LE + #define AFMT_S32_OE AFMT_S32_LE + #define AFMT_S24_OE AFMT_S24_LE #else -# define AFMT_S16_NE AFMT_S16_LE -# define AFMT_U16_NE AFMT_U16_LE -# define AFMT_S32_NE AFMT_S32_LE -# define AFMT_S24_NE AFMT_S24_LE -# define AFMT_S16_OE AFMT_S16_BE -# define AFMT_S32_OE AFMT_S32_BE -# define AFMT_S24_OE AFMT_S24_BE + #define AFMT_S16_NE AFMT_S16_LE + #define AFMT_U16_NE AFMT_U16_LE + #define AFMT_S32_NE AFMT_S32_LE + #define AFMT_S24_NE AFMT_S24_LE + #define AFMT_S16_OE AFMT_S16_BE + #define AFMT_S32_OE AFMT_S32_BE + #define AFMT_S24_OE AFMT_S24_BE #endif /* diff --git a/src/detection/sound/sound_apple.c b/src/detection/sound/sound_apple.c index 01daab128..aaacf78eb 100644 --- a/src/detection/sound/sound_apple.c +++ b/src/detection/sound/sound_apple.c @@ -5,7 +5,7 @@ #include #ifndef MAC_OS_VERSION_12_0 -# define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster + #define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster #endif const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FFSoundDevice */) { diff --git a/src/detection/sound/sound_bsd.c b/src/detection/sound/sound_bsd.c index 6bb2b9d98..cbac86848 100644 --- a/src/detection/sound/sound_bsd.c +++ b/src/detection/sound/sound_bsd.c @@ -58,7 +58,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) { } #if defined(SOUND_MIXER_MUTE) && (SOUND_MIXER_MUTE != SOUND_MIXER_NONE) -# define FF_SOUND_HAVE_MIXER_MUTE 1 + #define FF_SOUND_HAVE_MIXER_MUTE 1 uint32_t mutemask = 0; ioctl(fd, SOUND_MIXER_READ_MUTE, &mutemask); #endif diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index af9a22dbd..8af7e93c8 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -1,8 +1,8 @@ #include "sound.h" #ifdef FF_HAVE_PULSE -# include "common/library.h" -# include + #include "common/library.h" + #include struct DetectionInfoBundle { FFstrbuf serverName; diff --git a/src/detection/sound/sound_sunos.c b/src/detection/sound/sound_sunos.c index bba147821..be3e9739a 100644 --- a/src/detection/sound/sound_sunos.c +++ b/src/detection/sound/sound_sunos.c @@ -5,10 +5,10 @@ #include #include #if __has_include() -# include + #include #else -// Strangely, they don't provide this file on default installation -# include "audio_oss_sunos.h" + // Strangely, they don't provide this file on default installation + #include "audio_oss_sunos.h" #endif const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) { diff --git a/src/detection/terminalfont/terminalfont_android.c b/src/detection/terminalfont/terminalfont_android.c index 1188f1617..a7210783e 100644 --- a/src/detection/terminalfont/terminalfont_android.c +++ b/src/detection/terminalfont/terminalfont_android.c @@ -4,9 +4,9 @@ #include "common/io.h" #ifdef FF_HAVE_FREETYPE -# include "common/library.h" -# include -# include FT_FREETYPE_H + #include "common/library.h" + #include + #include FT_FREETYPE_H #endif #define FF_TERMUX_FONT_PATH FASTFETCH_TARGET_DIR_HOME "/.termux/font.ttf" diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 04320a7e9..97c2cff24 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -9,18 +9,18 @@ #include #include #ifdef __FreeBSD__ -# include -# ifndef _PATH_LOCALBASE -# define _PATH_LOCALBASE "/usr/local" -# endif + #include + #ifndef _PATH_LOCALBASE + #define _PATH_LOCALBASE "/usr/local" + #endif #elif __OpenBSD__ -# define _PATH_LOCALBASE "/usr/local" + #define _PATH_LOCALBASE "/usr/local" #elif __NetBSD__ -# define _PATH_LOCALBASE "/usr/pkg" + #define _PATH_LOCALBASE "/usr/pkg" #elif _WIN32 -# include "common/windows/version.h" -# include + #include "common/windows/version.h" + #include static bool getFileVersion(const FFstrbuf* exePath, const wchar_t* stringName, FFstrbuf* version) { wchar_t exePathW[PATH_MAX + 1]; @@ -31,7 +31,7 @@ static bool getFileVersion(const FFstrbuf* exePath, const wchar_t* stringName, F } #elif __HAIKU__ -# include "common/haiku/version.h" + #include "common/haiku/version.h" #endif static bool getExeVersionRaw(FFstrbuf* exe, FFstrbuf* version) { @@ -586,15 +586,15 @@ static bool getTerminalVersionSshd(FFstrbuf* exe, FFstrbuf* version) { #ifndef _WIN32 static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { -# if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__GNU__) + #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__GNU__) char buffer[1024] = {}; if ( -# if __linux__ || __GNU__ + #if __linux__ || __GNU__ ffReadFileData(FASTFETCH_TARGET_DIR_USR "/lib64/kitty/kitty/constants.py", ARRAY_SIZE(buffer) - 1, buffer) || ffReadFileData(FASTFETCH_TARGET_DIR_USR "/lib/kitty/kitty/constants.py", ARRAY_SIZE(buffer) - 1, buffer) -# else + #else ffReadFileData(_PATH_LOCALBASE "/share/kitty/kitty/constants.py", ARRAY_SIZE(buffer) - 1, buffer) -# endif + #endif ) { // Starts from version 0.17.0 // https://github.com/kovidgoyal/kitty/blob/master/kitty/constants.py#L25 @@ -608,7 +608,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { } } } -# elif __APPLE__ + #elif __APPLE__ if (ffStrbufEndsWithS(exe, "/kitty.app/Contents/MacOS/kitty")) { ffStrbufSet(version, exe); ffStrbufSubstrBeforeLastC(version, '/'); @@ -635,7 +635,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { } ffStrbufClear(version); } -# endif + #endif char versionHex[64]; // https://github.com/fastfetch-cli/fastfetch/discussions/1030#discussioncomment-9845233 diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 38be51a82..75f88c4e9 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -374,11 +374,11 @@ static void setTerminalInfoDetails(FFTerminalResult* result) { } #if defined(MAXPATH) -# define FF_EXE_PATH_LEN MAXPATH + #define FF_EXE_PATH_LEN MAXPATH #elif defined(PATH_MAX) -# define FF_EXE_PATH_LEN PATH_MAX + #define FF_EXE_PATH_LEN PATH_MAX #else -# define FF_EXE_PATH_LEN 260 + #define FF_EXE_PATH_LEN 260 #endif const FFShellResult* ffDetectShell() { diff --git a/src/detection/terminalsize/terminalsize_linux.c b/src/detection/terminalsize/terminalsize_linux.c index 523bf8a00..e06f958b2 100644 --- a/src/detection/terminalsize/terminalsize_linux.c +++ b/src/detection/terminalsize/terminalsize_linux.c @@ -6,7 +6,7 @@ #include #ifdef __sun -# include + #include #endif bool ffDetectTerminalSize(FFTerminalSizeResult* result) { diff --git a/src/detection/tpm/tpm_apple.c b/src/detection/tpm/tpm_apple.c index 07fbdb40f..250dd014e 100644 --- a/src/detection/tpm/tpm_apple.c +++ b/src/detection/tpm/tpm_apple.c @@ -1,8 +1,8 @@ #include "tpm.h" #ifndef __aarch64__ -# include "common/apple/cf_helpers.h" -# include + #include "common/apple/cf_helpers.h" + #include #endif const char* ffDetectTPM(FFTPMResult* result) { diff --git a/src/detection/users/users_linux.c b/src/detection/users/users_linux.c index 6606d9415..bc84eedbf 100644 --- a/src/detection/users/users_linux.c +++ b/src/detection/users/users_linux.c @@ -6,17 +6,17 @@ #include #if FF_HAVE_UTMPX -# include + #include #else -// for Android compatibility -# include -# define utmpx utmp -# define setutxent setutent -# define getutxent getutent + // for Android compatibility + #include + #define utmpx utmp + #define setutxent setutent + #define getutxent getutent #endif #if __linux__ || __GNU__ -# include -# include + #include + #include #endif #if __linux__ diff --git a/src/detection/version/version.c b/src/detection/version/version.c index 0027166bc..8bd066ec0 100644 --- a/src/detection/version/version.c +++ b/src/detection/version/version.c @@ -1,65 +1,65 @@ #include "version.h" #if defined(__x86_64__) -# define FF_ARCHITECTURE "x86_64" + #define FF_ARCHITECTURE "x86_64" #elif defined(__i386__) -# define FF_ARCHITECTURE "i386" + #define FF_ARCHITECTURE "i386" #elif defined(__ia64__) -# define FF_ARCHITECTURE "ia64" + #define FF_ARCHITECTURE "ia64" #elif defined(__aarch64__) -# define FF_ARCHITECTURE "aarch64" + #define FF_ARCHITECTURE "aarch64" #elif defined(__arm__) -# define FF_ARCHITECTURE "arm" + #define FF_ARCHITECTURE "arm" #elif defined(__mips__) -# define FF_ARCHITECTURE "mips" + #define FF_ARCHITECTURE "mips" #elif defined(__powerpc__) || defined(__powerpc) -# define FF_ARCHITECTURE "powerpc" + #define FF_ARCHITECTURE "powerpc" #elif defined(__riscv__) || defined(__riscv) -# define FF_ARCHITECTURE "riscv" + #define FF_ARCHITECTURE "riscv" #elif defined(__s390x__) -# define FF_ARCHITECTURE "s390x" + #define FF_ARCHITECTURE "s390x" #elif defined(__loongarch__) -# define FF_ARCHITECTURE "loongarch" + #define FF_ARCHITECTURE "loongarch" #elif defined(__sparc__) -# define FF_ARCHITECTURE "sparc" + #define FF_ARCHITECTURE "sparc" #elif defined(__alpha__) -# define FF_ARCHITECTURE "alpha" + #define FF_ARCHITECTURE "alpha" #elif defined(__hppa__) -# define FF_ARCHITECTURE "hppa" + #define FF_ARCHITECTURE "hppa" #elif defined(__sh__) -# define FF_ARCHITECTURE "sh" + #define FF_ARCHITECTURE "sh" #elif defined(__m68k__) -# define FF_ARCHITECTURE "m68k" + #define FF_ARCHITECTURE "m68k" #else -# define FF_ARCHITECTURE "Unknown" + #define FF_ARCHITECTURE "Unknown" #endif #if defined(__ANDROID__) -# define FF_SYSNAME "Android" + #define FF_SYSNAME "Android" #elif defined(__linux__) -# define FF_SYSNAME "Linux" + #define FF_SYSNAME "Linux" #elif defined(__DragonFly__) // We define `__FreeBSD__` on DragonFly BSD for simplification -# define FF_SYSNAME "DragonFly" + #define FF_SYSNAME "DragonFly" #elif defined(__MidnightBSD__) -# define FF_SYSNAME "MidnightBSD" + #define FF_SYSNAME "MidnightBSD" #elif defined(__FreeBSD__) -# define FF_SYSNAME "FreeBSD" + #define FF_SYSNAME "FreeBSD" #elif defined(__APPLE__) -# define FF_SYSNAME "macOS" + #define FF_SYSNAME "macOS" #elif defined(_WIN32) -# define FF_SYSNAME "Windows" + #define FF_SYSNAME "Windows" #elif defined(__sun) -# define FF_SYSNAME "SunOS" + #define FF_SYSNAME "SunOS" #elif defined(__OpenBSD__) -# define FF_SYSNAME "OpenBSD" + #define FF_SYSNAME "OpenBSD" #elif defined(__NetBSD__) -# define FF_SYSNAME "NetBSD" + #define FF_SYSNAME "NetBSD" #elif defined(__HAIKU__) -# define FF_SYSNAME "Haiku" + #define FF_SYSNAME "Haiku" #elif defined(__GNU__) -# define FF_SYSNAME "GNU" + #define FF_SYSNAME "GNU" #else -# define FF_SYSNAME "Unknown" + #define FF_SYSNAME "Unknown" #endif #define FF_STR_INDIR(x) #x @@ -77,20 +77,20 @@ FFVersionResult ffVersionResult = { .compiler = #ifdef __clang__ -# ifdef _MSC_VER + #ifdef _MSC_VER "clang-cl "; -# elif defined(__APPLE__) && defined(__apple_build_version__) + #elif defined(__APPLE__) && defined(__apple_build_version__) "Apple clang " -# else + #else "clang " -# endif + #endif FF_STR(__clang_major__) "." FF_STR(__clang_minor__) "." FF_STR(__clang_patchlevel__) -# if defined(__APPLE__) && defined(__apple_build_version__) + #if defined(__APPLE__) && defined(__apple_build_version__) " (" FF_STR(__apple_build_version__) ")" -# endif + #endif , #elif defined(__GNUC__) "gcc " FF_STR(__GNUC__) "." FF_STR(__GNUC_MINOR__) "." FF_STR(__GNUC_PATCHLEVEL__), diff --git a/src/detection/vulkan/vulkan.c b/src/detection/vulkan/vulkan.c index 6ec0a4860..001966de9 100644 --- a/src/detection/vulkan/vulkan.c +++ b/src/detection/vulkan/vulkan.c @@ -4,13 +4,13 @@ #include "detection/vulkan/vulkan.h" #ifdef FF_HAVE_VULKAN -# include "common/library.h" -# include "common/io.h" -# include "common/parsing.h" -# include "common/stringUtils.h" + #include "common/library.h" + #include "common/io.h" + #include "common/parsing.h" + #include "common/stringUtils.h" -# include -# include + #include + #include static inline void applyVulkanVersion(uint32_t vulkanVersion, FFVersion* ffVersion) { ffVersion->major = VK_VERSION_MAJOR(vulkanVersion); @@ -42,16 +42,16 @@ static const char* detectVulkan(FFVulkanResult* result) { FF_DEBUG("Starting Vulkan detection"); FF_LIBRARY_LOAD_MESSAGE(vulkan, -# if __APPLE__ + #if __APPLE__ "libMoltenVK" FF_LIBRARY_EXTENSION, -1 -# elif _WIN32 + #elif _WIN32 "vulkan-1" FF_LIBRARY_EXTENSION, -1 -# else + #else "libvulkan" FF_LIBRARY_EXTENSION, 2 -# endif + #endif ) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(vulkan, vkGetInstanceProcAddr) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(vulkan, vkCreateInstance) diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index eeb6b5b69..df944ddf1 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -37,7 +37,7 @@ typedef enum { NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192 = 0x00002000, } NM80211ApSecurityFlags; -# define FF_DBUS_ITER_CONTINUE(dbus, iterator) \ + #define FF_DBUS_ITER_CONTINUE(dbus, iterator) \ { \ if (!(dbus).lib->ffdbus_message_iter_next(iterator)) \ break; \ @@ -310,10 +310,10 @@ static const char* detectWifiWithIw(FFWifiResult* item, FFstrbuf* buffer) { } #if FF_HAVE_LINUX_WIRELESS -# include -# include -# include -# include + #include + #include + #include + #include static const char* detectWifiWithIoctls(FFWifiResult* item) { FF_DEBUG("Starting ioctl wifi detection for interface %s", item->inf.description.chars); diff --git a/src/detection/wm/wm_linux.c b/src/detection/wm/wm_linux.c index 03adbc74d..6c864a7fe 100644 --- a/src/detection/wm/wm_linux.c +++ b/src/detection/wm/wm_linux.c @@ -162,7 +162,7 @@ static const char* getNiri(FFstrbuf* result) { return "Failed to run command `niri --version`"; } -# ifdef __linux__ + #ifdef __linux__ static const char* getWslg(FFstrbuf* result) { if (!ffAppendFileBuffer("/mnt/wslg/versions.txt", result)) { return "Failed to read /mnt/wslg/versions.txt"; @@ -178,7 +178,7 @@ static const char* getWslg(FFstrbuf* result) { ffStrbufTrimLeft(result, ' '); return NULL; } -# endif + #endif #endif // !__ANDROID__ @@ -300,11 +300,11 @@ const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNU return getNiri(result); } -# if __linux__ + #if __linux__ if (ffStrbufEqualS(wmName, "WSLg")) { return getWslg(result); } -# endif + #endif #endif // X11 WMs diff --git a/src/detection/zpool/zpool.c b/src/detection/zpool/zpool.c index ece62a4dd..ce7abb37f 100644 --- a/src/detection/zpool/zpool.c +++ b/src/detection/zpool/zpool.c @@ -2,20 +2,20 @@ #if FF_HAVE_LIBZFS -# include "common/kmod.h" + #include "common/kmod.h" -# ifdef __sun -# include -# ifndef __illumos__ -// On Solaris 11, zpool_get_prop has only 5 arguments. #2173 -# define ffzpool_get_prop(zhp, prop, buf, len, srctype, literal) \ + #ifdef __sun + #include + #ifndef __illumos__ + // On Solaris 11, zpool_get_prop has only 5 arguments. #2173 + #define ffzpool_get_prop(zhp, prop, buf, len, srctype, literal) \ ffzpool_get_prop(zhp, prop, buf, len, srctype) -# endif -# else -# include "libzfs_simplified.h" -# endif + #endif + #else + #include "libzfs_simplified.h" + #endif -# include "common/library.h" + #include "common/library.h" typedef struct FFZfsData { FF_LIBRARY_SYMBOL(libzfs_fini) @@ -92,7 +92,7 @@ const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */) { FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libzfs, zpool_name_to_prop); -# define FF_QUERY_ZPOOL_PROP_FROM_NAME(prop_name) \ + #define FF_QUERY_ZPOOL_PROP_FROM_NAME(prop_name) \ do { \ data.props.prop_name = ffzpool_name_to_prop(#prop_name); \ if (data.props.prop_name < 0) \ @@ -106,7 +106,7 @@ const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */) { FF_QUERY_ZPOOL_PROP_FROM_NAME(allocated); FF_QUERY_ZPOOL_PROP_FROM_NAME(fragmentation); FF_QUERY_ZPOOL_PROP_FROM_NAME(readonly); -# undef FF_QUERY_ZPOOL_PROP_FROM_NAME + #undef FF_QUERY_ZPOOL_PROP_FROM_NAME FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libzfs, zpool_iter); FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libzfs, data, libzfs_fini); diff --git a/src/logo/image/im6.c b/src/logo/image/im6.c index f7559a479..3e9d7227e 100644 --- a/src/logo/image/im6.c +++ b/src/logo/image/im6.c @@ -1,9 +1,9 @@ #ifdef FF_HAVE_IMAGEMAGICK6 -# include "image.h" -# include "common/library.h" + #include "image.h" + #include "common/library.h" -# include + #include static FF_LIBRARY_SYMBOL(ResizeImage) diff --git a/src/logo/image/im7.c b/src/logo/image/im7.c index 4eae9dd99..636a5fa5b 100644 --- a/src/logo/image/im7.c +++ b/src/logo/image/im7.c @@ -1,9 +1,9 @@ #ifdef FF_HAVE_IMAGEMAGICK7 -# include "image.h" -# include "common/library.h" + #include "image.h" + #include "common/library.h" -# include + #include static FF_LIBRARY_SYMBOL(ResizeImage) diff --git a/src/logo/image/image.c b/src/logo/image/image.c index e85cfd3ff..60dc77741 100644 --- a/src/logo/image/image.c +++ b/src/logo/image/image.c @@ -10,13 +10,13 @@ #include #ifdef __APPLE__ -# include + #include #elif _WIN32 -# include + #include #elif __linux__ -# include + #include #elif __sun -# include + #include #endif static bool printImageIterm(bool printError) { @@ -342,30 +342,30 @@ static bool printImageKittyDirect(bool printError) { #if defined(FF_HAVE_IMAGEMAGICK7) || defined(FF_HAVE_IMAGEMAGICK6) -# define FF_KITTY_MAX_CHUNK_SIZE 4096 + #define FF_KITTY_MAX_CHUNK_SIZE 4096 -# define FF_CACHE_FILE_HEIGHT "height" -# define FF_CACHE_FILE_WIDTH "width" -# define FF_CACHE_FILE_SIXEL "sixel" -# define FF_CACHE_FILE_KITTY_COMPRESSED "kittyc" -# define FF_CACHE_FILE_KITTY_UNCOMPRESSED "kittyu" -# define FF_CACHE_FILE_CHAFA "chafa" + #define FF_CACHE_FILE_HEIGHT "height" + #define FF_CACHE_FILE_WIDTH "width" + #define FF_CACHE_FILE_SIXEL "sixel" + #define FF_CACHE_FILE_KITTY_COMPRESSED "kittyc" + #define FF_CACHE_FILE_KITTY_UNCOMPRESSED "kittyu" + #define FF_CACHE_FILE_CHAFA "chafa" -# include -# include -# include + #include + #include + #include -# ifndef _WIN32 -# include -# else -# include -# include "common/path.h" -# endif + #ifndef _WIN32 + #include + #else + #include + #include "common/path.h" + #endif -# ifdef FF_HAVE_ZLIB -# include "common/library.h" -# include -# include + #ifdef FF_HAVE_ZLIB + #include "common/library.h" + #include + #include static bool compressBlob(void** blob, size_t* length) { FF_LIBRARY_LOAD(zlib, false, "libz" FF_LIBRARY_EXTENSION, 2) @@ -390,14 +390,14 @@ static bool compressBlob(void** blob, size_t* length) { return true; } -# endif // FF_HAVE_ZLIB + #endif // FF_HAVE_ZLIB -// We use only the defines from here, that are exactly the same in both versions -# ifdef FF_HAVE_IMAGEMAGICK7 -# include -# else -# include -# endif + // We use only the defines from here, that are exactly the same in both versions + #ifdef FF_HAVE_IMAGEMAGICK7 + #include + #else + #include + #endif typedef struct ImageData { FF_LIBRARY_SYMBOL(CopyMagickString) @@ -518,11 +518,11 @@ static bool printImageKitty(FFLogoRequestData* requestData, const ImageData* ima return false; } -# ifdef FF_HAVE_ZLIB + #ifdef FF_HAVE_ZLIB bool isCompressed = compressBlob(&blob, &length); -# else + #else bool isCompressed = false; -# endif + #endif char* chars = imageData->ffBase64Encode(blob, length, &length); free(blob); @@ -550,8 +550,8 @@ static bool printImageKitty(FFLogoRequestData* requestData, const ImageData* ima return true; } -# ifdef FF_HAVE_CHAFA -# include + #ifdef FF_HAVE_CHAFA + #include static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* imageData) { FF_LIBRARY_LOAD(chafa, false, "libchafa" FF_LIBRARY_EXTENSION, 1, "libchafa-0" FF_LIBRARY_EXTENSION, -1 // Required for Windows ) @@ -645,7 +645,7 @@ static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* ima return true; } -# endif + #endif FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFIMData* imData) { FF_LIBRARY_LOAD_SYMBOL(imData->library, MagickCoreGenesis, FF_LOGO_IMAGE_RESULT_INIT_ERROR) @@ -727,9 +727,9 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI bool printSuccessful = false; if (requestData->type == FF_LOGO_TYPE_IMAGE_CHAFA) { -# ifdef FF_HAVE_CHAFA + #ifdef FF_HAVE_CHAFA printSuccessful = printImageChafa(requestData, &imageData); -# endif + #endif } else if (requestData->type == FF_LOGO_TYPE_IMAGE_KITTY) { printSuccessful = printImageKitty(requestData, &imageData); } else if (requestData->type == FF_LOGO_TYPE_IMAGE_SIXEL) { @@ -747,15 +747,15 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI static FFNativeFD getCacheFD(FFLogoRequestData* requestData, const char* fileName) { uint32_t cacheDirLength = requestData->cacheDir.length; ffStrbufAppendS(&requestData->cacheDir, fileName); -# ifndef _WIN32 + #ifndef _WIN32 int fd = open(requestData->cacheDir.chars, O_RDONLY -# ifdef O_CLOEXEC + #ifdef O_CLOEXEC | O_CLOEXEC -# endif + #endif ); -# else + #else HANDLE fd = CreateFileA(requestData->cacheDir.chars, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -# endif + #endif ffStrbufSubstrBefore(&requestData->cacheDir, cacheDirLength); return fd; } @@ -839,7 +839,7 @@ static bool printCachedPixel(FFLogoRequestData* requestData) { fflush(stdout); bool sent = false; -# ifdef __linux__ + #ifdef __linux__ struct stat st; if (fstat(fd, &st) >= 0) { while (st.st_size > 0) { @@ -852,7 +852,7 @@ static bool printCachedPixel(FFLogoRequestData* requestData) { } } } -# endif + #endif if (!sent) { char buffer[32768]; @@ -885,7 +885,7 @@ static bool printCached(FFLogoRequestData* requestData) { } static bool getCharacterPixelDimensions(FFLogoRequestData* requestData) { -# ifdef _WIN32 + #ifdef _WIN32 CONSOLE_FONT_INFOEX cfi = { .cbSize = sizeof(cfi) }; if (GetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi)) // Only works for ConHost @@ -896,7 +896,7 @@ static bool getCharacterPixelDimensions(FFLogoRequestData* requestData) { if (requestData->characterPixelWidth > 1.0 && requestData->characterPixelHeight > 1.0) { return true; } -# endif + #endif FFTerminalSizeResult termSize = {}; if (ffDetectTerminalSize(&termSize)) { @@ -938,10 +938,10 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError) { return false; } -# ifdef _WIN32 + #ifdef _WIN32 filePath[1] = filePath[0]; // Drive Name filePath[0] = '/'; -# endif + #endif ffStrbufRecalculateLength(&requestData.cacheDir); ffStrbufEnsureEndsWithC(&requestData.cacheDir, '/'); @@ -954,15 +954,15 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError) { FFLogoImageResult result = FF_LOGO_IMAGE_RESULT_INIT_ERROR; -# ifdef FF_HAVE_IMAGEMAGICK7 + #ifdef FF_HAVE_IMAGEMAGICK7 result = ffLogoPrintImageIM7(&requestData); -# endif + #endif -# ifdef FF_HAVE_IMAGEMAGICK6 + #ifdef FF_HAVE_IMAGEMAGICK6 if (result == FF_LOGO_IMAGE_RESULT_INIT_ERROR) { result = ffLogoPrintImageIM6(&requestData); } -# endif + #endif ffStrbufDestroy(&requestData.cacheDir); diff --git a/src/logo/image/image.h b/src/logo/image/image.h index 2fcb40a55..da3b2d290 100644 --- a/src/logo/image/image.h +++ b/src/logo/image/image.h @@ -38,6 +38,6 @@ FFLogoImageResult ffLogoPrintImageIM7(FFLogoRequestData* requestData); #endif #ifdef FF_HAVE_IMAGEMAGICK6 -# include + #include FFLogoImageResult ffLogoPrintImageIM6(FFLogoRequestData* requestData); #endif diff --git a/src/modules/disk/disk.c b/src/modules/disk/disk.c index b472feeea..cb06d0723 100644 --- a/src/modules/disk/disk.c +++ b/src/modules/disk/disk.c @@ -7,7 +7,7 @@ #include "modules/disk/disk.h" #ifndef _WIN32 -# include + #include #endif #pragma GCC diagnostic ignored "-Wsign-conversion" diff --git a/src/modules/separator/separator.c b/src/modules/separator/separator.c index aa8d13e49..7be01919c 100644 --- a/src/modules/separator/separator.c +++ b/src/modules/separator/separator.c @@ -14,7 +14,7 @@ static inline size_t mbrtoc32(uint32_t* restrict pc32, const char* restrict s, s return mbrtowc((wchar_t*) pc32, s, n, ps); } #else -# include + #include #endif static uint8_t getMbrWidth(const char* mbstr, uint32_t length, const char** next, mbstate_t* state) {