diff --git a/src/common/FFlist.h b/src/common/FFlist.h index cdd9a6da4..498499deb 100644 --- a/src/common/FFlist.h +++ b/src/common/FFlist.h @@ -1,7 +1,5 @@ #pragma once -#include "common/attributes.h" - #include #include #include @@ -32,24 +30,24 @@ static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capa list->data = __builtin_expect(capacity == 0, 0) ? nullptr : (uint8_t*) malloc((size_t) capacity * elementSize); } -FF_A_NODISCARD static inline FFlist ffListCreate() { +[[nodiscard]] static inline FFlist ffListCreate() { FFlist result; ffListInit(&result); return result; } -FF_A_NODISCARD static inline FFlist ffListCreateA(uint32_t elementSize, uint32_t capacity) { +[[nodiscard]] static inline FFlist ffListCreateA(uint32_t elementSize, uint32_t capacity) { FFlist result; ffListInitA(&result, elementSize, capacity); return result; } -FF_A_NODISCARD static inline void* ffListGet(const FFlist* list, uint32_t elementSize, uint32_t index) { +[[nodiscard]] static inline void* ffListGet(const FFlist* list, uint32_t elementSize, uint32_t index) { assert(list->capacity > index); return list->data + (index * elementSize); } -FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) { +[[nodiscard]] static inline uint32_t ffListFirstIndexComp(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) { for (uint32_t i = 0; i < list->length; i++) { if (compFunc(ffListGet(list, elementSize, i), compElement)) { return i; @@ -59,7 +57,7 @@ FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, u return list->length; } -FF_A_NODISCARD static inline bool ffListContains(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) { +[[nodiscard]] static inline bool ffListContains(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) { return ffListFirstIndexComp(list, elementSize, compElement, compFunc) != list->length; } @@ -117,7 +115,7 @@ static inline void* ffListAdd(FFlist* list, uint32_t elementSize) { itemVarName - (itemType*) (listVar).data < (intptr_t) (listVar).length; \ ++itemVarName) -#define FF_LIST_AUTO_DESTROY FFlist FF_A_CLEANUP(ffListDestroy) +#define FF_LIST_AUTO_DESTROY [[gnu::cleanup(ffListDestroy)]] FFlist #define FF_LIST_GET(itemType, listVar, index) \ ({ \ diff --git a/src/common/FFstrbuf.h b/src/common/FFstrbuf.h index fff933a1d..7b40bb42d 100644 --- a/src/common/FFstrbuf.h +++ b/src/common/FFstrbuf.h @@ -1,7 +1,5 @@ #pragma once -#include "common/attributes.h" - #include #include #include @@ -37,15 +35,15 @@ static inline void ffStrbufInit(FFstrbuf* strbuf); void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate); void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments); void ffStrbufInitMoveNS(FFstrbuf* strbuf, uint32_t length, char* heapStr); -FF_A_PRINTF(2, 3) void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...); -FF_A_PRINTF(1, 2) FF_A_NODISCARD FFstrbuf ffStrbufCreateF(const char* format, ...); +[[gnu::format(printf, 2, 3)]] void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...); +[[gnu::format(printf, 1, 2)]] [[nodiscard]] FFstrbuf ffStrbufCreateF(const char* format, ...); void ffStrbufEnsureFixedLengthFree(FFstrbuf* strbuf, uint32_t free); void ffStrbufEnsureFreeNoCheck(FFstrbuf* strbuf, uint32_t free); static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value); void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int (*transformFunc)(int)); -FF_A_PRINTF(2, 3) void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...); +[[gnu::format(printf, 2, 3)]] void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...); void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments); const char* ffStrbufAppendSUntilC(FFstrbuf* strbuf, const char* value, char until); @@ -58,7 +56,7 @@ void ffStrbufInsertNC(FFstrbuf* strbuf, uint32_t index, uint32_t num, char c); // NOTE: Unlike ffStrbufAppend*, ffStrbufSet* functions may NOT reserve extra space void ffStrbufSet(FFstrbuf* strbuf, const FFstrbuf* value); void ffStrbufSetNS(FFstrbuf* strbuf, uint32_t length, const char* value); -FF_A_PRINTF(2, 3) void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...); +[[gnu::format(printf, 2, 3)]] void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...); void ffStrbufTrimLeft(FFstrbuf* strbuf, char c); void ffStrbufTrimRight(FFstrbuf* strbuf, char c); @@ -79,7 +77,7 @@ bool ffStrbufSubstrAfterFirstS(FFstrbuf* strbuf, const char* str); bool ffStrbufSubstrAfterLastC(FFstrbuf* strbuf, char c); bool ffStrbufSubstr(FFstrbuf* strbuf, uint32_t start, uint32_t end); -FF_A_NODISCARD uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c); +[[nodiscard]] uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c); bool ffStrbufRemoveIgnCaseEndS(FFstrbuf* strbuf, const char* end); @@ -135,7 +133,7 @@ void ffStrbufAppendUInt(FFstrbuf* strbuf, uint64_t value); // if `precision < 0`, let yyjson decide the precision void ffStrbufAppendDouble(FFstrbuf* strbuf, double value, int8_t precision, bool trailingZeros); -FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) { +[[nodiscard]] static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) { FFstrbuf strbuf; ffStrbufInitA(&strbuf, allocate); return strbuf; @@ -150,7 +148,7 @@ static inline void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf* } } -FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) { +[[nodiscard]] static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) { FFstrbuf strbuf; ffStrbufInitCopy(&strbuf, src); return strbuf; @@ -166,7 +164,7 @@ static inline void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) { } } -FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) { +[[nodiscard]] static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) { FFstrbuf strbuf; ffStrbufInitMove(&strbuf, src); return strbuf; @@ -185,7 +183,7 @@ static inline void ffStrbufDestroy(FFstrbuf* strbuf) { ffStrbufInit(strbuf); } -FF_A_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) { +[[nodiscard]] static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) { assert(strbuf != nullptr); if (strbuf->allocated == 0) { return 0; @@ -311,7 +309,7 @@ static inline void ffStrbufInit(FFstrbuf* strbuf) { strbuf->chars = CHAR_NULL_PTR; } -FF_A_NODISCARD static inline FFstrbuf ffStrbufCreate(void) { +[[nodiscard]] static inline FFstrbuf ffStrbufCreate(void) { FFstrbuf strbuf; ffStrbufInit(&strbuf); return strbuf; @@ -328,7 +326,7 @@ static inline void ffStrbufInitStatic(FFstrbuf* strbuf, const char* str) { strbuf->chars = (char*) str; } -FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateStatic(const char* str) { +[[nodiscard]] static inline FFstrbuf ffStrbufCreateStatic(const char* str) { FFstrbuf strbuf; ffStrbufInitStatic(&strbuf, str); return strbuf; @@ -351,7 +349,7 @@ static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char* ffStrbufAppendNS(strbuf, length, str); } -FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) { +[[nodiscard]] static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) { FFstrbuf strbuf; ffStrbufInitNS(&strbuf, length, str); return strbuf; @@ -367,7 +365,7 @@ static inline void ffStrbufInitS(FFstrbuf* strbuf, const char* str) { ffStrbufAppendS(strbuf, str); } -FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) { +[[nodiscard]] static inline FFstrbuf ffStrbufCreateS(const char* str) { FFstrbuf strbuf; ffStrbufInitS(&strbuf, str); return strbuf; @@ -387,93 +385,93 @@ static inline void ffStrbufPrependS(FFstrbuf* strbuf, const char* value) { ffStrbufPrependNS(strbuf, (uint32_t) strlen(value), value); } -static inline FF_A_NODISCARD int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) { +[[nodiscard]] static inline int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) { uint32_t length = strbuf->length > comp->length ? comp->length : strbuf->length; return memcmp(strbuf->chars, comp->chars, length + 1); } -static inline FF_A_NODISCARD bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) { +[[nodiscard]] static inline bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) { return ffStrbufComp(strbuf, comp) == 0; } -static inline FF_A_NODISCARD int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) { +[[nodiscard]] static inline int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) { return strcmp(strbuf->chars, comp); } -static inline FF_A_NODISCARD bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) { +[[nodiscard]] static inline bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) { return ffStrbufCompS(strbuf, comp) == 0; } -static inline FF_A_NODISCARD int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) { +[[nodiscard]] static inline int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) { return strcasecmp(strbuf->chars, comp); } -static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) { +[[nodiscard]] static inline bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) { return ffStrbufIgnCaseCompS(strbuf, comp) == 0; } -static inline FF_A_NODISCARD int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) { +[[nodiscard]] static inline int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) { return ffStrbufIgnCaseCompS(strbuf, comp->chars); } -static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) { +[[nodiscard]] static inline bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) { return ffStrbufIgnCaseComp(strbuf, comp) == 0; } -static inline FF_A_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c) { +[[nodiscard]] static inline bool ffStrbufContainC(const FFstrbuf* strbuf, char c) { return memchr(strbuf->chars, c, strbuf->length) != nullptr; } -static inline FF_A_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) { +[[nodiscard]] static inline bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) { return strstr(strbuf->chars, str) != nullptr; } -static inline FF_A_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) { +[[nodiscard]] static inline bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) { return ffStrbufContainS(strbuf, str->chars); } -static inline FF_A_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) { +[[nodiscard]] static inline bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) { return strcasestr(strbuf->chars, str) != nullptr; } -static inline FF_A_NODISCARD bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) { +[[nodiscard]] static inline bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) { return ffStrbufContainIgnCaseS(strbuf, str->chars); } -FF_A_NODISCARD static inline uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c) { +[[nodiscard]] static inline uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c) { assert(start <= strbuf->length); const char* ptr = (const char*) memchr(strbuf->chars + start, c, strbuf->length - start); return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length; } -FF_A_NODISCARD static inline uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str) { +[[nodiscard]] static inline uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str) { assert(start <= strbuf->length); const char* ptr = strstr(strbuf->chars + start, str); return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length; } -FF_A_NODISCARD static inline uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c) { +[[nodiscard]] static inline uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c) { assert(start <= strbuf->length); const char* ptr = (const char*) memrchr(strbuf->chars, c, start + 1); return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length; } -static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) { +[[nodiscard]] static inline uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) { return ffStrbufNextIndexC(strbuf, 0, c); } -static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) { +[[nodiscard]] static inline uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) { return ffStrbufNextIndexS(strbuf, 0, searched->chars); } -static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) { +[[nodiscard]] static inline uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) { return ffStrbufNextIndexS(strbuf, 0, str); } -static inline FF_A_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) { +[[nodiscard]] static inline uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) { if (strbuf->length == 0) { return 0; } @@ -489,11 +487,11 @@ static inline bool ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c) { return ffStrbufSubstrBefore(strbuf, ffStrbufLastIndexC(strbuf, c)); } -static inline FF_A_NODISCARD bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) { +[[nodiscard]] static inline bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) { return strbuf->chars[0] == c; } -static inline FF_A_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) { +[[nodiscard]] static inline bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) { if (length > strbuf->length) { return false; } @@ -501,34 +499,34 @@ static inline FF_A_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, c return memcmp(strbuf->chars, start, length) == 0; } -static inline FF_A_NODISCARD bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) { +[[nodiscard]] static inline bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) { return ffStrbufStartsWithSN(strbuf, start, (uint32_t) strlen(start)); } -static inline FF_A_NODISCARD bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) { +[[nodiscard]] static inline bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) { return ffStrbufStartsWithSN(strbuf, start->chars, start->length); } -static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) { +[[nodiscard]] static inline bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) { if (length > strbuf->length) { return false; } return strncasecmp(strbuf->chars, start, length) == 0; } -static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) { +[[nodiscard]] static inline bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) { return ffStrbufStartsWithIgnCaseNS(strbuf, (uint32_t) strlen(start), start); } -static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) { +[[nodiscard]] static inline bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) { return ffStrbufStartsWithIgnCaseNS(strbuf, start->length, start->chars); } -static inline FF_A_NODISCARD bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) { +[[nodiscard]] static inline bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) { return strbuf->length == 0 ? false : strbuf->chars[strbuf->length - 1] == c; } -static inline FF_A_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) { +[[nodiscard]] static inline bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) { if (endLength > strbuf->length) { return false; } @@ -536,30 +534,30 @@ static inline FF_A_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uin return memcmp(strbuf->chars + strbuf->length - endLength, end, endLength) == 0; } -static inline FF_A_NODISCARD bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) { +[[nodiscard]] static inline bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) { return ffStrbufEndsWithNS(strbuf, (uint32_t) strlen(end), end); } -static inline FF_A_NODISCARD bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) { +[[nodiscard]] static inline bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) { return strbuf->length == 0 ? false : fn(strbuf->chars[strbuf->length - 1]); } -static inline FF_A_NODISCARD bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) { +[[nodiscard]] static inline bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) { return ffStrbufEndsWithNS(strbuf, end->length, end->chars); } -static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) { +[[nodiscard]] static inline bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) { if (endLength > strbuf->length) { return false; } return strcasecmp(strbuf->chars + strbuf->length - endLength, end) == 0; } -static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) { +[[nodiscard]] static inline bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) { return ffStrbufEndsWithIgnCaseNS(strbuf, (uint32_t) strlen(end), end); } -static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) { +[[nodiscard]] static inline bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) { return ffStrbufEndsWithIgnCaseNS(strbuf, end->length, end->chars); } @@ -614,19 +612,19 @@ static inline void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file) { fputc('\n', file); } -FF_A_NODISCARD static inline double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue) { +[[nodiscard]] static inline double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue) { char* str_end; double result = strtod(strbuf->chars, &str_end); return str_end == strbuf->chars ? defaultValue : result; } -FF_A_NODISCARD static inline uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue) { +[[nodiscard]] static inline uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue) { char* str_end; unsigned long long result = strtoull(strbuf->chars, &str_end, 10); return str_end == strbuf->chars ? defaultValue : (uint64_t) result; } -FF_A_NODISCARD static inline int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue) { +[[nodiscard]] static inline int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue) { char* str_end; long long result = strtoll(strbuf->chars, &str_end, 10); return str_end == strbuf->chars ? defaultValue : (int64_t) result; @@ -635,4 +633,4 @@ FF_A_NODISCARD static inline int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int6 // Returns true if the strbuf is modified bool ffStrbufDecodeHexEscapeSequences(FFstrbuf* strbuf); -#define FF_STRBUF_AUTO_DESTROY FFstrbuf FF_A_CLEANUP(ffStrbufDestroy) +#define FF_STRBUF_AUTO_DESTROY [[gnu::cleanup(ffStrbufDestroy)]] FFstrbuf diff --git a/src/common/apple/cf_helpers.h b/src/common/apple/cf_helpers.h index 6801668d4..3df16b594 100644 --- a/src/common/apple/cf_helpers.h +++ b/src/common/apple/cf_helpers.h @@ -32,7 +32,7 @@ static inline void cfReleaseWrapper(void* type) { } } -#define FF_CFTYPE_AUTO_RELEASE FF_A_CLEANUP(cfReleaseWrapper) +#define FF_CFTYPE_AUTO_RELEASE [[gnu::cleanup(cfReleaseWrapper)]] static inline void wrapIoObjectRelease(io_object_t* service) { assert(service); @@ -40,4 +40,4 @@ static inline void wrapIoObjectRelease(io_object_t* service) { IOObjectRelease(*service); } } -#define FF_IOOBJECT_AUTO_RELEASE FF_A_CLEANUP(wrapIoObjectRelease) +#define FF_IOOBJECT_AUTO_RELEASE [[gnu::cleanup(wrapIoObjectRelease)]] diff --git a/src/common/attributes.h b/src/common/attributes.h deleted file mode 100644 index a7b964c4d..000000000 --- a/src/common/attributes.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#ifndef __has_attribute - #error Unsupported compiler - #define __attribute__(x) -#endif - -#define FF_A_FALLTHROUGH __attribute__((__fallthrough__)) -#define FF_A_DEPRECATED __attribute__((__deprecated__)) -#define FF_A_CLEANUP(func) __attribute__((__cleanup__(func))) -#define FF_A_NODISCARD __attribute__((__warn_unused_result__)) -#define FF_A_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__(printf, formatStrIndex, argsStartIndex))) -#define FF_A_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__(scanf, formatStrIndex, argsStartIndex))) -#define FF_A_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__))) -#define FF_A_RETURNS_NONNULL __attribute__((__returns_nonnull__)) -#define FF_A_UNUSED __attribute__((__unused__)) -#define FF_A_PACKED __attribute__((__packed__)) -#define FF_A_WEAK_IMPORT __attribute__((__weak_import__)) -#define FF_A_ALWAYS_INLINE __attribute__((__always_inline__)) -#define FF_A_COLD __attribute__((__cold__)) diff --git a/src/common/dbus.h b/src/common/dbus.h index 0c9850ff1..e4274180a 100644 --- a/src/common/dbus.h +++ b/src/common/dbus.h @@ -41,6 +41,6 @@ static inline DBusMessage* ffDBusGetAllProperties(FFDBusData* dbus, const char* return ffDBusGetMethodReply(dbus, busName, objectPath, "org.freedesktop.DBus.Properties", "GetAll", interface, nullptr); } - #define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData) + #define FF_DBUS_AUTO_DESTROY_DATA [[gnu::cleanup(ffDBusDestroyData)]] #endif // FF_HAVE_DBUS diff --git a/src/common/impl/binary_apple.c b/src/common/impl/binary_apple.c index fce33246d..c25df7a92 100644 --- a/src/common/impl/binary_apple.c +++ b/src/common/impl/binary_apple.c @@ -273,7 +273,7 @@ const char* ffBinaryExtractStrings(const char* machoFile, bool (*cb)(const char* return "Failed to stat file"; } - FF_A_CLEANUP(wrapMunmap) FFMemoryMapping mapping = { + [[gnu::cleanup(wrapMunmap)]] FFMemoryMapping mapping = { .data = mmap(nullptr, (size_t) st.st_size, PROT_READ, MAP_PRIVATE, fd, 0), .length = (size_t) st.st_size, }; diff --git a/src/common/impl/commandoption.c b/src/common/impl/commandoption.c index bd80825c4..eacf4eab9 100644 --- a/src/common/impl/commandoption.c +++ b/src/common/impl/commandoption.c @@ -82,7 +82,7 @@ void ffPrepareCommandOption(FFdata* data) { case 'D': case 'd': FF_IF_MODULE_MATCH(FF_DISKIO_MODULE_NAME) { - FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options; + [[gnu::cleanup(ffDestroyDiskIOOptions)]] FFDiskIOOptions options; ffInitDiskIOOptions(&options); ffPrepareDiskIO(&options); } @@ -93,7 +93,7 @@ void ffPrepareCommandOption(FFdata* data) { case 'N': case 'n': FF_IF_MODULE_MATCH(FF_NETIO_MODULE_NAME) { - FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options; + [[gnu::cleanup(ffDestroyNetIOOptions)]] FFNetIOOptions options; ffInitNetIOOptions(&options); ffPrepareNetIO(&options); } @@ -104,7 +104,7 @@ void ffPrepareCommandOption(FFdata* data) { case 'P': case 'p': FF_IF_MODULE_MATCH(FF_PUBLICIP_MODULE_NAME) { - FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options; + [[gnu::cleanup(ffDestroyPublicIpOptions)]] FFPublicIPOptions options; ffInitPublicIpOptions(&options); ffPreparePublicIp(&options); } @@ -115,7 +115,7 @@ void ffPrepareCommandOption(FFdata* data) { case 'W': case 'w': FF_IF_MODULE_MATCH(FF_WEATHER_MODULE_NAME) { - FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options; + [[gnu::cleanup(ffDestroyWeatherOptions)]] FFWeatherOptions options; ffInitWeatherOptions(&options); ffPrepareWeather(&options); } diff --git a/src/common/impl/format.c b/src/common/impl/format.c index eb2ae57e5..978011bd1 100644 --- a/src/common/impl/format.c +++ b/src/common/impl/format.c @@ -112,7 +112,7 @@ static inline bool formatArgSet(const FFformatarg* arg) { return arg->value != nullptr && ((arg->type == FF_ARG_TYPE_DOUBLE && *(double*) arg->value > 0.0) || (arg->type == FF_ARG_TYPE_FLOAT && *(float*) arg->value > 0.0) || (arg->type == FF_ARG_TYPE_INT && *(int32_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_STRBUF && ((FFstrbuf*) arg->value)->length > 0) || (arg->type == FF_ARG_TYPE_STRING && ffStrSet((char*) arg->value)) || (arg->type == FF_ARG_TYPE_UINT8 && *(uint8_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT16 && *(uint16_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT && *(uint32_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT64 && *(uint64_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_BOOL && *(bool*) arg->value) || (arg->type == FF_ARG_TYPE_LIST && ((FFlist*) arg->value)->length > 0)); } -FF_A_UNUSED static inline void normalizeArgName(FFstrbuf* dst, const char* src) { +[[maybe_unused]] static inline void normalizeArgName(FFstrbuf* dst, const char* src) { ffStrbufClear(dst); bool flag = false; for (const char* p = src; *p; ++p) { diff --git a/src/common/impl/init.c b/src/common/impl/init.c index 3b167745c..8f6edbe7f 100644 --- a/src/common/impl/init.c +++ b/src/common/impl/init.c @@ -105,12 +105,12 @@ static void resetConsole(void) { } #ifdef _WIN32 -BOOL WINAPI consoleHandler(FF_A_UNUSED DWORD signal) { +BOOL WINAPI consoleHandler([[maybe_unused]] DWORD signal) { resetConsole(); exit(0); } #else -static void exitSignalHandler(FF_A_UNUSED int signal) { +static void exitSignalHandler([[maybe_unused]] int signal) { resetConsole(); exit(0); } diff --git a/src/common/impl/io_unix.c b/src/common/impl/io_unix.c index a4d8273d3..840df3be6 100644 --- a/src/common/impl/io_unix.c +++ b/src/common/impl/io_unix.c @@ -34,7 +34,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data) { int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC; mode_t openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; - int FF_AUTO_CLOSE_FD fd = open(fileName, openFlagsModes, openFlagsRights); + FF_AUTO_CLOSE_FD int fd = open(fileName, openFlagsModes, openFlagsRights); if (fd == -1) { if (errno == ENOENT) { createSubfolders(fileName); diff --git a/src/common/impl/io_windows.c b/src/common/impl/io_windows.c index ff78a14f1..b9691eb39 100644 --- a/src/common/impl/io_windows.c +++ b/src/common/impl/io_windows.c @@ -157,7 +157,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data) { } } - HANDLE FF_AUTO_CLOSE_FD handle = CreateFileW(fileNameW, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + FF_AUTO_CLOSE_FD HANDLE handle = CreateFileW(fileNameW, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle == INVALID_HANDLE_VALUE) { if (GetLastError() == ERROR_PATH_NOT_FOUND) { if (!createSubfolders(fileNameW)) { diff --git a/src/common/impl/jsonconfig.c b/src/common/impl/jsonconfig.c index fc093313a..9feee1bf5 100644 --- a/src/common/impl/jsonconfig.c +++ b/src/common/impl/jsonconfig.c @@ -139,7 +139,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { if (ffStrEqualsIgnCase(type, FF_CPUUSAGE_MODULE_NAME)) { ffPrepareCPUUsage(); } else if (ffStrEqualsIgnCase(type, FF_COMMAND_MODULE_NAME)) { - FF_A_CLEANUP(ffDestroyCommandOptions) FFCommandOptions options; + [[gnu::cleanup(ffDestroyCommandOptions)]] FFCommandOptions options; ffInitCommandOptions(&options); if (module) { ffCommandModuleInfo.parseJsonObject(&options, module); @@ -154,7 +154,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'd': case 'D': { if (ffStrEqualsIgnCase(type, FF_DISKIO_MODULE_NAME)) { - FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options; + [[gnu::cleanup(ffDestroyDiskIOOptions)]] FFDiskIOOptions options; ffInitDiskIOOptions(&options); if (module) { ffDiskIOModuleInfo.parseJsonObject(&options, module); @@ -169,7 +169,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'n': case 'N': { if (ffStrEqualsIgnCase(type, FF_NETIO_MODULE_NAME)) { - FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options; + [[gnu::cleanup(ffDestroyNetIOOptions)]] FFNetIOOptions options; ffInitNetIOOptions(&options); if (module) { ffNetIOModuleInfo.parseJsonObject(&options, module); @@ -184,7 +184,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'p': case 'P': { if (ffStrEqualsIgnCase(type, FF_PUBLICIP_MODULE_NAME)) { - FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options; + [[gnu::cleanup(ffDestroyPublicIpOptions)]] FFPublicIPOptions options; ffInitPublicIpOptions(&options); if (module) { ffPublicIPModuleInfo.parseJsonObject(&options, module); @@ -199,7 +199,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'w': case 'W': { if (ffStrEqualsIgnCase(type, FF_WEATHER_MODULE_NAME)) { - FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options; + [[gnu::cleanup(ffDestroyWeatherOptions)]] FFWeatherOptions options; ffInitWeatherOptions(&options); if (module) { ffWeatherModuleInfo.parseJsonObject(&options, module); diff --git a/src/common/impl/kmod_nbsd.c b/src/common/impl/kmod_nbsd.c index 19f18a05d..2352bb52c 100644 --- a/src/common/impl/kmod_nbsd.c +++ b/src/common/impl/kmod_nbsd.c @@ -4,7 +4,7 @@ #include #include -typedef struct FF_A_PACKED FFNbsdModList { +typedef struct [[gnu::packed]] FFNbsdModList { int len; modstat_t mods[]; } FFNbsdModList; diff --git a/src/common/impl/kmod_nosupport.c b/src/common/impl/kmod_nosupport.c index c254ba7b2..6335a7fd1 100644 --- a/src/common/impl/kmod_nosupport.c +++ b/src/common/impl/kmod_nosupport.c @@ -1,5 +1,5 @@ #include "common/kmod.h" -bool ffKmodLoaded(FF_A_UNUSED const char* modName) { +bool ffKmodLoaded([[maybe_unused]] const char* modName) { return true; // Don't generate kernel module related errors } diff --git a/src/common/impl/library.c b/src/common/impl/library.c index 08ba5055b..440ea1336 100644 --- a/src/common/impl/library.c +++ b/src/common/impl/library.c @@ -108,7 +108,7 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...) { #if _WIN32 -void* dlopen(const char* path, FF_A_UNUSED int mode) { +void* dlopen(const char* path, [[maybe_unused]] int mode) { wchar_t pathW[MAX_PATH + 1]; ULONG pathWBytes = 0; diff --git a/src/common/impl/netif_linux.c b/src/common/impl/netif_linux.c index 67e486821..a881c779d 100644 --- a/src/common/impl/netif_linux.c +++ b/src/common/impl/netif_linux.c @@ -44,7 +44,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { uint32_t pid = ffNetifGetNetlinkPortId(sock_fd); - struct FF_A_PACKED { + struct [[gnu::packed]] { struct nlmsghdr nlh; struct rtmsg rtm; struct rtattr rta; @@ -97,7 +97,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) { uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient uint32_t minMetric = UINT32_MAX; - FF_A_UNUSED int routeCount = 0; + [[maybe_unused]] int routeCount = 0; while (true) { ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, (struct sockaddr*) &src_addr, &src_addr_len); @@ -254,7 +254,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { uint32_t pid = ffNetifGetNetlinkPortId(sock_fd); - struct FF_A_PACKED { + struct [[gnu::packed]] { struct nlmsghdr nlh; struct rtmsg rtm; struct rtattr rta; @@ -307,7 +307,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient uint32_t minMetric = UINT32_MAX; - FF_A_UNUSED int routeCount = 0; + [[maybe_unused]] int routeCount = 0; while (true) { ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, (struct sockaddr*) &src_addr, &src_addr_len); @@ -382,7 +382,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { switch (rta->rta_type) { case RTA_DST: if (RTA_PAYLOAD(rta) >= sizeof(struct in6_addr)) { - FF_A_UNUSED char str[INET6_ADDRSTRLEN]; + [[maybe_unused]] char str[INET6_ADDRSTRLEN]; FF_DEBUG("Unexpected RTA_DST: %s", inet_ntop(AF_INET6, RTA_DATA(rta), str, sizeof(str))); goto next; } @@ -399,7 +399,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) { if (IN6_IS_ADDR_UNSPECIFIED(gw)) { goto next; } - FF_A_UNUSED char str[INET6_ADDRSTRLEN]; + [[maybe_unused]] char str[INET6_ADDRSTRLEN]; FF_DEBUG("Found gateway: %s", inet_ntop(AF_INET6, gw, str, sizeof(str))); } break; diff --git a/src/common/impl/networking_linux.c b/src/common/impl/networking_linux.c index 9dcdd72cd..0d31b4602 100644 --- a/src/common/impl/networking_linux.c +++ b/src/common/impl/networking_linux.c @@ -261,7 +261,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos if (state->timeout > 0) { FF_DEBUG("Setting connection timeout: %u ms", state->timeout); - FF_A_UNUSED uint32_t sec = state->timeout / 1000; + [[maybe_unused]] uint32_t sec = state->timeout / 1000; if (sec == 0) { sec = 1; } @@ -417,7 +417,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf } FF_DEBUG("Starting data reception"); - FF_A_UNUSED int recvCount = 0; + [[maybe_unused]] int recvCount = 0; uint32_t contentLength = 0; uint32_t headerEnd = 0; diff --git a/src/common/impl/networking_windows.c b/src/common/impl/networking_windows.c index 019306b6d..ba4af1dc8 100644 --- a/src/common/impl/networking_windows.c +++ b/src/common/impl/networking_windows.c @@ -275,7 +275,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf } FF_DEBUG("Starting data reception"); - FF_A_UNUSED int recvCount = 0; + [[maybe_unused]] int recvCount = 0; uint32_t contentLength = 0; uint32_t headerEnd = 0; diff --git a/src/common/impl/settings.c b/src/common/impl/settings.c index 28a91b186..0f00054df 100644 --- a/src/common/impl/settings.c +++ b/src/common/impl/settings.c @@ -603,7 +603,7 @@ bool ffSettingsGetEnlightenmentProperty(ffEnlightenmentSettings* result) { return !!parsed; } #else -bool ffSettingsGetEnlightenmentProperty(FF_A_UNUSED ffEnlightenmentSettings* result) { +bool ffSettingsGetEnlightenmentProperty([[maybe_unused]] ffEnlightenmentSettings* result) { return false; } #endif diff --git a/src/common/impl/smbios.c b/src/common/impl/smbios.c index 88d898344..fc7df14b3 100644 --- a/src/common/impl/smbios.c +++ b/src/common/impl/smbios.c @@ -66,7 +66,7 @@ static bool parseSmbiosTable(const uint8_t* data, uint32_t length) { const FFSmbiosHeader* endOfTable = nullptr; FF_DEBUG("Parsing SMBIOS table structures with length %u bytes", length); - FF_A_UNUSED int structureCount = 0, totalCount = 0; + [[maybe_unused]] int structureCount = 0, totalCount = 0; for ( const FFSmbiosHeader* header = (const FFSmbiosHeader*) data; (const uint8_t*) header + sizeof(FFSmbiosHeader) < (const uint8_t*) data + length; @@ -228,7 +228,7 @@ static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffe return true; } -typedef struct FFSmbios20EntryPoint { +typedef struct [[gnu::packed]] FFSmbios20EntryPoint { uint8_t AnchorString[4]; uint8_t EntryPointStructureChecksum; uint8_t EntryPointLength; @@ -243,11 +243,11 @@ typedef struct FFSmbios20EntryPoint { uint32_t StructureTableAddress; uint16_t NumberOfSmbiosStructures; uint8_t SmbiosBcdRevision; -} FF_A_PACKED FFSmbios20EntryPoint; +} FFSmbios20EntryPoint; static_assert(offsetof(FFSmbios20EntryPoint, SmbiosBcdRevision) == 0x1E, "FFSmbios20EntryPoint: Wrong struct alignment"); -typedef struct FFSmbios30EntryPoint { +typedef struct [[gnu::packed]] FFSmbios30EntryPoint { uint8_t AnchorString[5]; uint8_t EntryPointStructureChecksum; uint8_t EntryPointLength; @@ -258,7 +258,7 @@ typedef struct FFSmbios30EntryPoint { uint8_t Reversed; uint32_t StructureTableMaximumSize; uint64_t StructureTableAddress; -} FF_A_PACKED FFSmbios30EntryPoint; +} FFSmbios30EntryPoint; static_assert(offsetof(FFSmbios30EntryPoint, StructureTableAddress) == 0x10, "FFSmbios30EntryPoint: Wrong struct alignment"); diff --git a/src/common/impl/strutil.c b/src/common/impl/strutil.c index 3a801f7e8..095452dbc 100644 --- a/src/common/impl/strutil.c +++ b/src/common/impl/strutil.c @@ -1,4 +1,5 @@ #include "common/strutil.h" +#include "common/wcwidth.h" uint8_t ffUtf8CharLenWidth(const char* str, uint32_t length, uint8_t* width) { if (__builtin_expect(length == 0 || *str == '\0', false)) { diff --git a/src/common/impl/time.c b/src/common/impl/time.c index c60d1fece..4f52d25ab 100644 --- a/src/common/impl/time.c +++ b/src/common/impl/time.c @@ -89,7 +89,7 @@ FFTimeGetAgeResult ffTimeGetAge(uint64_t birthMs, uint64_t nowMs) { #ifdef _WIN32 double ffQpcMultiplier; -__attribute__((constructor)) static void ffTimeInitQpcMultiplier(void) { +[[gnu::constructor]] static void ffTimeInitQpcMultiplier(void) { LARGE_INTEGER frequency; RtlQueryPerformanceFrequency(&frequency); ffQpcMultiplier = 1000. / (double) frequency.QuadPart; diff --git a/src/common/impl/tracer.c b/src/common/impl/tracer.c index b54f88467..aa46ad545 100644 --- a/src/common/impl/tracer.c +++ b/src/common/impl/tracer.c @@ -30,7 +30,7 @@ static struct trace_event { } events[4 * 1024 * 1024]; // 4M events, 96 MiB memory usage static _Atomic uint32_t event_count; -__attribute__((no_instrument_function, always_inline)) static inline uint64_t get_time_us() { +[[gnu::no_instrument_function, gnu::always_inline]] static inline uint64_t get_time_us() { #if !_WIN32 struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -43,12 +43,12 @@ __attribute__((no_instrument_function, always_inline)) static inline uint64_t ge } #if _WIN32 -__attribute__((constructor, no_instrument_function)) void trace_init() { +[[gnu::constructor, gnu::no_instrument_function]] void trace_init() { QueryPerformanceFrequency(&freq); } #endif -__attribute__((destructor, no_instrument_function)) void trace_fini() { +[[gnu::destructor, gnu::no_instrument_function]] void trace_fini() { #if _WIN32 uint32_t pid = (uint32_t) GetCurrentProcessId(); #else @@ -115,7 +115,7 @@ __attribute__((destructor, no_instrument_function)) void trace_fini() { #endif } -__attribute__((no_instrument_function)) static void write_event(void* this_fn, bool is_exit) { +[[gnu::no_instrument_function]] static void write_event(void* this_fn, bool is_exit) { uint32_t idx = atomic_fetch_add_explicit(&event_count, 1, memory_order_relaxed); if (__builtin_expect(idx >= sizeof(events) / sizeof(events[0]), false)) { abort(); @@ -137,12 +137,12 @@ __attribute__((no_instrument_function)) static void write_event(void* this_fn, b } } -__attribute__((no_instrument_function)) void __cyg_profile_func_enter(void* this_fn, void* call_site) { +[[gnu::no_instrument_function]] void __cyg_profile_func_enter(void* this_fn, void* call_site) { (void) call_site; write_event(this_fn, false); } -__attribute__((no_instrument_function)) void __cyg_profile_func_exit(void* this_fn, void* call_site) { +[[gnu::no_instrument_function]] void __cyg_profile_func_exit(void* this_fn, void* call_site) { (void) call_site; write_event(this_fn, true); } diff --git a/src/common/io.h b/src/common/io.h index 2012d0db0..9086bea43 100644 --- a/src/common/io.h +++ b/src/common/io.h @@ -40,7 +40,6 @@ HANDLE openat(HANDLE dfd, const char* fileName, int oflag); HANDLE openatW(HANDLE dfd, const wchar_t* fileName, uint16_t fileNameLen, bool directory); #endif -FF_A_ALWAYS_INLINE static inline bool ffIsValidNativeFD(FFNativeFD fd) { #ifndef _WIN32 return fd >= 0; @@ -50,7 +49,7 @@ static inline bool ffIsValidNativeFD(FFNativeFD fd) { #endif } -FF_A_ALWAYS_INLINE FF_A_NONNULL(1) +[[gnu::always_inline, gnu::nonnull(1)]] static inline void wrapClose(FFNativeFD* pfd) { assert(pfd); @@ -62,7 +61,7 @@ static inline void wrapClose(FFNativeFD* pfd) { #endif } } -#define FF_AUTO_CLOSE_FD FF_A_CLEANUP(wrapClose) +#define FF_AUTO_CLOSE_FD [[gnu::cleanup(wrapClose)]] static inline FFNativeFD FFUnixFD2NativeFD(int unixfd) { #ifndef _WIN32 @@ -72,7 +71,8 @@ static inline FFNativeFD FFUnixFD2NativeFD(int unixfd) { #endif } -FF_A_NONNULL(3) static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* data) { +[[gnu::nonnull(3)]] +static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* data) { #ifndef _WIN32 return write(fd, data, dataSize) != -1; #else @@ -81,17 +81,21 @@ FF_A_NONNULL(3) static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, #endif } -FF_A_NONNULL(2) static inline bool ffWriteFDBuffer(FFNativeFD fd, const FFstrbuf* content) { +[[gnu::nonnull(2)]] +static inline bool ffWriteFDBuffer(FFNativeFD fd, const FFstrbuf* content) { return ffWriteFDData(fd, content->length, content->chars); } -FF_A_NONNULL(1, 3) bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data); +[[gnu::nonnull(1, 3)]] +bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data); -FF_A_NONNULL(1, 2) static inline bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer) { +[[gnu::nonnull(1, 2)]] +static inline bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer) { return ffWriteFileData(fileName, buffer->length, buffer->chars); } -FF_A_NONNULL(3) static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data) { +[[gnu::nonnull(3)]] +static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data) { #ifndef _WIN32 return read(fd, data, dataSize); #else @@ -104,10 +108,10 @@ FF_A_NONNULL(3) static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSiz #endif } -FF_A_NONNULL(2) bool ffAppendFDBuffer(FFNativeFD fd, FFstrbuf* buffer); +[[gnu::nonnull(2)]] bool ffAppendFDBuffer(FFNativeFD fd, FFstrbuf* buffer); -FF_A_NONNULL(1, 3) static inline ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data) { - FFNativeFD FF_AUTO_CLOSE_FD fd = +[[gnu::nonnull(1, 3)]] static inline ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data) { + FF_AUTO_CLOSE_FD FFNativeFD fd = #ifndef _WIN32 open(fileName, O_RDONLY | O_CLOEXEC); #else @@ -121,8 +125,8 @@ FF_A_NONNULL(1, 3) static inline ssize_t ffReadFileData(const char* fileName, si return ffReadFDData(fd, dataSize, data); } -FF_A_NONNULL(2, 4) static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileName, size_t dataSize, void* data) { - FFNativeFD FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC); +[[gnu::nonnull(2, 4)]] static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileName, size_t dataSize, void* data) { + FF_AUTO_CLOSE_FD FFNativeFD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC); if (!ffIsValidNativeFD(fd)) { return -1; } @@ -130,8 +134,8 @@ FF_A_NONNULL(2, 4) static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, return ffReadFDData(fd, dataSize, data); } -FF_A_NONNULL(1, 2) static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) { - FFNativeFD FF_AUTO_CLOSE_FD fd = +[[gnu::nonnull(1, 2)]] static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) { + FF_AUTO_CLOSE_FD FFNativeFD fd = #ifndef _WIN32 open(fileName, O_RDONLY | O_CLOEXEC); #else @@ -145,8 +149,8 @@ FF_A_NONNULL(1, 2) static inline bool ffAppendFileBuffer(const char* fileName, F return ffAppendFDBuffer(fd, buffer); } -FF_A_NONNULL(2, 3) static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) { - FFNativeFD FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC); +[[gnu::nonnull(2, 3)]] static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) { + FF_AUTO_CLOSE_FD FFNativeFD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC); if (!ffIsValidNativeFD(fd)) { return false; } @@ -154,17 +158,17 @@ FF_A_NONNULL(2, 3) static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, return ffAppendFDBuffer(fd, buffer); } -FF_A_NONNULL(2) static inline bool ffReadFDBuffer(FFNativeFD fd, FFstrbuf* buffer) { +[[gnu::nonnull(2)]] static inline bool ffReadFDBuffer(FFNativeFD fd, FFstrbuf* buffer) { ffStrbufClear(buffer); return ffAppendFDBuffer(fd, buffer); } -FF_A_NONNULL(1, 2) static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer) { +[[gnu::nonnull(1, 2)]] static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer) { ffStrbufClear(buffer); return ffAppendFileBuffer(fileName, buffer); } -FF_A_NONNULL(2, 3) static inline bool ffReadFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) { +[[gnu::nonnull(2, 3)]] static inline bool ffReadFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) { ffStrbufClear(buffer); return ffAppendFileBufferRelative(dfd, fileName, buffer); } @@ -175,7 +179,7 @@ typedef enum FFPathType: uint8_t { FF_PATHTYPE_ANY = FF_PATHTYPE_FILE | FF_PATHTYPE_DIRECTORY, } FFPathType; -FF_A_NONNULL(1) static inline bool ffPathExists(const char* path, FFPathType pathType) { +[[gnu::nonnull(1)]] static inline bool ffPathExists(const char* path, FFPathType pathType) { #ifdef _WIN32 wchar_t wPath[MAX_PATH]; @@ -224,13 +228,11 @@ FF_A_NONNULL(1) static inline bool ffPathExists(const char* path, FFPathType pat return false; } -FF_A_NONNULL(1, 2) bool ffPathExpandEnv(const char* in, FFstrbuf* out); +[[gnu::nonnull(1, 2)]] bool ffPathExpandEnv(const char* in, FFstrbuf* out); #define FF_IO_TERM_RESP_WAIT_MS 100 // #554 -FF_A_SCANF(3, 4) -FF_A_NONNULL(1, 3) -const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...); +[[gnu::format(scanf, 3, 4), gnu::nonnull(1, 3)]] const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...); // Not thread safe! bool ffSuppressIO(bool suppress); @@ -243,19 +245,19 @@ static inline void ffUnsuppressIO(bool* suppressed) { *suppressed = false; } -#define FF_SUPPRESS_IO() bool FF_A_CLEANUP(ffUnsuppressIO) FF_A_UNUSED io_suppressed__ = ffSuppressIO(true) +#define FF_SUPPRESS_IO() [[maybe_unused, gnu::cleanup(ffUnsuppressIO)]] bool io_suppressed__ = ffSuppressIO(true) void ffListFilesRecursively(const char* path, bool pretty); -FF_A_NONNULL(1) FF_A_ALWAYS_INLINE static inline void wrapFclose(FILE** pfile) { +[[gnu::nonnull(1), gnu::always_inline]] static inline void wrapFclose(FILE** pfile) { assert(pfile); if (*pfile) { fclose(*pfile); } } -#define FF_AUTO_CLOSE_FILE FF_A_CLEANUP(wrapFclose) +#define FF_AUTO_CLOSE_FILE [[gnu::cleanup(wrapFclose)]] -FF_A_NONNULL(1) FF_A_ALWAYS_INLINE +[[gnu::nonnull(1), gnu::always_inline]] #ifndef _WIN32 static inline void wrapClosedir(DIR** pdir) { assert(pdir); @@ -271,9 +273,9 @@ static inline void wrapClosedir(HANDLE* pdir) { } } #endif -#define FF_AUTO_CLOSE_DIR FF_A_CLEANUP(wrapClosedir) +#define FF_AUTO_CLOSE_DIR [[gnu::cleanup(wrapClosedir)]] -FF_A_NONNULL(1, 2, 3) static inline bool ffSearchUserConfigFile(const FFlist* configDirs, const char* fileSubpath, FFstrbuf* result) { +[[gnu::nonnull(1, 2, 3)]] static inline bool ffSearchUserConfigFile(const FFlist* configDirs, const char* fileSubpath, FFstrbuf* result) { // configDirs is a list of FFstrbufs include the trailing slash FF_LIST_FOR_EACH (FFstrbuf, dir, *configDirs) { ffStrbufClear(result); diff --git a/src/common/library.h b/src/common/library.h index 4d6cf2df1..7ee80cd9c 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -6,8 +6,8 @@ #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); +[[nodiscard]] void* dlopen(const char* path, int mode); +[[nodiscard]] void* dlsym(void* handle, const char* symbol); int dlclose(void* handle); #else #include @@ -36,7 +36,7 @@ static inline void ffLibraryUnload(void** handle) { __typeof__(&symbolName) ff##symbolName; #define FF_LIBRARY_LOAD(libraryObjectName, returnValue, libraryFileName, maxVersion, ...) \ - void* FF_A_CLEANUP(ffLibraryUnload) libraryObjectName = ffLibraryLoadSingle(libraryFileName, maxVersion); \ + [[gnu::cleanup(ffLibraryUnload)]] void* libraryObjectName = ffLibraryLoadSingle(libraryFileName, maxVersion); \ __VA_OPT__(if (__builtin_expect(libraryObjectName == nullptr, false)) libraryObjectName = ffLibraryLoadMulti(__VA_ARGS__, nullptr);) \ if (__builtin_expect(libraryObjectName == nullptr, false)) \ return returnValue; @@ -78,7 +78,7 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...); __typeof__(&symbolName) ff##symbolName; #define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ - FF_A_UNUSED void* libraryObjectName = nullptr; // Placeholder + [[maybe_unused]] void* libraryObjectName = nullptr; // Placeholder #define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \ FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__) @@ -87,13 +87,13 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...); symbolMapping = (__typeof__(&symbolName)) &symbolName; #define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ - FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue); + [[maybe_unused]] __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue); #define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \ - FF_A_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName; + [[maybe_unused]] __auto_type ff##symbolName = (__typeof__(&symbolName)) &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"); + [[maybe_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) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, returnValue); diff --git a/src/common/lua.h b/src/common/lua.h index 06343c40e..fab613f12 100644 --- a/src/common/lua.h +++ b/src/common/lua.h @@ -63,95 +63,95 @@ extern struct FFLuaData { } luaData; #if !FF_DISABLE_DLOPEN -FF_A_ALWAYS_INLINE void(lua_settop)(lua_State* L, int idx) { +[[gnu::always_inline]] void(lua_settop)(lua_State* L, int idx) { return luaData.fflua_settop(L, idx); } -FF_A_ALWAYS_INLINE int(luaL_loadbufferx)(lua_State* L, const char* buff, size_t sz, const char* name, const char* mode) { +[[gnu::always_inline]] int(luaL_loadbufferx)(lua_State* L, const char* buff, size_t sz, const char* name, const char* mode) { return luaData.ffluaL_loadbufferx(L, buff, sz, name, mode); } -FF_A_ALWAYS_INLINE const char*(lua_tolstring) (lua_State * L, int idx, size_t* len) { +[[gnu::always_inline]] const char*(lua_tolstring) (lua_State * L, int idx, size_t* len) { return luaData.fflua_tolstring(L, idx, len); } -FF_A_ALWAYS_INLINE void(lua_createtable)(lua_State* L, int narr, int nrec) { +[[gnu::always_inline]] void(lua_createtable)(lua_State* L, int narr, int nrec) { return luaData.fflua_createtable(L, narr, nrec); } -FF_A_ALWAYS_INLINE void(lua_pushinteger)(lua_State* L, lua_Integer n) { +[[gnu::always_inline]] void(lua_pushinteger)(lua_State* L, lua_Integer n) { return luaData.fflua_pushinteger(L, n); } -FF_A_ALWAYS_INLINE void(lua_pushnumber)(lua_State* L, lua_Number n) { +[[gnu::always_inline]] void(lua_pushnumber)(lua_State* L, lua_Number n) { return luaData.fflua_pushnumber(L, n); } -FF_A_ALWAYS_INLINE void(lua_pushboolean)(lua_State* L, int b) { +[[gnu::always_inline]] void(lua_pushboolean)(lua_State* L, int b) { return luaData.fflua_pushboolean(L, b); } -FF_A_ALWAYS_INLINE const char*(lua_pushlstring) (lua_State * L, const char* s, size_t len) { +[[gnu::always_inline]] const char*(lua_pushlstring) (lua_State * L, const char* s, size_t len) { return luaData.fflua_pushlstring(L, s, len); } -FF_A_ALWAYS_INLINE void(lua_pushvalue)(lua_State* L, int idx) { +[[gnu::always_inline]] void(lua_pushvalue)(lua_State* L, int idx) { return luaData.fflua_pushvalue(L, idx); } -FF_A_ALWAYS_INLINE void(lua_seti)(lua_State* L, int idx, lua_Integer n) { +[[gnu::always_inline]] void(lua_seti)(lua_State* L, int idx, lua_Integer n) { return luaData.fflua_seti(L, idx, n); } -FF_A_ALWAYS_INLINE void(lua_pushnil)(lua_State* L) { +[[gnu::always_inline]] void(lua_pushnil)(lua_State* L) { return luaData.fflua_pushnil(L); } -FF_A_ALWAYS_INLINE void(lua_setfield)(lua_State* L, int idx, const char* k) { +[[gnu::always_inline]] void(lua_setfield)(lua_State* L, int idx, const char* k) { return luaData.fflua_setfield(L, idx, k); } -FF_A_ALWAYS_INLINE int(lua_pcallk)(lua_State* L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k) { +[[gnu::always_inline]] int(lua_pcallk)(lua_State* L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k) { return luaData.fflua_pcallk(L, nargs, nresults, errfunc, ctx, k); } -FF_A_ALWAYS_INLINE int(lua_gettop)(lua_State* L) { +[[gnu::always_inline]] int(lua_gettop)(lua_State* L) { return luaData.fflua_gettop(L); } -FF_A_ALWAYS_INLINE const char*(luaL_tolstring) (lua_State * L, int idx, size_t* len) { +[[gnu::always_inline]] const char*(luaL_tolstring) (lua_State * L, int idx, size_t* len) { return luaData.ffluaL_tolstring(L, idx, len); } -FF_A_ALWAYS_INLINE int(lua_error)(lua_State* L) { +[[gnu::always_inline]] int(lua_error)(lua_State* L) { return luaData.fflua_error(L); } -FF_A_ALWAYS_INLINE void(lua_pushcclosure)(lua_State* L, lua_CFunction fn, int n) { +[[gnu::always_inline]] void(lua_pushcclosure)(lua_State* L, lua_CFunction fn, int n) { return luaData.fflua_pushcclosure(L, fn, n); } -FF_A_ALWAYS_INLINE void(luaL_checkany)(lua_State* L, int idx) { +[[gnu::always_inline]] void(luaL_checkany)(lua_State* L, int idx) { return luaData.ffluaL_checkany(L, idx); } -FF_A_ALWAYS_INLINE void(lua_callk)(lua_State* L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k) { +[[gnu::always_inline]] void(lua_callk)(lua_State* L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k) { return luaData.fflua_callk(L, nargs, nresults, ctx, k); } -FF_A_ALWAYS_INLINE int(lua_isinteger)(lua_State* L, int idx) { +[[gnu::always_inline]] int(lua_isinteger)(lua_State* L, int idx) { return luaData.fflua_isinteger(L, idx); } -FF_A_ALWAYS_INLINE int(lua_next)(lua_State* L, int idx) { +[[gnu::always_inline]] int(lua_next)(lua_State* L, int idx) { return luaData.fflua_next(L, idx); } -FF_A_ALWAYS_INLINE int(lua_rawgeti)(lua_State* L, int idx, lua_Integer n) { +[[gnu::always_inline]] int(lua_rawgeti)(lua_State* L, int idx, lua_Integer n) { return luaData.fflua_rawgeti(L, idx, n); } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] #if LUA_VERSION_NUM > 503 lua_Unsigned #else @@ -161,23 +161,23 @@ size_t return luaData.fflua_rawlen(L, idx); } -FF_A_ALWAYS_INLINE void(lua_setglobal)(lua_State* L, const char* name) { +[[gnu::always_inline]] void(lua_setglobal)(lua_State* L, const char* name) { return luaData.fflua_setglobal(L, name); } -FF_A_ALWAYS_INLINE int(lua_toboolean)(lua_State* L, int idx) { +[[gnu::always_inline]] int(lua_toboolean)(lua_State* L, int idx) { return luaData.fflua_toboolean(L, idx); } -FF_A_ALWAYS_INLINE lua_Integer(lua_tointegerx)(lua_State* L, int idx, int* isnum) { +[[gnu::always_inline]] lua_Integer(lua_tointegerx)(lua_State* L, int idx, int* isnum) { return luaData.fflua_tointegerx(L, idx, isnum); } -FF_A_ALWAYS_INLINE lua_Number(lua_tonumberx)(lua_State* L, int idx, int* isnum) { +[[gnu::always_inline]] lua_Number(lua_tonumberx)(lua_State* L, int idx, int* isnum) { return luaData.fflua_tonumberx(L, idx, isnum); } -FF_A_ALWAYS_INLINE int(lua_type)(lua_State* L, int idx) { +[[gnu::always_inline]] int(lua_type)(lua_State* L, int idx) { return luaData.fflua_type(L, idx); } #endif diff --git a/src/common/mallocHelper.h b/src/common/mallocHelper.h index a13011838..e0c182948 100644 --- a/src/common/mallocHelper.h +++ b/src/common/mallocHelper.h @@ -2,7 +2,6 @@ #include #include -#include "common/attributes.h" #if FF_HAVE_MALLOC_USABLE_SIZE || FF_HAVE_MSVC_MSIZE #if __has_include() @@ -14,7 +13,7 @@ #include #endif -FF_A_ALWAYS_INLINE FF_A_NONNULL(1) +[[gnu::always_inline, gnu::nonnull(1)]] static inline void ffWrapFree(const void* pPtr) { assert(pPtr); if (*(void**) pPtr) { @@ -22,7 +21,7 @@ static inline void ffWrapFree(const void* pPtr) { } } -#define FF_AUTO_FREE FF_A_CLEANUP(ffWrapFree) +#define FF_AUTO_FREE [[gnu::cleanup(ffWrapFree)]] // ptr MUST be a malloc'ed pointer static inline size_t ffMallocUsableSize(const void* ptr) { diff --git a/src/common/option.h b/src/common/option.h index 9fdf0bceb..9f54d3c1a 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -65,10 +65,10 @@ typedef struct FFKeyValuePair { const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName); void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer); -FF_A_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); -FF_A_NODISCARD int32_t ffOptionParseInt32(const char* argumentKey, const char* value); -FF_A_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]); -FF_A_NODISCARD bool ffOptionParseBoolean(const char* str); +[[nodiscard]] uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); +[[nodiscard]] int32_t ffOptionParseInt32(const char* argumentKey, const char* value); +[[nodiscard]] int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]); +[[nodiscard]] bool ffOptionParseBoolean(const char* str); void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer); static inline void ffOptionParseColor(const char* value, FFstrbuf* buffer) { ffStrbufClear(buffer); diff --git a/src/common/printing.h b/src/common/printing.h index 6963bf026..29f8c1227 100644 --- a/src/common/printing.h +++ b/src/common/printing.h @@ -15,6 +15,6 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu bool ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments); #define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, arguments) \ ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (sizeof(arguments) / sizeof(*arguments)), (arguments)); -FF_A_PRINTF(5, 6) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...); +[[gnu::format(printf, 5, 6)]] void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...); void ffPrintColor(const FFstrbuf* colorValue); void ffPrintCharTimes(char c, uint32_t times); diff --git a/src/common/smbios.h b/src/common/smbios.h index 744717cc6..15c0b0ce6 100644 --- a/src/common/smbios.h +++ b/src/common/smbios.h @@ -67,7 +67,7 @@ typedef enum FFSmbiosType : uint8_t { } FFSmbiosType; static_assert(sizeof(FFSmbiosType) == 1, "FFSmbiosType should be 1 byte"); -typedef struct FFSmbiosHeader { +typedef struct [[gnu::packed]] FFSmbiosHeader { // Type of SMBIOS structure. Do NOT test `Type == FF_SMBIOS_END_OF_TABLE` to determine the end of the table, // as malformed tables may be missing the end-of-table marker. // **Use FFSmbiosHeaderTable[FF_SMBIOS_TYPE_END_OF_TABLE] pointer instead.** @@ -79,7 +79,7 @@ typedef struct FFSmbiosHeader { // Not guaranteed to be consistent across reboots or even multiple reads of the same table. // Must be less than 0xFF00 uint16_t Handle; -} FF_A_PACKED FFSmbiosHeader; +} FFSmbiosHeader; static_assert(sizeof(FFSmbiosHeader) == 4, "FFSmbiosHeader should be 4 bytes"); static inline const char* ffSmbiosLocateString(const char* start, uint8_t index /* start from 1 */) { diff --git a/src/common/strutil.h b/src/common/strutil.h index b6c36afae..a9c43c495 100644 --- a/src/common/strutil.h +++ b/src/common/strutil.h @@ -5,9 +5,6 @@ #include #include -#include "common/attributes.h" -#include "common/wcwidth.h" - #ifdef _WIN32 // #include __stdcall char* StrStrIA(const char* lpFirst, const char* lpSrch); @@ -29,17 +26,17 @@ static inline bool ffStrSet(const char* str) { return *str != '\0'; } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffStrStartsWithIgnCase(const char* str, const char* compareTo) { return strncasecmp(str, compareTo, strlen(compareTo)) == 0; } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffStrEqualsIgnCase(const char* str, const char* compareTo) { return strcasecmp(str, compareTo) == 0; } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffStrStartsWith(const char* str, const char* compareTo) { return strncmp(str, compareTo, strlen(compareTo)) == 0; } @@ -62,32 +59,32 @@ static inline bool ffStrEndsWithIgnCase(const char* str, const char* compareTo) return strncasecmp(str + strLength - compareToLength, compareTo, compareToLength) == 0; } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffStrEquals(const char* str, const char* compareTo) { return strcmp(str, compareTo) == 0; } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffStrContains(const char* str, const char* compareTo) { return strstr(str, compareTo) != nullptr; } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffStrContainsIgnCase(const char* str, const char* compareTo) { return strcasestr(str, compareTo) != nullptr; } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffStrContainsC(const char* str, char compareTo) { return strchr(str, compareTo) != nullptr; } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffCharIsEnglishAlphabet(char c) { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'); } -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffCharIsDigit(char c) { return '0' <= c && c <= '9'; } @@ -99,7 +96,7 @@ uint8_t ffUtf8CharLenWidth(const char* str, uint32_t length, uint8_t* width); uint32_t ffUtf8StrWidth(const char* str, uint32_t length); -FF_A_ALWAYS_INLINE +[[gnu::always_inline]] static inline bool ffCharIsHexDigit(char c) { return ffCharIsDigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F'); } diff --git a/src/common/sysctl.h b/src/common/sysctl.h index 1baabe628..7e59ec663 100644 --- a/src/common/sysctl.h +++ b/src/common/sysctl.h @@ -7,11 +7,11 @@ #ifdef __OpenBSD__ const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result); -FF_A_NODISCARD int ffSysctlGetInt(int mib1, int mib2, int defaultValue); -FF_A_NODISCARD int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue); +[[nodiscard]] int ffSysctlGetInt(int mib1, int mib2, int defaultValue); +[[nodiscard]] int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue); #else const char* ffSysctlGetString(const char* propName, FFstrbuf* result); -FF_A_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue); -FF_A_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue); +[[nodiscard]] int ffSysctlGetInt(const char* propName, int defaultValue); +[[nodiscard]] int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue); #endif -FF_A_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength); +[[nodiscard]] void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength); diff --git a/src/common/thread.h b/src/common/thread.h index be82def60..c8212c255 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -90,7 +90,7 @@ static inline FFThreadType ffThreadCreate(void* (*func)(void*), void* data) { static inline void ffThreadDetach(FFThreadType thread) { pthread_detach(thread); } -static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeout) { +static inline bool ffThreadJoin(FFThreadType thread, [[maybe_unused]] uint32_t timeout) { #if HAVE_TIMEDJOIN_NP if (timeout > 0) { struct timespec ts; @@ -115,7 +115,7 @@ static inline uintptr_t ffThreadGetCurrentId() { #else // FF_HAVE_THREADS #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) {} +static inline void ffThreadMutexLock([[maybe_unused]] FFThreadMutex* mutex) {} +static inline void ffThreadMutexUnlock([[maybe_unused]] FFThreadMutex* mutex) {} #define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) #endif // FF_HAVE_THREADS diff --git a/src/common/windows/com.h b/src/common/windows/com.h index d7a7dc090..34de125dd 100644 --- a/src/common/windows/com.h +++ b/src/common/windows/com.h @@ -1,6 +1,5 @@ #pragma once -#include "common/attributes.h" #include #include @@ -20,4 +19,4 @@ static inline void ffReleaseComObject(void* ppUnknown) { } } -#define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject) +#define FF_AUTO_RELEASE_COM_OBJECT [[gnu::cleanup(ffReleaseComObject)]] diff --git a/src/common/windows/wmi.h b/src/common/windows/wmi.h index aa50c0043..2ff6282f5 100644 --- a/src/common/windows/wmi.h +++ b/src/common/windows/wmi.h @@ -49,6 +49,4 @@ static inline void ffCloseWmiBlock(HANDLE* hBlock) { } } -#define FF_AUTO_CLOSE_WMI_BLOCK __attribute__((cleanup(ffCloseWmiBlock))) - // MOF: https://github.com/tpn/winsdk-10/blob/master/Include/10.0.16299.0/km/wmicore.mof diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index 5b8176069..325be96cb 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_android.c @@ -21,7 +21,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results) { return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; } - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); + [[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); if (!doc) { return "Failed to parse battery info"; } diff --git a/src/detection/battery/battery_bsd.c b/src/detection/battery/battery_bsd.c index a51f72708..cff41d5a6 100644 --- a/src/detection/battery/battery_bsd.c +++ b/src/detection/battery/battery_bsd.c @@ -8,7 +8,7 @@ #include #include -const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) { +const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) { // https://www.freebsd.org/cgi/man.cgi?acpi_battery(4) // https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c diff --git a/src/detection/battery/battery_haiku.c b/src/detection/battery/battery_haiku.c index 22726bf32..523d33d93 100644 --- a/src/detection/battery/battery_haiku.c +++ b/src/detection/battery/battery_haiku.c @@ -53,7 +53,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) { return nullptr; } -const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) { +const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) { FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/"); if (!dir) { return "opendir(/dev/power/acpi_battery) failed"; diff --git a/src/detection/battery/battery_nbsd.c b/src/detection/battery/battery_nbsd.c index fda4ef0db..eaf1fc715 100644 --- a/src/detection/battery/battery_nbsd.c +++ b/src/detection/battery/battery_nbsd.c @@ -14,7 +14,7 @@ #include #include -const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) { +const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) { FF_AUTO_CLOSE_FD int fd = open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC); if (fd < 0) { return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed"; diff --git a/src/detection/battery/battery_obsd.c b/src/detection/battery/battery_obsd.c index 8de17bcd9..c5c6c3c39 100644 --- a/src/detection/battery/battery_obsd.c +++ b/src/detection/battery/battery_obsd.c @@ -6,7 +6,7 @@ #include #include -const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* result) { +const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* result) { FF_AUTO_CLOSE_FD int devfd = open("/dev/apm", O_RDONLY | O_CLOEXEC); if (devfd < 0) { diff --git a/src/detection/battery/battery_windows.c b/src/detection/battery/battery_windows.c index 7a57c191b..720d5cbd3 100644 --- a/src/detection/battery/battery_windows.c +++ b/src/detection/battery/battery_windows.c @@ -51,7 +51,7 @@ static FFBatteryWmiEntry* getBatteryEntry(FFlist* entries, FFlist* results, ULON } static const char* queryWmiAllData(const GUID* guid, const char* guidStr, PWNODE_ALL_DATA* pAllData, ULONG* pBufferSize) { - FF_AUTO_CLOSE_WMI_BLOCK HANDLE hBlock = nullptr; + [[gnu::cleanup(ffCloseWmiBlock)]] HANDLE hBlock = nullptr; ULONG status = WmiOpenBlock(guid, WMIGUID_QUERY, &hBlock); if (status != ERROR_SUCCESS) { FF_DEBUG("WMI: WmiOpenBlock() failed for %s: %s", guidStr, ffDebugWin32Error(status)); diff --git a/src/detection/bios/bios_nosupport.c b/src/detection/bios/bios_nosupport.c index e04483570..a8b055e1e 100644 --- a/src/detection/bios/bios_nosupport.c +++ b/src/detection/bios/bios_nosupport.c @@ -1,5 +1,5 @@ #include "bios.h" -const char* ffDetectBios(FF_A_UNUSED FFBiosResult* bios) { +const char* ffDetectBios([[maybe_unused]] FFBiosResult* bios) { return "Not supported on this platform"; } diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index 211d6a9b0..b1d309f5e 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -19,7 +19,7 @@ #include #endif -typedef struct FFSmbiosBios { +typedef struct [[gnu::packed]] FFSmbiosBios { FFSmbiosHeader Header; uint8_t Vendor; // string @@ -38,7 +38,7 @@ typedef struct FFSmbiosBios { // 3.1+ uint16_t ExtendedBiosRomSize; // bit field -} FF_A_PACKED FFSmbiosBios; +} FFSmbiosBios; static_assert(offsetof(FFSmbiosBios, ExtendedBiosRomSize) == 0x18, "FFSmbiosBios: Wrong struct alignment"); diff --git a/src/detection/bluetooth/bluetooth_bsd.c b/src/detection/bluetooth/bluetooth_bsd.c index b70157753..af1d6effd 100644 --- a/src/detection/bluetooth/bluetooth_bsd.c +++ b/src/detection/bluetooth/bluetooth_bsd.c @@ -3,7 +3,7 @@ #define L2CAP_SOCKET_CHECKED #include -static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* devices) { +static int enumDev([[maybe_unused]] int sockfd, struct bt_devinfo const* dev, FFlist* devices) { FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices); ffStrbufInitS(&device->name, #if __FreeBSD__ @@ -20,7 +20,7 @@ static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* return 0; } -const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) { +const char* ffDetectBluetooth([[maybe_unused]] FFBluetoothOptions* options, [[maybe_unused]] FFlist* devices /* FFBluetoothResult */) { // struct hostent* ent = bt_gethostent(); if (bt_devenum((void*) enumDev, devices) < 0) { return "bt_devenum() failed"; diff --git a/src/detection/bluetooth/bluetooth_haiku.cpp b/src/detection/bluetooth/bluetooth_haiku.cpp index 7efb69722..b4479d600 100644 --- a/src/detection/bluetooth/bluetooth_haiku.cpp +++ b/src/detection/bluetooth/bluetooth_haiku.cpp @@ -5,7 +5,7 @@ extern "C" { #include -const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) { +const char* ffDetectBluetooth([[maybe_unused]] FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) { using namespace Bluetooth; FF_SUPPRESS_IO(); diff --git a/src/detection/bluetooth/bluetooth_nosupport.c b/src/detection/bluetooth/bluetooth_nosupport.c index ac93ceed4..ae54eb055 100644 --- a/src/detection/bluetooth/bluetooth_nosupport.c +++ b/src/detection/bluetooth/bluetooth_nosupport.c @@ -1,5 +1,5 @@ #include "bluetooth.h" -const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) { +const char* ffDetectBluetooth([[maybe_unused]] FFBluetoothOptions* options, [[maybe_unused]] FFlist* devices /* FFBluetoothResult */) { return "Not supported on this platform"; } diff --git a/src/detection/bluetooth/bluetooth_windows.c b/src/detection/bluetooth/bluetooth_windows.c index ac0d2f49f..8f765c21a 100644 --- a/src/detection/bluetooth/bluetooth_windows.c +++ b/src/detection/bluetooth/bluetooth_windows.c @@ -38,7 +38,7 @@ static const char* ffBluetoothDetectBattery(FFlist* devices) { return nullptr; } - wchar_t* FF_AUTO_FREE idList = (wchar_t*) malloc((size_t) idListLength * sizeof(wchar_t)); + FF_AUTO_FREE wchar_t* idList = (wchar_t*) malloc((size_t) idListLength * sizeof(wchar_t)); if (!idList) { return "malloc() failed"; } diff --git a/src/detection/bluetoothradio/bluetoothradio_nosupport.c b/src/detection/bluetoothradio/bluetoothradio_nosupport.c index 08fb6f8a7..feeab46a3 100644 --- a/src/detection/bluetoothradio/bluetoothradio_nosupport.c +++ b/src/detection/bluetoothradio/bluetoothradio_nosupport.c @@ -1,5 +1,5 @@ #include "bluetoothradio.h" -const char* ffDetectBluetoothRadio(FF_A_UNUSED FFlist* devices /* FFBluetoothRadioResult */) { +const char* ffDetectBluetoothRadio([[maybe_unused]] FFlist* devices /* FFBluetoothRadioResult */) { return "Not supported on this platform"; } diff --git a/src/detection/bluetoothradio/bluetoothradio_windows.c b/src/detection/bluetoothradio/bluetoothradio_windows.c index 8bb672b21..11f7879d5 100644 --- a/src/detection/bluetoothradio/bluetoothradio_windows.c +++ b/src/detection/bluetoothradio/bluetoothradio_windows.c @@ -14,7 +14,7 @@ #define IOCTL_BTH_GET_LOCAL_INFO BTH_CTL(BTH_IOCTL_BASE + 0x00) #define LMP_LE_SUPPORTED(x) ((x >> 38) & 1) -typedef struct _BTH_RADIO_INFO { +typedef struct [[gnu::packed]] _BTH_RADIO_INFO { // Supported LMP features of the radio. Use LMP_XXX() to extract // the desired bits. ULONGLONG lmpSupportedFeatures; @@ -27,9 +27,9 @@ typedef struct _BTH_RADIO_INFO { // LMP version UCHAR lmpVersion; -} FF_A_PACKED BTH_RADIO_INFO; +} BTH_RADIO_INFO; -typedef struct _BTH_LOCAL_RADIO_INFO { +typedef struct [[gnu::packed]] _BTH_LOCAL_RADIO_INFO { // Local BTH_ADDR, class of device, and radio name BTH_DEVICE_INFO localInfo; @@ -44,7 +44,7 @@ typedef struct _BTH_LOCAL_RADIO_INFO { // More information about the local radio (LMP, MFG) BTH_RADIO_INFO radioInfo; -} FF_A_PACKED BTH_LOCAL_RADIO_INFO; +} BTH_LOCAL_RADIO_INFO; static_assert(sizeof(BTH_LOCAL_RADIO_INFO) == 292, "BTH_LOCAL_RADIO_INFO should be 292 bytes"); #pragma GCC diagnostic ignored "-Wpointer-sign" diff --git a/src/detection/board/board_nosupport.c b/src/detection/board/board_nosupport.c index befc63083..1b7bf1e31 100644 --- a/src/detection/board/board_nosupport.c +++ b/src/detection/board/board_nosupport.c @@ -1,5 +1,5 @@ #include "board.h" -const char* ffDetectBoard(FF_A_UNUSED FFBoardResult* board) { +const char* ffDetectBoard([[maybe_unused]] FFBoardResult* board) { return "Not supported on this platform"; } diff --git a/src/detection/board/board_windows.c b/src/detection/board/board_windows.c index 599dad034..7ce50032d 100644 --- a/src/detection/board/board_windows.c +++ b/src/detection/board/board_windows.c @@ -1,7 +1,7 @@ #include "board.h" #include "common/smbios.h" -typedef struct FFSmbiosBaseboard { +typedef struct [[gnu::packed]] FFSmbiosBaseboard { FFSmbiosHeader Header; uint8_t Manufacturer; // string @@ -15,7 +15,7 @@ typedef struct FFSmbiosBaseboard { uint8_t BoardType; // enum uint8_t NumberOfContainedObjectHandles; // varies uint16_t ContainedObjectHandles[]; // varies -} FF_A_PACKED FFSmbiosBaseboard; +} FFSmbiosBaseboard; static_assert(offsetof(FFSmbiosBaseboard, ContainedObjectHandles) == 0x0F, "FFSmbiosBaseboard: Wrong struct alignment"); diff --git a/src/detection/bootmgr/bootmgr_nosupport.c b/src/detection/bootmgr/bootmgr_nosupport.c index bb0171427..12b7f84c6 100644 --- a/src/detection/bootmgr/bootmgr_nosupport.c +++ b/src/detection/bootmgr/bootmgr_nosupport.c @@ -1,5 +1,5 @@ #include "bootmgr.h" -const char* ffDetectBootmgr(FF_A_UNUSED FFBootmgrResult* result) { +const char* ffDetectBootmgr([[maybe_unused]] FFBootmgrResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index 013e3e84e..14f490067 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -9,21 +9,21 @@ // DDC/CI #ifdef __aarch64__ typedef CFTypeRef IOAVServiceRef; -extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) FF_A_WEAK_IMPORT; -extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) FF_A_WEAK_IMPORT; -extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) FF_A_WEAK_IMPORT; -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; +[[clang::weak_import]] extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator); +[[clang::weak_import]] extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service); +[[clang::weak_import]] extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2); +[[clang::weak_import]] extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize); +[[clang::weak_import]] extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize); #else // DDC/CI (Intel) #include #include #include -extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service) FF_A_WEAK_IMPORT; +[[clang::weak_import]] extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service); #endif // ACPI -extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* brightness) FF_A_WEAK_IMPORT; +[[clang::weak_import]] extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* brightness); // Works for internal display static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* result) { @@ -51,7 +51,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa #ifdef __aarch64__ // https://github.com/waydabber/m1ddc // Works for Apple Silicon and USB-C adapter connection ( but not HTMI ) -static const char* detectWithDdcci(FF_A_UNUSED const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) { +static const char* detectWithDdcci([[maybe_unused]] const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) { if (!IOAVServiceCreate || !IOAVServiceReadI2C || !IOAVServiceWriteI2C) { return "IOAVService is not available"; } diff --git a/src/detection/brightness/brightness_bsd.c b/src/detection/brightness/brightness_bsd.c index 93c48aad3..bf09098b2 100644 --- a/src/detection/brightness/brightness_bsd.c +++ b/src/detection/brightness/brightness_bsd.c @@ -12,7 +12,7 @@ #if __has_include() #include -const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* detectWithDdcci([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { // FIXME: doesn't work for me for (char i = '0'; i <= '9'; ++i) { char path[] = "/dev/iic0"; @@ -74,7 +74,7 @@ const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* re #else -const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) { +const char* detectWithDdcci([[maybe_unused]] FFBrightnessOptions* options, [[maybe_unused]] FFlist* result) { FF_DEBUG("DDC/CI support is not available on this system"); return "DDC/CI is supported only on FreeBSD"; } @@ -84,7 +84,7 @@ const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSE #if __has_include() #include -const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* detectWithBacklight([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { // https://man.freebsd.org/cgi/man.cgi?query=backlight&sektion=9 char path[] = "/dev/backlight/backlight0"; @@ -130,14 +130,14 @@ const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FFlist #else -const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) { +const char* detectWithBacklight([[maybe_unused]] FFBrightnessOptions* options, [[maybe_unused]] FFlist* result) { FF_DEBUG("Backlight support is not available on this system"); return "Backlight is supported only on FreeBSD 13 and newer"; } #endif -const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { detectWithBacklight(options, result); if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && result->length == 0) { diff --git a/src/detection/brightness/brightness_haiku.cpp b/src/detection/brightness/brightness_haiku.cpp index aadf9c9ca..0c189da82 100644 --- a/src/detection/brightness/brightness_haiku.cpp +++ b/src/detection/brightness/brightness_haiku.cpp @@ -6,7 +6,7 @@ extern "C" { #include #include -const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { // We need a valid be_app to query the app_server here. BApplication app("application/x-vnd.fastfetch-cli-fastfetch"); BScreen screen{}; // default screen is the main one diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index afac0fa7d..ab82ac0b5 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -90,7 +90,7 @@ double ddca_set_default_sleep_multiplier(double multiplier); // ddcutil 1.4 DDCA_Status ddca_init(const char* libopts, int syslog_level, int opts); #endif -static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +static const char* detectWithDdcci([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { FF_LIBRARY_LOAD_MESSAGE(libddcutil, "libddcutil" FF_LIBRARY_EXTENSION, 5); FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_display_info_list2) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_open_display2) @@ -158,7 +158,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl } #endif -const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { detectWithBacklight(result); #ifdef FF_HAVE_DDCUTIL diff --git a/src/detection/brightness/brightness_nbsd.c b/src/detection/brightness/brightness_nbsd.c index 9b556bbe1..56dd39ce5 100644 --- a/src/detection/brightness/brightness_nbsd.c +++ b/src/detection/brightness/brightness_nbsd.c @@ -2,7 +2,7 @@ #include "common/sysctl.h" -const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { // https://man.netbsd.org/NetBSD-10.1/acpiout.4#DESCRIPTION char key[] = "hw.acpi.acpiout0.brightness"; char* pn = key + strlen("hw.acpi.acpiout"); diff --git a/src/detection/brightness/brightness_nosupport.c b/src/detection/brightness/brightness_nosupport.c index 6e9284e96..4cc53e5ec 100644 --- a/src/detection/brightness/brightness_nosupport.c +++ b/src/detection/brightness/brightness_nosupport.c @@ -1,5 +1,5 @@ #include "brightness.h" -const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) { +const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, [[maybe_unused]] FFlist* result) { return "Not supported on this platform"; } diff --git a/src/detection/brightness/brightness_obsd.c b/src/detection/brightness/brightness_obsd.c index c93cc6f68..2c9847c66 100644 --- a/src/detection/brightness/brightness_obsd.c +++ b/src/detection/brightness/brightness_obsd.c @@ -6,7 +6,7 @@ #include #include -const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { char path[] = "/dev/ttyCX"; for (char i = '0'; i <= '9'; ++i) { path[strlen("/dev/ttyC")] = i; diff --git a/src/detection/brightness/brightness_windows.c b/src/detection/brightness/brightness_windows.c index 7f26adabc..fc3bf8270 100644 --- a/src/detection/brightness/brightness_windows.c +++ b/src/detection/brightness/brightness_windows.c @@ -45,7 +45,7 @@ static const char* detectWithWmi(FFlist* result) { 0xd43412ac, 0x67f9, 0x4fbb, { 0xa0, 0x81, 0x17, 0x52, 0xa2, 0xc3, 0x3e, 0x84 } }; - FF_AUTO_CLOSE_WMI_BLOCK HANDLE hBlock = nullptr; + [[gnu::cleanup(ffCloseWmiBlock)]] HANDLE hBlock = nullptr; ULONG status = WmiOpenBlock(&WmiMonitorBrightnessGuid, WMIGUID_QUERY, &hBlock); if (status != 0) { @@ -204,7 +204,7 @@ static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer) { return false; } -const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) { const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); FF_DEBUG("start, displayCount=%u", displayServer->displays.length); diff --git a/src/detection/btrfs/btrfs_nosupport.c b/src/detection/btrfs/btrfs_nosupport.c index b51d2c5cd..62e041bb2 100644 --- a/src/detection/btrfs/btrfs_nosupport.c +++ b/src/detection/btrfs/btrfs_nosupport.c @@ -1,5 +1,5 @@ #include "btrfs.h" -const char* ffDetectBtrfs(FF_A_UNUSED FFlist* result) { +const char* ffDetectBtrfs([[maybe_unused]] FFlist* result) { return "Not supported on this platform"; } diff --git a/src/detection/camera/camera_android.c b/src/detection/camera/camera_android.c index 9b6c99890..9a82668d6 100644 --- a/src/detection/camera/camera_android.c +++ b/src/detection/camera/camera_android.c @@ -13,14 +13,14 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) { } } -const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { +const char* ffDetectCamera([[maybe_unused]] FFlist* result) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, nullptr })) { return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; } - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); + [[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); if (!doc) { return "Failed to parse camera info"; } diff --git a/src/detection/camera/camera_apple.m b/src/detection/camera/camera_apple.m index 603bcd598..da6884486 100644 --- a/src/detection/camera/camera_apple.m +++ b/src/detection/camera/camera_apple.m @@ -8,7 +8,7 @@ #ifdef MAC_OS_VERSION_14_0 // To make fastfetch compiled on newer macOS versions runs on older ones -AVF_EXPORT FF_A_WEAK_IMPORT AVCaptureDeviceType const AVCaptureDeviceTypeExternal; +[[clang::weak_import]] AVF_EXPORT AVCaptureDeviceType const AVCaptureDeviceTypeExternal; #endif const char* ffDetectCamera(FFlist* result) diff --git a/src/detection/camera/camera_nosupport.c b/src/detection/camera/camera_nosupport.c index ae5b2432d..ca8e64a16 100644 --- a/src/detection/camera/camera_nosupport.c +++ b/src/detection/camera/camera_nosupport.c @@ -1,5 +1,5 @@ #include "camera.h" -const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { +const char* ffDetectCamera([[maybe_unused]] FFlist* result) { return "Not support on this platform"; } diff --git a/src/detection/camera/camera_windows.cpp b/src/detection/camera/camera_windows.cpp index 0d24a9eb3..22d2fdec1 100644 --- a/src/detection/camera/camera_windows.cpp +++ b/src/detection/camera/camera_windows.cpp @@ -10,7 +10,7 @@ extern "C" { #include #include -extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { +extern "C" const char* ffDetectCamera([[maybe_unused]] FFlist* result) { FF_LIBRARY_LOAD_MESSAGE(mfplat, "mfplat" FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mfplat, MFCreateAttributes) FF_LIBRARY_LOAD_MESSAGE(mf, "mf" FF_LIBRARY_EXTENSION, 1) @@ -21,7 +21,7 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { return error; } - IMFAttributes* FF_AUTO_RELEASE_COM_OBJECT attrs = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMFAttributes* attrs = nullptr; if (FAILED(ffMFCreateAttributes(&attrs, 1))) { return "MFCreateAttributes() failed"; } @@ -40,7 +40,7 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { } for (uint32_t i = 0; i < count; i++) { - IMFActivate* FF_AUTO_RELEASE_COM_OBJECT device = devices[i]; + FF_AUTO_RELEASE_COM_OBJECT IMFActivate* device = devices[i]; wchar_t buffer[256]; uint32_t length = 0; @@ -60,25 +60,25 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { ffStrbufSetNWS(&camera->id, length, buffer); } - IMFMediaSource* FF_AUTO_RELEASE_COM_OBJECT source = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMFMediaSource* source = nullptr; if (FAILED(device->ActivateObject(IID_PPV_ARGS(&source)))) { continue; } on_scope_exit destroySource([&] { source->Shutdown(); }); - IMFPresentationDescriptor* FF_AUTO_RELEASE_COM_OBJECT pd = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMFPresentationDescriptor* pd = nullptr; if (FAILED(source->CreatePresentationDescriptor(&pd))) { continue; } - IMFStreamDescriptor* FF_AUTO_RELEASE_COM_OBJECT sd = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMFStreamDescriptor* sd = nullptr; BOOL selected; if (FAILED(pd->GetStreamDescriptorByIndex(0, &selected, &sd))) { continue; } - IMFMediaTypeHandler* FF_AUTO_RELEASE_COM_OBJECT handler = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMFMediaTypeHandler* handler = nullptr; if (FAILED(sd->GetMediaTypeHandler(&handler))) { continue; } diff --git a/src/detection/chassis/chassis_nosupport.c b/src/detection/chassis/chassis_nosupport.c index 0fc4dd949..4b7318080 100644 --- a/src/detection/chassis/chassis_nosupport.c +++ b/src/detection/chassis/chassis_nosupport.c @@ -1,5 +1,5 @@ #include "chassis.h" -const char* ffDetectChassis(FF_A_UNUSED FFChassisResult* result) { +const char* ffDetectChassis([[maybe_unused]] FFChassisResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/chassis/chassis_windows.c b/src/detection/chassis/chassis_windows.c index 5ffc9a45a..25b37f85a 100644 --- a/src/detection/chassis/chassis_windows.c +++ b/src/detection/chassis/chassis_windows.c @@ -2,7 +2,7 @@ #include "common/smbios.h" // 7.4 -typedef struct FFSmbiosSystemEnclosure { +typedef struct [[gnu::packed]] FFSmbiosSystemEnclosure { FFSmbiosHeader Header; uint8_t Manufacturer; // string @@ -24,7 +24,7 @@ typedef struct FFSmbiosSystemEnclosure { uint8_t ContainedElementCount; // varies uint8_t ContainedRecordLength; // varies uint8_t ContainedElements[]; // varies -} FF_A_PACKED FFSmbiosSystemEnclosure; +} FFSmbiosSystemEnclosure; static_assert(offsetof(FFSmbiosSystemEnclosure, ContainedElements) == 0x15, "FFSmbiosSystemEnclosure: Wrong struct alignment"); diff --git a/src/detection/codec/codec_windows.cpp b/src/detection/codec/codec_windows.cpp index 9e2183959..9124d484b 100644 --- a/src/detection/codec/codec_windows.cpp +++ b/src/detection/codec/codec_windows.cpp @@ -278,7 +278,7 @@ static const FFCodecMftEncoderSubtype FF_D3D11VA_MFT_ENCODER_SUBTYPES[] = { }; static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, __typeof__(&D3D11CreateDevice) ffD3D11CreateDevice) { - ID3D11Device* FF_AUTO_RELEASE_COM_OBJECT d3dDevice = nullptr; + FF_AUTO_RELEASE_COM_OBJECT ID3D11Device* d3dDevice = nullptr; D3D_FEATURE_LEVEL featureLevel; if (FAILED(ffD3D11CreateDevice( adapter, @@ -295,7 +295,7 @@ static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, __typeof__(&D return FF_CODEC_TYPE_NONE; } - ID3D11VideoDevice* FF_AUTO_RELEASE_COM_OBJECT videoDevice = nullptr; + FF_AUTO_RELEASE_COM_OBJECT ID3D11VideoDevice* videoDevice = nullptr; if (FAILED(d3dDevice->QueryInterface(__uuidof(ID3D11VideoDevice), (void**) &videoDevice)) || !videoDevice) { return FF_CODEC_TYPE_NONE; } @@ -320,7 +320,7 @@ static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, __typeof__(&D } static FFCodecType ffDetectD3d11MftEncoders(const LUID& adapterLuid, __typeof__(&MFCreateAttributes) ffMFCreateAttributes, __typeof__(&MFTEnum2) ffMFTEnum2) { - IMFAttributes* FF_AUTO_RELEASE_COM_OBJECT attributes = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMFAttributes* attributes = nullptr; if (FAILED(ffMFCreateAttributes(&attributes, 1)) || !attributes) { return FF_CODEC_TYPE_NONE; } @@ -382,7 +382,7 @@ static FFCodecType ffCodecEncoderToType(D3D12_VIDEO_ENCODER_CODEC codec) { template static void ffEnumHardwareAdapters(IDXGIFactory1* factory, Func&& onAdapter) { for (UINT adapterIndex = 0;; ++adapterIndex) { - IDXGIAdapter1* FF_AUTO_RELEASE_COM_OBJECT adapter = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IDXGIAdapter1* adapter = nullptr; HRESULT adapterStatus = factory->EnumAdapters1(adapterIndex, &adapter); if (adapterStatus == DXGI_ERROR_NOT_FOUND) { break; @@ -468,7 +468,7 @@ const char* detectD3d12va(FFCodecOptions* options, FFlist* result /*list of FFCo const uint32_t resultLengthBefore = result->length; ffEnumHardwareAdapters(factory, [&](IDXGIAdapter1* adapter, const DXGI_ADAPTER_DESC1& desc) { - ID3D12Device* FF_AUTO_RELEASE_COM_OBJECT d3dDevice = nullptr; + FF_AUTO_RELEASE_COM_OBJECT ID3D12Device* d3dDevice = nullptr; if (FAILED(ffD3D12CreateDevice( adapter, D3D_FEATURE_LEVEL_11_0, @@ -478,7 +478,7 @@ const char* detectD3d12va(FFCodecOptions* options, FFlist* result /*list of FFCo return; } - ID3D12VideoDevice* FF_AUTO_RELEASE_COM_OBJECT videoDevice = nullptr; + FF_AUTO_RELEASE_COM_OBJECT ID3D12VideoDevice* videoDevice = nullptr; if (FAILED(d3dDevice->QueryInterface(__uuidof(ID3D12VideoDevice), (void**) &videoDevice)) || !videoDevice) { return; } @@ -538,7 +538,7 @@ const char* ffDetectCodecNative(FFCodecOptions* options, FFlist* result /*list o return error; } - IDXGIFactory1* FF_AUTO_RELEASE_COM_OBJECT factory = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IDXGIFactory1* factory = nullptr; if (FAILED(ffCreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**) &factory)) || !factory) { return "CreateDXGIFactory1() failed"; } diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index 4f20602a5..a796175e0 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -510,14 +510,14 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) { } } #else -void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) { +void ffCPUDetectByCpuid([[maybe_unused]] FFCPUResult* cpu) { // Unsupported system } #endif #else -void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) { +void ffCPUDetectByCpuid([[maybe_unused]] FFCPUResult* cpu) { // Unsupported architecture } diff --git a/src/detection/cpu/cpu_haiku.c b/src/detection/cpu/cpu_haiku.c index 47399d00c..5ca06a284 100644 --- a/src/detection/cpu/cpu_haiku.c +++ b/src/detection/cpu/cpu_haiku.c @@ -4,7 +4,7 @@ #include #include -const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FFCPUResult* cpu) { +const char* ffDetectCPUImpl([[maybe_unused]] const FFCPUOptions* options, FFCPUResult* cpu) { system_info sysInfo; if (get_system_info(&sysInfo) != B_OK) { return "get_system_info() failed"; diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index f49924eb8..e41aeabe8 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -546,11 +546,11 @@ static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId) static const char* parseCpuInfo( FFstrbuf* cpuinfo, FFCPUResult* cpu, - FF_A_UNUSED FFstrbuf* physicalCoresBuffer, - FF_A_UNUSED FFstrbuf* cpuMHz, - FF_A_UNUSED FFstrbuf* cpuIsa, - FF_A_UNUSED FFstrbuf* cpuUarch, - FF_A_UNUSED FFstrbuf* cpuImplementer) { + [[maybe_unused]] FFstrbuf* physicalCoresBuffer, + [[maybe_unused]] FFstrbuf* cpuMHz, + [[maybe_unused]] FFstrbuf* cpuIsa, + [[maybe_unused]] FFstrbuf* cpuUarch, + [[maybe_unused]] FFstrbuf* cpuImplementer) { char* line = nullptr; size_t len = 0; @@ -681,7 +681,7 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options) { #if __i386__ || __x86_64__ -FF_A_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) { +[[maybe_unused]] static uint16_t getPackageCount(FFstrbuf* cpuinfo) { const char* p = cpuinfo->chars; uint64_t low = 0, high = 0; @@ -700,7 +700,7 @@ FF_A_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) { return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high)); } -FF_A_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFCPUResult* cpu) { +[[maybe_unused]] static const char* detectCPUX86(const FFCPUOptions* options, FFCPUResult* cpu) { FF_STRBUF_AUTO_DESTROY cpuinfo = ffStrbufCreateA(PROC_FILE_BUFFSIZ); if (!ffReadFileBuffer(FF_CPUINFO_PATH, &cpuinfo) || cpuinfo.length == 0) { return "ffReadFileBuffer(\"" FF_CPUINFO_PATH "\") failed"; @@ -813,7 +813,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) { return nullptr; } -FF_A_UNUSED static void parseIsa(FFstrbuf* cpuIsa) { +[[maybe_unused]] static void parseIsa(FFstrbuf* cpuIsa) { // Always use the last part of the ISA string. Ref: #590 #1204 ffStrbufSubstrAfterLastC(cpuIsa, ' '); @@ -833,7 +833,7 @@ FF_A_UNUSED static void parseIsa(FFstrbuf* cpuIsa) { } } -FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) { +[[maybe_unused]] static void detectSocName(FFCPUResult* cpu) { if (cpu->name.length > 0) { return; } @@ -953,7 +953,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) { } #ifdef __loongarch__ -FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) { +[[maybe_unused]] static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) { const char* p = cpuinfo->chars; uint64_t low = 0, high = 0; uint32_t keylen = (uint32_t) strlen(key); @@ -974,7 +974,7 @@ FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* } #endif -FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) { +[[maybe_unused]] static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) { cpu->coresLogical = (uint16_t) get_nprocs_conf(); cpu->coresOnline = (uint16_t) get_nprocs(); diff --git a/src/detection/cpu/cpu_nbsd.c b/src/detection/cpu/cpu_nbsd.c index 3cf7dc4fb..d5ccbf230 100644 --- a/src/detection/cpu/cpu_nbsd.c +++ b/src/detection/cpu/cpu_nbsd.c @@ -23,7 +23,7 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) { return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed"; } - FF_A_CLEANUP(freePropDict) prop_dictionary_t root = nullptr; + [[gnu::cleanup(freePropDict)]] prop_dictionary_t root = nullptr; if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &root) < 0) { return "prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed"; } diff --git a/src/detection/cpu/cpu_nosupport.c b/src/detection/cpu/cpu_nosupport.c index 309883db2..3b014a4cb 100644 --- a/src/detection/cpu/cpu_nosupport.c +++ b/src/detection/cpu/cpu_nosupport.c @@ -1,5 +1,5 @@ #include "cpu.h" -const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FF_A_UNUSED FFCPUResult* cpu) { +const char* ffDetectCPUImpl([[maybe_unused]] const FFCPUOptions* options, [[maybe_unused]] FFCPUResult* cpu) { return "Not supported on this platform"; } diff --git a/src/detection/cpu/cpu_sunos.c b/src/detection/cpu/cpu_sunos.c index 94fa2436d..43b92c371 100644 --- a/src/detection/cpu/cpu_sunos.c +++ b/src/detection/cpu/cpu_sunos.c @@ -99,7 +99,7 @@ static inline uint16_t countTypeId(kstat_ctl_t* kc, const char* type) { } const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { - FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); + [[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open(); if (!kc) { return "kstat_open() failed"; } diff --git a/src/detection/cpu/cpu_windows.c b/src/detection/cpu/cpu_windows.c index dfa82f972..82b656e4f 100644 --- a/src/detection/cpu/cpu_windows.c +++ b/src/detection/cpu/cpu_windows.c @@ -77,7 +77,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) { } } - FF_A_CLEANUP(ffPerfCloseQueryHandle) + [[gnu::cleanup(ffPerfCloseQueryHandle)]] HANDLE hQuery = nullptr; if (PerfOpenQueryHandle(nullptr, &hQuery) != ERROR_SUCCESS) { @@ -139,7 +139,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) { } // 7.5 -typedef struct FFSmbiosProcessorInfo { +typedef struct [[gnu::packed]] FFSmbiosProcessorInfo { FFSmbiosHeader Header; uint8_t SocketDesignation; // string @@ -181,7 +181,7 @@ typedef struct FFSmbiosProcessorInfo { // 3.6+ uint16_t ThreadEnabled; // varies -} FF_A_PACKED FFSmbiosProcessorInfo; +} FFSmbiosProcessorInfo; static_assert(offsetof(FFSmbiosProcessorInfo, ThreadEnabled) == 0x30, "FFSmbiosProcessorInfo: Wrong struct alignment"); @@ -238,7 +238,7 @@ static const char* detectNCores(const FFCPUOptions* options, FFCPUResult* cpu) { return "GetLogicalProcessorInformationEx(RelationAll, nullptr, &length) failed"; } - SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE + FF_AUTO_FREE SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*) malloc(length); if (!NT_SUCCESS(NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), pProcessorInfo, length, &length))) { diff --git a/src/detection/cpucache/cpucache_nosupport.c b/src/detection/cpucache/cpucache_nosupport.c index 51d22563c..002e64216 100644 --- a/src/detection/cpucache/cpucache_nosupport.c +++ b/src/detection/cpucache/cpucache_nosupport.c @@ -1,5 +1,5 @@ #include "cpucache.h" -const char* ffDetectCPUCache(FF_A_UNUSED FFCPUCacheResult* result) { +const char* ffDetectCPUCache([[maybe_unused]] FFCPUCacheResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/cpucache/cpucache_shared.c b/src/detection/cpucache/cpucache_shared.c index 60ea3bdd0..58419a963 100644 --- a/src/detection/cpucache/cpucache_shared.c +++ b/src/detection/cpucache/cpucache_shared.c @@ -2,7 +2,7 @@ #include "common/smbios.h" #include "common/strutil.h" -typedef struct FFSmbiosCacheInfo { +typedef struct [[gnu::packed]] FFSmbiosCacheInfo { FFSmbiosHeader Header; uint8_t SocketDesignation; // string @@ -21,7 +21,7 @@ typedef struct FFSmbiosCacheInfo { // 3.1+ uint32_t MaximumCacheSize2; // bit field uint32_t InstalledCacheSize2; // bit field -} FF_A_PACKED FFSmbiosCacheInfo; +} FFSmbiosCacheInfo; static_assert(offsetof(FFSmbiosCacheInfo, InstalledCacheSize2) == 0x17, "FFSmbiosCacheInfo: Wrong struct alignment"); diff --git a/src/detection/cpucache/cpucache_windows.c b/src/detection/cpucache/cpucache_windows.c index c8459e069..0bfc57982 100644 --- a/src/detection/cpucache/cpucache_windows.c +++ b/src/detection/cpucache/cpucache_windows.c @@ -10,7 +10,7 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) { return "GetLogicalProcessorInformationEx(RelationCache, nullptr, &length) failed"; } - SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE + FF_AUTO_FREE SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*) malloc(length); if (!NT_SUCCESS(NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), pProcessorInfo, length, &length))) { diff --git a/src/detection/cpuusage/cpuusage_nosupport.c b/src/detection/cpuusage/cpuusage_nosupport.c index faade7b84..4b0ba7aa8 100644 --- a/src/detection/cpuusage/cpuusage_nosupport.c +++ b/src/detection/cpuusage/cpuusage_nosupport.c @@ -1,6 +1,6 @@ #include "fastfetch.h" #include "detection/cpuusage/cpuusage.h" -const char* ffGetCpuUsageInfo(FF_A_UNUSED FFlist* cpuTimes) { +const char* ffGetCpuUsageInfo([[maybe_unused]] FFlist* cpuTimes) { return "Not support on this platform"; } diff --git a/src/detection/cpuusage/cpuusage_sunos.c b/src/detection/cpuusage/cpuusage_sunos.c index aaefeb6a3..a10f09ed7 100644 --- a/src/detection/cpuusage/cpuusage_sunos.c +++ b/src/detection/cpuusage/cpuusage_sunos.c @@ -12,7 +12,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) { } const char* ffGetCpuUsageInfo(FFlist* cpuTimes) { - FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); + [[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open(); if (!kc) { return "kstat_open() failed"; } diff --git a/src/detection/cpuusage/cpuusage_windows.c b/src/detection/cpuusage/cpuusage_windows.c index abc99882e..a208c40f4 100644 --- a/src/detection/cpuusage/cpuusage_windows.c +++ b/src/detection/cpuusage/cpuusage_windows.c @@ -14,7 +14,7 @@ static const char* getInfoByNqsi(FFlist* cpuTimes) { return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr) failed"; } - SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* FF_AUTO_FREE pinfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*) malloc(size); + FF_AUTO_FREE SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* pinfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*) malloc(size); if (!NT_SUCCESS(NtQuerySystemInformation(SystemProcessorPerformanceInformation, pinfo, size, &size))) { return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, size) failed"; } diff --git a/src/detection/cursor/cursor_nosupport.c b/src/detection/cursor/cursor_nosupport.c index 6413d92d3..123beacb0 100644 --- a/src/detection/cursor/cursor_nosupport.c +++ b/src/detection/cursor/cursor_nosupport.c @@ -1,5 +1,5 @@ #include "cursor.h" -void ffDetectCursor(FF_A_UNUSED FFCursorResult* result) { +void ffDetectCursor([[maybe_unused]] FFCursorResult* result) { ffStrbufInitS(&result->error, "Not supported on this platform"); } diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c index 531a25004..e79c3f418 100644 --- a/src/detection/de/de_linux.c +++ b/src/detection/de/de_linux.c @@ -22,7 +22,7 @@ #define _PATH_LOCALBASE "/usr/pkg" #endif -static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getKDE(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { #ifdef _PATH_LOCALBASE ffParsePropFile(_PATH_LOCALBASE "/share/wayland-sessions/plasma.desktop", "X-KDE-PluginInfo-Version =", result); if (result->length == 0) { @@ -56,7 +56,7 @@ static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { } } -static const char* getGnomeByDbus(FF_A_UNUSED FFstrbuf* result) { +static const char* getGnomeByDbus([[maybe_unused]] FFstrbuf* result) { #ifdef FF_HAVE_DBUS FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) { @@ -70,7 +70,7 @@ static const char* getGnomeByDbus(FF_A_UNUSED FFstrbuf* result) { #endif // FF_HAVE_DBUS } -static void getGnome(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getGnome(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { getGnomeByDbus(result); if (result->length == 0) { @@ -80,7 +80,7 @@ static void getGnome(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { } } -static void getCinnamon(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getCinnamon(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { ffStrbufSetS(result, getenv("CINNAMON_VERSION")); if (result->length == 0) { @@ -94,7 +94,7 @@ static void getCinnamon(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { } } -static void getMate(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getMate(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { FF_STRBUF_AUTO_DESTROY major = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY micro = ffStrbufCreate(); @@ -124,7 +124,7 @@ static const char* getXfce4ByLib(FFstrbuf* result) { #endif } -static void getXFCE4(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getXFCE4(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { getXfce4ByLib(result); if (result->length == 0) { @@ -137,7 +137,7 @@ static void getXFCE4(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { } } -static void getLXQt(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getLXQt(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { ffParsePropFileData("gconfig/lxqt.pc", "Version:", result); if (result->length == 0) { @@ -156,11 +156,11 @@ static void getLXQt(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { } } -static void getBudgie(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getBudgie(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { ffParsePropFileData("budgie/budgie-version.xml", "", result); } -static void getUnity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getUnity(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { if (ffParsePropFile("/usr/bin/unity", "parser = OptionParser(version= \"%prog ", result)) { ffStrbufSubstrBeforeFirstC(result, '"'); } @@ -177,7 +177,7 @@ static bool extractTdeVersion(const char* line, uint32_t len, void* userdata) { return false; } -static const char* getTrinity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static const char* getTrinity(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate(); const char* error = ffFindExecutableInPath("tde-config", &path); if (error) { @@ -200,7 +200,7 @@ static const char* getTrinity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options return "All methods failed"; } -static const char* getCosmic(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static const char* getCosmic(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { if (ffProcessAppendStdOut(result, (char* const[]) { "cosmic-comp", "--version", nullptr }) == nullptr) { // cosmic-comp 0.1.0 (git commit fa88002ba41d2edec25dd7ffdee9719fbb928fc0) ffStrbufSubstrAfterFirstC(result, ' '); @@ -211,7 +211,7 @@ static const char* getCosmic(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) return "All methods failed"; } -static const char* getEnlightenmentByDbus(FF_A_UNUSED FFstrbuf* result) { +static const char* getEnlightenmentByDbus([[maybe_unused]] FFstrbuf* result) { #ifdef FF_HAVE_DBUS FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) { @@ -240,7 +240,7 @@ static const char* getEnlightenmentByDbus(FF_A_UNUSED FFstrbuf* result) { #endif // FF_HAVE_DBUS } -static void getEnlightenment(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +static void getEnlightenment(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { getEnlightenmentByDbus(result); if (result->length == 0) { diff --git a/src/detection/de/de_nosupport.c b/src/detection/de/de_nosupport.c index d870ae033..d9262c4f1 100644 --- a/src/detection/de/de_nosupport.c +++ b/src/detection/de/de_nosupport.c @@ -1,5 +1,5 @@ #include "de.h" -const char* ffDetectDEVersion(FF_A_UNUSED const FFstrbuf* deName, FF_A_UNUSED FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { +const char* ffDetectDEVersion([[maybe_unused]] const FFstrbuf* deName, [[maybe_unused]] FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) { return "Not supported on this platform"; } diff --git a/src/detection/disk/disk_bsd.c b/src/detection/disk/disk_bsd.c index 65c09cf30..aaa69b294 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -54,7 +54,7 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) { return nullptr; } #else -static const char* detectFsLabel(FF_A_UNUSED struct statfs* fs, FF_A_UNUSED FFDisk* disk) { +static const char* detectFsLabel([[maybe_unused]] struct statfs* fs, [[maybe_unused]] FFDisk* disk) { return "Fastfetch was compiled without libgeom support"; } #endif @@ -84,11 +84,11 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) { #define MNT_REMOVABLE 0x00000200 #endif -struct CmnAttrBuf { +struct [[gnu::packed]] CmnAttrBuf { uint32_t length; attrreference_t nameRef; char nameSpace[NAME_MAX * 3 + 1]; -} FF_A_PACKED; +}; void detectFsInfo(struct statfs* fs, FFDisk* disk) { if (fs->f_flags & MNT_DONTBROWSE) { diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 9ef3954fa..bb1a69512 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -162,7 +162,7 @@ static void detectName(FFDisk* disk) { #ifdef __ANDROID__ -static void detectType(FF_A_UNUSED const FFlist* disks, FFDisk* currentDisk, FF_A_UNUSED struct mntent* device) { +static void detectType([[maybe_unused]] const FFlist* disks, FFDisk* currentDisk, [[maybe_unused]] struct mntent* device) { if (ffStrbufEqualS(¤tDisk->mountpoint, "/") || ffStrbufEqualS(¤tDisk->mountpoint, "/storage/emulated")) { currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; } else if (ffStrbufStartsWithS(¤tDisk->mountpoint, "/mnt/media_rw/")) { diff --git a/src/detection/disk/disk_nosupport.c b/src/detection/disk/disk_nosupport.c index eabddbc88..0623336dc 100644 --- a/src/detection/disk/disk_nosupport.c +++ b/src/detection/disk/disk_nosupport.c @@ -1,5 +1,5 @@ #include "disk.h" -const char* ffDetectDisksImpl(FF_A_UNUSED FFDiskOptions* options, FF_A_UNUSED FFlist* disks) { +const char* ffDetectDisksImpl([[maybe_unused]] FFDiskOptions* options, [[maybe_unused]] FFlist* disks) { return "Not supported on this platform"; } diff --git a/src/detection/diskio/diskio_bsd.c b/src/detection/diskio/diskio_bsd.c index dacb58f1f..495d1a95a 100644 --- a/src/detection/diskio/diskio_bsd.c +++ b/src/detection/diskio/diskio_bsd.c @@ -12,7 +12,7 @@ #include const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { - FF_A_CLEANUP(geom_deletetree) struct gmesh geomTree = {}; + [[gnu::cleanup(geom_deletetree)]] struct gmesh geomTree = {}; if (geom_gettree(&geomTree) < 0) { return "geom_gettree() failed"; } diff --git a/src/detection/diskio/diskio_nosupport.c b/src/detection/diskio/diskio_nosupport.c index f5de15d08..8711e342e 100644 --- a/src/detection/diskio/diskio_nosupport.c +++ b/src/detection/diskio/diskio_nosupport.c @@ -1,5 +1,5 @@ #include "diskio.h" -const char* ffDiskIOGetIoCounters(FF_A_UNUSED FFlist* result, FF_A_UNUSED FFDiskIOOptions* options) { +const char* ffDiskIOGetIoCounters([[maybe_unused]] FFlist* result, [[maybe_unused]] FFDiskIOOptions* options) { return "Not supported on this platform"; } diff --git a/src/detection/diskio/diskio_sunos.c b/src/detection/diskio/diskio_sunos.c index 837a7aa64..c79e3daea 100644 --- a/src/detection/diskio/diskio_sunos.c +++ b/src/detection/diskio/diskio_sunos.c @@ -10,7 +10,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) { } const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { - FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); + [[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open(); if (!kc) { return "kstat_open() failed"; } diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index f761fbb5f..94c86dfb6 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -12,9 +12,9 @@ #include #ifdef MAC_OS_X_VERSION_10_15 -extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display) FF_A_WEAK_IMPORT; -extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display) FF_A_WEAK_IMPORT; -extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) FF_A_WEAK_IMPORT; +[[clang::weak_import]] extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display); +[[clang::weak_import]] extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display); +[[clang::weak_import]] extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display); #else #include #endif @@ -50,7 +50,7 @@ static void detectDisplays(FFDisplayServerResult* ds) { } ffStrbufClear(&buffer); - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = nullptr; + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef displayInfo = nullptr; #ifdef MAC_OS_X_VERSION_10_15 if (CoreDisplay_DisplayCreateInfoDictionary) { displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen); diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index fe500f86e..63d9e9a80 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -12,8 +12,7 @@ static inline void freeArgBuffer(FFArgBuffer* buffer) { } buffer->data = nullptr; buffer->length = 0; -} -#define FF_AUTO_FREE_ARG_BUFFER FF_A_CLEANUP(freeArgBuffer) +}\ // http://undoc.airesoft.co.uk/user32.dll/IsThreadDesktopComposited.php BOOL WINAPI IsThreadDesktopComposited(); @@ -47,7 +46,7 @@ static void detectDisplays(FFDisplayServerResult* ds) { .id = path->targetInfo.id, }, }; - FF_AUTO_FREE_ARG_BUFFER FFArgBuffer edid = {}; + [[gnu::cleanup(freeArgBuffer)]] FFArgBuffer edid = {}; if (DisplayConfigGetDeviceInfo(&targetName.header) == ERROR_SUCCESS) { wchar_t regPath[256] = L"SYSTEM\\CurrentControlSet\\Enum"; wchar_t* pRegPath = regPath + strlen("SYSTEM\\CurrentControlSet\\Enum"); diff --git a/src/detection/displayserver/linux/drm.c b/src/detection/displayserver/linux/drm.c index 7c45b36c4..21d70ea06 100644 --- a/src/detection/displayserver/linux/drm.c +++ b/src/detection/displayserver/linux/drm.c @@ -175,7 +175,7 @@ static inline const char* drmType2Name(uint32_t connector_type) { } } -FF_A_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edidData, ssize_t* edidLength) { +[[maybe_unused]] static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edidData, ssize_t* edidLength) { const char* drmDirPath = "/sys/class/drm/"; FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath); @@ -434,7 +434,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { #endif -const char* ffdsConnectDrm(FF_A_UNUSED FFDisplayServerResult* result) { +const char* ffdsConnectDrm([[maybe_unused]] FFDisplayServerResult* result) { #if FF_HAVE_DRM if (instance.config.general.dsForceDrm != FF_DS_FORCE_DRM_TYPE_SYSFS_ONLY) { if (drmConnectLibdrm(result) == nullptr) { diff --git a/src/detection/displayserver/linux/wayland/global-output.c b/src/detection/displayserver/linux/wayland/global-output.c index de69b2cde..e3c801853 100644 --- a/src/detection/displayserver/linux/wayland/global-output.c +++ b/src/detection/displayserver/linux/wayland/global-output.c @@ -5,7 +5,7 @@ #include "xdg-output-unstable-v1-client-protocol.h" #include "wp-color-management-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) { +static void waylandOutputModeListener(void* data, [[maybe_unused]] struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) { WaylandDisplay* display = data; if (flags & WL_OUTPUT_MODE_CURRENT) { @@ -20,20 +20,20 @@ static void waylandOutputModeListener(void* data, FF_A_UNUSED struct wl_output* } } -static void waylandOutputScaleListener(void* data, FF_A_UNUSED struct wl_output* output, int32_t scale) { +static void waylandOutputScaleListener(void* data, [[maybe_unused]] struct wl_output* output, int32_t scale) { WaylandDisplay* display = data; display->dpi = 96 * (uint32_t) scale; } static void waylandOutputGeometryListener(void* data, - FF_A_UNUSED struct wl_output* output, - FF_A_UNUSED int32_t x, - FF_A_UNUSED int32_t y, + [[maybe_unused]] struct wl_output* output, + [[maybe_unused]] int32_t x, + [[maybe_unused]] int32_t y, int32_t physical_width, int32_t physical_height, - FF_A_UNUSED int32_t subpixel, - FF_A_UNUSED const char* make, - FF_A_UNUSED const char* model, + [[maybe_unused]] int32_t subpixel, + [[maybe_unused]] const char* make, + [[maybe_unused]] const char* model, int32_t transform) { WaylandDisplay* display = data; display->physicalWidth = physical_width; @@ -41,7 +41,7 @@ static void waylandOutputGeometryListener(void* data, display->transform = (enum wl_output_transform) transform; } -static void handleXdgLogicalSize(void* data, FF_A_UNUSED struct zxdg_output_v1* _, int32_t width, FF_A_UNUSED int32_t height) { +static void handleXdgLogicalSize(void* data, [[maybe_unused]] struct zxdg_output_v1* _, int32_t width, [[maybe_unused]] int32_t height) { WaylandDisplay* display = data; // Seems the values are only useful when ractional scale is enabled if (width < display->width) { @@ -71,7 +71,7 @@ static struct zxdg_output_v1_listener zxdgOutputListener = { .description = (void*) ffWaylandOutputDescriptionListener, }; -static void handleWpTfNamed(void *data, FF_A_UNUSED struct wp_image_description_info_v1* wp_image_description_info_v1, uint32_t tf) { +static void handleWpTfNamed(void *data, [[maybe_unused]] struct wp_image_description_info_v1* wp_image_description_info_v1, uint32_t tf) { // KDE reports `gamma 2.2` even in HDR mode, but it should be handled in KDE specific path WaylandDisplay* display = data; switch (tf) { diff --git a/src/detection/displayserver/linux/wayland/kde-output.c b/src/detection/displayserver/linux/wayland/kde-output.c index 272b03df3..d26cfbc68 100644 --- a/src/detection/displayserver/linux/wayland/kde-output.c +++ b/src/detection/displayserver/linux/wayland/kde-output.c @@ -13,18 +13,18 @@ typedef struct WaylandKdeMode { struct kde_output_device_mode_v2* pMode; } WaylandKdeMode; -static void waylandKdeModeSizeListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _, int32_t width, int32_t height) { +static void waylandKdeModeSizeListener(void* data, [[maybe_unused]] struct kde_output_device_mode_v2* _, int32_t width, int32_t height) { WaylandKdeMode* mode = (WaylandKdeMode*) data; mode->width = width; mode->height = height; } -static void waylandKdeModeRefreshListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _, int32_t rate) { +static void waylandKdeModeRefreshListener(void* data, [[maybe_unused]] struct kde_output_device_mode_v2* _, int32_t rate) { WaylandKdeMode* mode = (WaylandKdeMode*) data; mode->refreshRate = rate; } -static void waylandKdeModePreferredListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _) { +static void waylandKdeModePreferredListener(void* data, [[maybe_unused]] struct kde_output_device_mode_v2* _) { WaylandKdeMode* mode = (WaylandKdeMode*) data; mode->preferred = true; } @@ -37,7 +37,7 @@ static const struct kde_output_device_mode_v2_listener modeListener = { .flags = (void*) stubListener, }; -static void waylandKdeModeListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) { +static void waylandKdeModeListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) { WaylandDisplay* wldata = (WaylandDisplay*) data; if (!wldata->internal) { return; @@ -50,7 +50,7 @@ static void waylandKdeModeListener(void* data, FF_A_UNUSED struct kde_output_dev wldata->parent->ffwl_proxy_add_listener((struct wl_proxy*) mode, (void (**)(void)) &modeListener, newMode); } -static void waylandKdeCurrentModeListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) { +static void waylandKdeCurrentModeListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) { // waylandKdeModeListener is always run before this WaylandDisplay* wldata = (WaylandDisplay*) data; if (!wldata->internal) { @@ -78,12 +78,12 @@ static void waylandKdeCurrentModeListener(void* data, FF_A_UNUSED struct kde_out } } -static void waylandKdeScaleListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, wl_fixed_t scale) { +static void waylandKdeScaleListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, wl_fixed_t scale) { WaylandDisplay* wldata = (WaylandDisplay*) data; wldata->dpi = (uint32_t) scale * 3 / 8; // wl_fixed_to_double(scale) * 96; } -static void waylandKdeEdidListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, const char* raw) { +static void waylandKdeEdidListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, const char* raw) { if (!*raw) { return; } @@ -100,7 +100,7 @@ static void waylandKdeEdidListener(void* data, FF_A_UNUSED struct kde_output_dev wldata->hdrInfoAvailable = true; } -static void waylandKdeEnabledListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, int32_t enabled) { +static void waylandKdeEnabledListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, int32_t enabled) { WaylandDisplay* wldata = (WaylandDisplay*) data; if (!enabled) { wldata->internal = nullptr; @@ -108,14 +108,14 @@ static void waylandKdeEnabledListener(void* data, FF_A_UNUSED struct kde_output_ } static void waylandKdeGeometryListener(void* data, - FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, - FF_A_UNUSED int32_t x, - FF_A_UNUSED int32_t y, + [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, + [[maybe_unused]] int32_t x, + [[maybe_unused]] int32_t y, int32_t physical_width, int32_t physical_height, - FF_A_UNUSED int32_t subpixel, - FF_A_UNUSED const char* make, - FF_A_UNUSED const char* model, + [[maybe_unused]] int32_t subpixel, + [[maybe_unused]] const char* make, + [[maybe_unused]] const char* model, int32_t transform) { WaylandDisplay* display = data; display->physicalWidth = physical_width; @@ -123,7 +123,7 @@ static void waylandKdeGeometryListener(void* data, display->transform = (enum wl_output_transform) transform; } -static void waylandKdeNameListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, const char* name) { +static void waylandKdeNameListener(void* data, [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, const char* name) { WaylandDisplay* display = data; display->type = ffdsGetDisplayType(name); // As display->id is used as an internal identifier, we don't need it to be NUL terminated @@ -132,17 +132,17 @@ static void waylandKdeNameListener(void* data, FF_A_UNUSED struct kde_output_dev ffStrbufAppendS(&display->name, name); } -static void waylandKdeHdrListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t hdr_enabled) { +static void waylandKdeHdrListener(void* data, [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, uint32_t hdr_enabled) { WaylandDisplay* display = data; display->hdrEnabled = !!hdr_enabled; } -static void waylandKdeMaxBitsPerColorListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t max_bpc) { +static void waylandKdeMaxBitsPerColorListener(void* data, [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, uint32_t max_bpc) { WaylandDisplay* display = data; display->bitDepth = (uint8_t) max_bpc; } -static void waylandKdePriorityListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t priority) { +static void waylandKdePriorityListener(void* data, [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, uint32_t priority) { WaylandDisplay* display = data; display->primary = priority == 1; } @@ -282,7 +282,7 @@ const char* ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* re return waylandKdeHandleOutput(wldata, output); } -static void waylandKdeOutputListener(void* data, FF_A_UNUSED struct kde_output_device_registry_v2* kde_output_device_registry_v2, struct kde_output_device_v2* output) { +static void waylandKdeOutputListener(void* data, [[maybe_unused]] struct kde_output_device_registry_v2* kde_output_device_registry_v2, struct kde_output_device_v2* output) { waylandKdeHandleOutput((WaylandData*) data, (struct wl_proxy*) output); } diff --git a/src/detection/displayserver/linux/wayland/wayland.c b/src/detection/displayserver/linux/wayland/wayland.c index a1d7edf34..7e37aee8d 100644 --- a/src/detection/displayserver/linux/wayland/wayland.c +++ b/src/detection/displayserver/linux/wayland/wayland.c @@ -102,7 +102,7 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u } } -static FF_A_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) { +[[maybe_unused]] static bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) { // https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-event-name // The doc says that "do not assume that the name is a reflection of an underlying DRM connector, X11 connection, etc." // However I can't find a better method to get the edid data @@ -149,7 +149,7 @@ static FF_A_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* return false; } -void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const char* name) { +void ffWaylandOutputNameListener(void* data, [[maybe_unused]] void* output, const char* name) { WaylandDisplay* display = data; if (display->id) { return; @@ -165,7 +165,7 @@ void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const cha ffStrbufAppendS(&display->name, name); } -void ffWaylandOutputDescriptionListener(void* data, FF_A_UNUSED void* output, const char* description) { +void ffWaylandOutputDescriptionListener(void* data, [[maybe_unused]] void* output, const char* description) { WaylandDisplay* display = data; if (display->description.length) { return; @@ -341,7 +341,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) { #else -const char* ffdsConnectWayland(FF_A_UNUSED FFDisplayServerResult* result) { +const char* ffdsConnectWayland([[maybe_unused]] FFDisplayServerResult* result) { return "Fastfetch was compiled without Wayland support"; } diff --git a/src/detection/displayserver/linux/wayland/wayland.h b/src/detection/displayserver/linux/wayland/wayland.h index 18a023cc8..a661936cf 100644 --- a/src/detection/displayserver/linux/wayland/wayland.h +++ b/src/detection/displayserver/linux/wayland/wayland.h @@ -75,8 +75,8 @@ inline static uint64_t ffWaylandGenerateIdFromName(const char* name) { return id; } -void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const char* name); -void ffWaylandOutputDescriptionListener(void* data, FF_A_UNUSED void* output, const char* description); +void ffWaylandOutputNameListener(void* data, [[maybe_unused]] void* output, const char* name); +void ffWaylandOutputDescriptionListener(void* data, [[maybe_unused]] void* output, const char* description); // Modifies content of display. Don't call this function when calling ffdsAppendDisplay uint32_t ffWaylandHandleRotation(WaylandDisplay* display); diff --git a/src/detection/dns/dns_windows.c b/src/detection/dns/dns_windows.c index 5d2ab5534..4f63d91f9 100644 --- a/src/detection/dns/dns_windows.c +++ b/src/detection/dns/dns_windows.c @@ -6,7 +6,7 @@ #include const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) { - IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = nullptr; + FF_AUTO_FREE IP_ADAPTER_ADDRESSES* adapter_addresses = nullptr; // Multiple attempts in case interfaces change while // we are in the middle of querying them. diff --git a/src/detection/editor/editor.c b/src/detection/editor/editor.c index 6d4974686..a4176636a 100644 --- a/src/detection/editor/editor.c +++ b/src/detection/editor/editor.c @@ -7,7 +7,7 @@ #include -static bool extractNvimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractNvimVersionFromBinary(const char* str, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffStrStartsWith(str, "NVIM v")) { return true; } @@ -15,7 +15,7 @@ static bool extractNvimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t l return false; } -static bool extractVimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractVimVersionFromBinary(const char* str, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffStrStartsWith(str, "VIM - Vi IMproved ")) { return true; } @@ -24,7 +24,7 @@ static bool extractVimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t le return false; } -static bool extractNanoVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractNanoVersionFromBinary(const char* str, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffStrStartsWith(str, "GNU nano ")) { return true; } diff --git a/src/detection/font/font_nosupport.c b/src/detection/font/font_nosupport.c index 26f9ec68a..8dc7b1c77 100644 --- a/src/detection/font/font_nosupport.c +++ b/src/detection/font/font_nosupport.c @@ -1,7 +1,7 @@ #include "fastfetch.h" #include "font.h" -const char* ffDetectFontImpl(FF_A_UNUSED FFFontResult* result) { +const char* ffDetectFontImpl([[maybe_unused]] FFFontResult* result) { FF_UNUSED(result); return "Not supported on this platform"; } diff --git a/src/detection/gamepad/gamepad_apple.c b/src/detection/gamepad/gamepad_apple.c index fa927c306..7f70cfc9a 100644 --- a/src/detection/gamepad/gamepad_apple.c +++ b/src/detection/gamepad/gamepad_apple.c @@ -28,17 +28,17 @@ static void enumSet(IOHIDDeviceRef value, FFlist* results) { } const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { - IOHIDManagerRef FF_CFTYPE_AUTO_RELEASE manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); + FF_CFTYPE_AUTO_RELEASE IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (IOHIDManagerOpen(manager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) { return "IOHIDManagerOpen() failed"; } - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Joystick) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching2 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_GamePad) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFArrayRef FF_CFTYPE_AUTO_RELEASE matchings = CFArrayCreate(kCFAllocatorDefault, (const void**) (CFTypeRef[]) { matching1, matching2 }, 2, &kCFTypeArrayCallBacks); + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Joystick) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef matching2 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_GamePad) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + FF_CFTYPE_AUTO_RELEASE CFArrayRef matchings = CFArrayCreate(kCFAllocatorDefault, (const void**) (CFTypeRef[]) { matching1, matching2 }, 2, &kCFTypeArrayCallBacks); IOHIDManagerSetDeviceMatchingMultiple(manager, matchings); - CFSetRef FF_CFTYPE_AUTO_RELEASE set = IOHIDManagerCopyDevices(manager); + FF_CFTYPE_AUTO_RELEASE CFSetRef set = IOHIDManagerCopyDevices(manager); if (set) { CFSetApplyFunction(set, (CFSetApplierFunction) &enumSet, devices); } diff --git a/src/detection/gamepad/gamepad_nosupport.c b/src/detection/gamepad/gamepad_nosupport.c index c0d791e71..ad6a3741e 100644 --- a/src/detection/gamepad/gamepad_nosupport.c +++ b/src/detection/gamepad/gamepad_nosupport.c @@ -1,5 +1,5 @@ #include "gamepad.h" -const char* ffDetectGamepad(FF_A_UNUSED FFlist* devices /* List of FFGamepadDevice */) { +const char* ffDetectGamepad([[maybe_unused]] FFlist* devices /* List of FFGamepadDevice */) { return "Not supported on this platform"; } diff --git a/src/detection/gamepad/gamepad_windows.c b/src/detection/gamepad/gamepad_windows.c index 34199c569..b7f23e18c 100644 --- a/src/detection/gamepad/gamepad_windows.c +++ b/src/detection/gamepad/gamepad_windows.c @@ -85,7 +85,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { if (nDevices == 0) { return "No HID devices found"; } - RAWINPUTDEVICELIST* FF_AUTO_FREE pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices); + FF_AUTO_FREE RAWINPUTDEVICELIST* pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices); if ((nDevices = GetRawInputDeviceList(pRawInputDeviceList, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT) -1) { return "GetRawInputDeviceList(pRawInputDeviceList) failed"; } @@ -122,7 +122,7 @@ const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) { if (knownGamepad) { ffStrbufSetS(&device->name, knownGamepad); } - HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr); + FF_AUTO_CLOSE_FD HANDLE hHidFile = CreateFileW(devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr); if (hHidFile == INVALID_HANDLE_VALUE) { if (!knownGamepad) { ffStrbufSetF(&device->name, "Unknown gamepad %04X-%04X", (unsigned) rdi.hid.dwVendorId, (unsigned) rdi.hid.dwProductId); diff --git a/src/detection/gpu/d3dkmthk.h b/src/detection/gpu/d3dkmthk.h index e32241164..0fe47398b 100644 --- a/src/detection/gpu/d3dkmthk.h +++ b/src/detection/gpu/d3dkmthk.h @@ -316,18 +316,18 @@ typedef struct _DXGK_NODEMETADATA_FLAGS { }; } DXGK_NODEMETADATA_FLAGS; -typedef struct _DXGK_NODEMETADATA { +typedef struct [[gnu::packed]] _DXGK_NODEMETADATA { DXGK_ENGINE_TYPE EngineType; WCHAR FriendlyName[DXGK_MAX_METADATA_NAME_LENGTH]; DXGK_NODEMETADATA_FLAGS Flags; // WDDM 2.2 BOOLEAN GpuMmuSupported; // WDDM 2.0 ??? BOOLEAN IoMmuSupported; -} FF_A_PACKED DXGK_NODEMETADATA; +} DXGK_NODEMETADATA; -typedef struct _D3DKMT_NODEMETADATA { +typedef struct [[gnu::packed]] _D3DKMT_NODEMETADATA { UINT NodeOrdinalAndAdapterIndex; // WDDMv2: High word is physical adapter index, low word is node ordinal DXGK_NODEMETADATA NodeData; -} FF_A_PACKED D3DKMT_NODEMETADATA; +} D3DKMT_NODEMETADATA; static_assert(sizeof(D3DKMT_NODEMETADATA) == 0x4E, "D3DKMT_NODEMETADATA structure size mismatch"); // Functions diff --git a/src/detection/gpu/gpu.c b/src/detection/gpu/gpu.c index 2a74a54b2..6fb0fe7f7 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -106,7 +106,7 @@ const char* detectByOpenGL(FFlist* gpus) { ffStrbufInit(&result.slv); ffStrbufInit(&result.library); - FF_A_CLEANUP(ffDestroyOpenGLOptions) FFOpenGLOptions options; + [[gnu::cleanup(ffDestroyOpenGLOptions)]] FFOpenGLOptions options; ffInitOpenGLOptions(&options); const char* error = ffDetectOpenGL(&options, &result); FF_DEBUG("OpenGL detection returns: %s", error ?: "success"); diff --git a/src/detection/gpu/gpu_amd.c b/src/detection/gpu/gpu_amd.c index 8569ee03f..858bac0f3 100644 --- a/src/detection/gpu/gpu_amd.c +++ b/src/detection/gpu/gpu_amd.c @@ -6,7 +6,7 @@ #include "common/debug.h" // Helper function to convert ADL status code to string -FF_A_UNUSED static const char* ffAdlStatusToString(int status) { +[[maybe_unused]] static const char* ffAdlStatusToString(int status) { switch (status) { #define FF_ADL_STATUS_CASE(name) \ case name: \ diff --git a/src/detection/gpu/gpu_driver_specific.h b/src/detection/gpu/gpu_driver_specific.h index 3500a51e2..1549f84e8 100644 --- a/src/detection/gpu/gpu_driver_specific.h +++ b/src/detection/gpu/gpu_driver_specific.h @@ -48,7 +48,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive #define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX #endif -FF_A_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) { +[[maybe_unused]] static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) { if (vendor == FF_GPU_VENDOR_NAME_NVIDIA) { *pDetectFn = ffDetectNvidiaGpuInfo; #ifdef _WIN32 diff --git a/src/detection/gpu/gpu_gnu.c b/src/detection/gpu/gpu_gnu.c index 113b34b45..3edb32d6c 100644 --- a/src/detection/gpu/gpu_gnu.c +++ b/src/detection/gpu/gpu_gnu.c @@ -15,7 +15,7 @@ enum { PCI_CONF_SIZE = 0x40, }; -const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl([[maybe_unused]] const FFGPUOptions* options, FFlist* gpus) { int dDomainFd = open(_SERVERS_BUS "/pci/0000", O_RDONLY | O_CLOEXEC); if (dDomainFd < 0) { return "open(_SERVERS_BUS \"/pci/0000\") failed"; diff --git a/src/detection/gpu/gpu_haiku.c b/src/detection/gpu/gpu_haiku.c index cf4704acd..6d2bf7d3f 100644 --- a/src/detection/gpu/gpu_haiku.c +++ b/src/detection/gpu/gpu_haiku.c @@ -3,7 +3,7 @@ #include -const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl([[maybe_unused]] const FFGPUOptions* options, FFlist* gpus) { FF_AUTO_CLOSE_FD int pokefd = open(POKE_DEVICE_FULLNAME, O_RDWR | O_CLOEXEC); if (pokefd < 0) { return "open(POKE_DEVICE_FULLNAME) failed"; diff --git a/src/detection/gpu/gpu_linux.c b/src/detection/gpu/gpu_linux.c index 5b8dff471..9575d9ff4 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -7,7 +7,7 @@ #include #include -static bool detectDriverFromSysfs(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer, FF_A_UNUSED const char* drmKey) { +static bool detectDriverFromSysfs(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer, [[maybe_unused]] const char* drmKey) { uint32_t pciDirLength = pciDir->length; ffStrbufAppendS(pciDir, "/driver"); char pathBuf[PATH_MAX]; @@ -52,7 +52,7 @@ static bool detectDriverFromSysfs(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* return true; } -FF_A_UNUSED static const char* drmFindRenderFromCard(const char* drmCardKey, FFstrbuf* result) { +[[maybe_unused]] static const char* drmFindRenderFromCard(const char* drmCardKey, FFstrbuf* result) { char path[PATH_MAX]; sprintf(path, "/sys/class/drm/%s/device/drm", drmCardKey); FF_AUTO_CLOSE_DIR DIR* dirp = opendir(path); @@ -497,7 +497,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf #if __aarch64__ #include "detection/cpu/cpu.h" -FF_A_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const char* name, FF_A_UNUSED FFstrbuf* buffer, FF_A_UNUSED const char* drmKey) { +[[maybe_unused]] static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const char* name, [[maybe_unused]] FFstrbuf* buffer, [[maybe_unused]] const char* drmKey) { if (sscanf(name, "agx-t%lu", &gpu->deviceId) == 1) { ffStrbufSetStatic(&gpu->name, ffCPUAppleCodeToName((uint32_t) gpu->deviceId)); } diff --git a/src/detection/gpu/gpu_mthreads.c b/src/detection/gpu/gpu_mthreads.c index a38887a85..5a6b6a467 100644 --- a/src/detection/gpu/gpu_mthreads.c +++ b/src/detection/gpu/gpu_mthreads.c @@ -29,7 +29,7 @@ struct FFMtmlData { MtmlSystem* sys; } mtmlData; -FF_A_UNUSED static void shutdownMtml(void) { +[[maybe_unused]] static void shutdownMtml(void) { mtmlData.ffmtmlLibraryShutDown(mtmlData.lib); } diff --git a/src/detection/gpu/gpu_nbsd.c b/src/detection/gpu/gpu_nbsd.c index dd51d32d1..e3d04c14e 100644 --- a/src/detection/gpu/gpu_nbsd.c +++ b/src/detection/gpu/gpu_nbsd.c @@ -26,7 +26,7 @@ static inline int pciReadConf(int fd, uint32_t bus, uint32_t device, uint32_t fu return 0; } -const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl([[maybe_unused]] const FFGPUOptions* options, FFlist* gpus) { char pciDevPath[] = "/dev/pciXXX"; for (uint32_t idev = 0; idev <= 255; idev++) { diff --git a/src/detection/gpu/gpu_obsd.c b/src/detection/gpu/gpu_obsd.c index 25c8f5396..4dd2d8327 100644 --- a/src/detection/gpu/gpu_obsd.c +++ b/src/detection/gpu/gpu_obsd.c @@ -27,7 +27,7 @@ static inline int pciReadConf(int fd, uint8_t bus, uint8_t device, uint8_t func, return 0; } -const char* detectByPci(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* detectByPci([[maybe_unused]] const FFGPUOptions* options, FFlist* gpus) { char pciDevPath[] = "/dev/pci0"; FF_AUTO_CLOSE_FD int pcifd = open(pciDevPath, O_RDONLY | O_CLOEXEC); if (pcifd < 0) { diff --git a/src/detection/gpu/gpu_sunos.c b/src/detection/gpu/gpu_sunos.c index fe9a8b43c..8e896625f 100644 --- a/src/detection/gpu/gpu_sunos.c +++ b/src/detection/gpu/gpu_sunos.c @@ -3,7 +3,7 @@ #include -static int walkDevTree(di_node_t node, FF_A_UNUSED di_minor_t minor, FFlist* gpus) { +static int walkDevTree(di_node_t node, [[maybe_unused]] di_minor_t minor, FFlist* gpus) { int* vendorId; int* deviceId; if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, "vendor-id", &vendorId) > 0 && di_prop_lookup_ints(DDI_DEV_T_ANY, node, "device-id", &deviceId) > 0) { @@ -43,7 +43,7 @@ static int walkDevTree(di_node_t node, FF_A_UNUSED di_minor_t minor, FFlist* gpu return DI_WALK_CONTINUE; } -const char* ffDetectGPUImpl(FF_A_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl([[maybe_unused]] const FFGPUOptions* options, FFlist* gpus) { di_node_t rootNode = di_init("/", DINFOCPYALL); if (rootNode == DI_NODE_NIL) { return "di_init() failed"; diff --git a/src/detection/gpu/gpu_windows.c b/src/detection/gpu/gpu_windows.c index 9e0e3b573..ab4cffae8 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -230,7 +230,7 @@ static void closeDxgfd(void) { } } -FF_A_UNUSED static inline const char* ffDebugNtStatus(NTSTATUS status) { +[[maybe_unused]] static inline const char* ffDebugNtStatus(NTSTATUS status) { return status < 0 ? strerror(-status) : "Success"; } #endif @@ -407,7 +407,7 @@ ffGPUDetectWsl2 const char* dllName; if (options->driverSpecific && getDriverSpecificDetectionFn(gpu->vendor.chars, &detectFn, &dllName)) { FF_DEBUG("Calling driver-specific detection function for vendor: %s, DLL: %s", gpu->vendor.chars, dllName); - FF_A_UNUSED const char* error = detectFn( + [[maybe_unused]] const char* error = detectFn( &(FFGpuDriverCondition) { .type = FF_GPU_DRIVER_CONDITION_TYPE_LUID | (deviceIds.DeviceIds.VendorID != -1u ? FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID : 0) | @@ -613,7 +613,7 @@ ffGPUDetectWsl2 #if _WIN32 else if (ffIsWindows10OrGreater()) { const char* ffGPUDetectTypeWithDXCore(LUID adapterLuid, FFGPUResult * gpu); - FF_A_UNUSED const char* error = ffGPUDetectTypeWithDXCore(adapter->AdapterLuid, gpu); + [[maybe_unused]] const char* error = ffGPUDetectTypeWithDXCore(adapter->AdapterLuid, gpu); FF_DEBUG("DXCore GPU type detection result: %s", error ?: "Success"); } #endif diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index 3cc7911e2..12aaeac14 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -37,7 +37,7 @@ static inline void applyGTKSettings(FFGTKResult* result, const char* themeName, } } -static bool testXfconfWallpaperPropKey(FF_A_UNUSED void* data, const char* key) { +static bool testXfconfWallpaperPropKey([[maybe_unused]] void* data, const char* key) { int count = 0; sscanf(key, "/backdrop/screen0/monitor%*[^/]/workspace0/last-image%n", &count); return count == 0; diff --git a/src/detection/host/host_nosupport.c b/src/detection/host/host_nosupport.c index 61a725433..4475f24f9 100644 --- a/src/detection/host/host_nosupport.c +++ b/src/detection/host/host_nosupport.c @@ -1,5 +1,5 @@ #include "host.h" -const char* ffDetectHost(FF_A_UNUSED FFHostResult* host) { +const char* ffDetectHost([[maybe_unused]] FFHostResult* host) { return "Not supported on this platform"; } diff --git a/src/detection/host/host_windows.c b/src/detection/host/host_windows.c index 0aa90ee08..13bf56e88 100644 --- a/src/detection/host/host_windows.c +++ b/src/detection/host/host_windows.c @@ -1,7 +1,7 @@ #include "host.h" #include "common/smbios.h" -typedef struct FFSmbiosSystemInfo { +typedef struct [[gnu::packed]] FFSmbiosSystemInfo { FFSmbiosHeader Header; uint8_t Manufacturer; // string @@ -10,20 +10,20 @@ typedef struct FFSmbiosSystemInfo { uint8_t SerialNumber; // string // 2.1+ - struct { + struct [[gnu::packed]] { uint32_t TimeLow; uint16_t TimeMid; uint16_t TimeHighAndVersion; uint8_t ClockSeqHiAndReserved; uint8_t ClockSeqLow; uint8_t Node[6]; - } FF_A_PACKED UUID; // varies + } UUID; // varies uint8_t WakeUpType; // enum // 2.4+ uint8_t SKUNumber; // string uint8_t Family; // string -} FF_A_PACKED FFSmbiosSystemInfo; +} FFSmbiosSystemInfo; static_assert(offsetof(FFSmbiosSystemInfo, Family) == 0x1A, "FFSmbiosSystemInfo: Wrong struct alignment"); diff --git a/src/detection/icons/icons_nosupport.c b/src/detection/icons/icons_nosupport.c index ab8cebbc7..ff5ef01ea 100644 --- a/src/detection/icons/icons_nosupport.c +++ b/src/detection/icons/icons_nosupport.c @@ -1,5 +1,5 @@ #include "icons.h" -const char* ffDetectIcons(FF_A_UNUSED FFIconsResult* result) { +const char* ffDetectIcons([[maybe_unused]] FFIconsResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/initsystem/initsystem_linux.c b/src/detection/initsystem/initsystem_linux.c index bd2715293..12243bb4d 100644 --- a/src/detection/initsystem/initsystem_linux.c +++ b/src/detection/initsystem/initsystem_linux.c @@ -6,7 +6,7 @@ #include #include -FF_A_UNUSED static bool extractSystemdVersion(const char* str, uint32_t len, void* userdata) { +[[maybe_unused]] static bool extractSystemdVersion(const char* str, uint32_t len, void* userdata) { if (!ffStrStartsWith(str, "systemd ")) { return true; } diff --git a/src/detection/initsystem/initsystem_nosupport.c b/src/detection/initsystem/initsystem_nosupport.c index e8ccb8e16..b3a5036f4 100644 --- a/src/detection/initsystem/initsystem_nosupport.c +++ b/src/detection/initsystem/initsystem_nosupport.c @@ -1,5 +1,5 @@ #include "initsystem.h" -const char* ffDetectInitSystem(FF_A_UNUSED FFInitSystemResult* result) { +const char* ffDetectInitSystem([[maybe_unused]] FFInitSystemResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/keyboard/keyboard_apple.c b/src/detection/keyboard/keyboard_apple.c index 5d4602257..63adcafd7 100644 --- a/src/detection/keyboard/keyboard_apple.c +++ b/src/detection/keyboard/keyboard_apple.c @@ -18,15 +18,15 @@ static void enumSet(IOHIDDeviceRef value, FFlist* results) { } const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { - IOHIDManagerRef FF_CFTYPE_AUTO_RELEASE manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); + FF_CFTYPE_AUTO_RELEASE IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (IOHIDManagerOpen(manager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) { return "IOHIDManagerOpen() failed"; } - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Keyboard) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Keyboard) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); IOHIDManagerSetDeviceMatching(manager, matching1); - CFSetRef FF_CFTYPE_AUTO_RELEASE set = IOHIDManagerCopyDevices(manager); + FF_CFTYPE_AUTO_RELEASE CFSetRef set = IOHIDManagerCopyDevices(manager); if (set) { CFSetApplyFunction(set, (CFSetApplierFunction) &enumSet, devices); } diff --git a/src/detection/keyboard/keyboard_nosupport.c b/src/detection/keyboard/keyboard_nosupport.c index 6523ed405..a80dfd0ae 100644 --- a/src/detection/keyboard/keyboard_nosupport.c +++ b/src/detection/keyboard/keyboard_nosupport.c @@ -1,5 +1,5 @@ #include "keyboard.h" -const char* ffDetectKeyboard(FF_A_UNUSED FFlist* devices /* List of FFKeyboardDevice */) { +const char* ffDetectKeyboard([[maybe_unused]] FFlist* devices /* List of FFKeyboardDevice */) { return "No mouse support on this platform"; } diff --git a/src/detection/keyboard/keyboard_windows.c b/src/detection/keyboard/keyboard_windows.c index 8dc1fc41e..7d98ac4ed 100644 --- a/src/detection/keyboard/keyboard_windows.c +++ b/src/detection/keyboard/keyboard_windows.c @@ -19,7 +19,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { return "No HID devices found"; } - RAWINPUTDEVICELIST* FF_AUTO_FREE pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices); + FF_AUTO_FREE RAWINPUTDEVICELIST* pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices); if ((nDevices = GetRawInputDeviceList(pRawInputDeviceList, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT) -1) { return "GetRawInputDeviceList(pRawInputDeviceList) failed"; } @@ -49,7 +49,7 @@ const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) { wchar_t buffer[MAX_PATH]; - HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, 0 /* must be 0 instead of GENERIC_READ */, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); + FF_AUTO_CLOSE_FD HANDLE hHidFile = CreateFileW(devName, 0 /* must be 0 instead of GENERIC_READ */, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (hHidFile != INVALID_HANDLE_VALUE) { if (HidD_GetProductString(hHidFile, buffer, (ULONG) sizeof(buffer))) { ffStrbufSetWS(&device->name, buffer); diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index fbce9e0ee..1623c7277 100644 --- a/src/detection/lm/lm_linux.c +++ b/src/detection/lm/lm_linux.c @@ -81,7 +81,7 @@ static const char* getSddmVersion(FFstrbuf* version) { return nullptr; } #else -static const char* getSddmVersion(FF_A_UNUSED FFstrbuf* version) { +static const char* getSddmVersion([[maybe_unused]] FFstrbuf* version) { return "Fastfetch is built without libz support"; } #endif diff --git a/src/detection/lm/lm_nosupport.c b/src/detection/lm/lm_nosupport.c index 22c180307..2f6811379 100644 --- a/src/detection/lm/lm_nosupport.c +++ b/src/detection/lm/lm_nosupport.c @@ -1,5 +1,5 @@ #include "lm.h" -const char* ffDetectLM(FF_A_UNUSED FFLMResult* result) { +const char* ffDetectLM([[maybe_unused]] FFLMResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/loadavg/loadavg_nosupport.c b/src/detection/loadavg/loadavg_nosupport.c index f14c71795..40dde9d2a 100644 --- a/src/detection/loadavg/loadavg_nosupport.c +++ b/src/detection/loadavg/loadavg_nosupport.c @@ -1,5 +1,5 @@ #include "detection/loadavg/loadavg.h" -const char* ffDetectLoadavg(FF_A_UNUSED double result[3]) { +const char* ffDetectLoadavg([[maybe_unused]] double result[3]) { return "Not supported on this platform"; } diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index 8ae6b244d..203543c67 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -982,7 +982,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { #endif #if __sun if (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) { - FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); + [[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open(); for (kstat_t* ks = kc->kc_chain; ks; ks = ks->ks_next) { if (!ffStrEquals(ks->ks_class, "net") || !ffStrEquals(ks->ks_module, "link")) { continue; diff --git a/src/detection/localip/localip_windows.c b/src/detection/localip/localip_windows.c index ecb4159a0..c36118015 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -30,7 +30,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { (int) options->namePrefix.length, options->namePrefix.chars); - IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = nullptr; + FF_AUTO_FREE IP_ADAPTER_ADDRESSES* adapter_addresses = nullptr; // Multiple attempts in case interfaces change while // we are in the middle of querying them. @@ -67,7 +67,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { } } - FF_A_UNUSED int adapterCount = 0, processedCount = 0; + [[maybe_unused]] int adapterCount = 0, processedCount = 0; // Iterate through all of the adapters for (IP_ADAPTER_ADDRESSES* adapter = adapter_addresses; adapter; adapter = adapter->Next) { @@ -127,7 +127,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { uint32_t typesToAdd = options->showType & (FF_LOCALIP_TYPE_IPV4_BIT | FF_LOCALIP_TYPE_IPV6_BIT | FF_LOCALIP_TYPE_ALL_IPS_BIT); FF_DEBUG("Types to add for adapter %u: 0x%X", (unsigned) adapter->IfIndex, typesToAdd); - FF_A_UNUSED int ipv4Count = 0, ipv6Count = 0; + [[maybe_unused]] int ipv4Count = 0, ipv6Count = 0; for (IP_ADAPTER_UNICAST_ADDRESS* ifa = adapter->FirstUnicastAddress; ifa; ifa = ifa->Next) { FF_DEBUG("Processing unicast address: prefix origin=%d, suffix origin=%d, family=%d, DadState=%d", diff --git a/src/detection/media/media_apple.m b/src/detection/media/media_apple.m index 931c0b940..a9f2ada5e 100644 --- a/src/detection/media/media_apple.m +++ b/src/detection/media/media_apple.m @@ -9,10 +9,10 @@ #import // https://github.com/andrewwiik/iOS-Blocks/blob/master/Widgets/Music/MediaRemote.h -extern void MRMediaRemoteGetNowPlayingInfo(dispatch_queue_t dispatcher, void (^callback)(_Nullable CFDictionaryRef info)) FF_A_WEAK_IMPORT; -extern void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, void (^callback)(BOOL playing)) FF_A_WEAK_IMPORT; -extern void MRMediaRemoteGetNowPlayingApplicationDisplayID(dispatch_queue_t queue, void (^callback)(_Nullable CFStringRef displayID)) FF_A_WEAK_IMPORT; -extern void MRMediaRemoteGetNowPlayingApplicationDisplayName(int unknown, dispatch_queue_t queue, void (^callback)(_Nullable CFStringRef name)) FF_A_WEAK_IMPORT; +[[clang::weak_import]] extern void MRMediaRemoteGetNowPlayingInfo(dispatch_queue_t dispatcher, void (^callback)(_Nullable CFDictionaryRef info)); +[[clang::weak_import]] extern void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, void (^callback)(BOOL playing)); +[[clang::weak_import]] extern void MRMediaRemoteGetNowPlayingApplicationDisplayID(dispatch_queue_t queue, void (^callback)(_Nullable CFStringRef displayID)); +[[clang::weak_import]] extern void MRMediaRemoteGetNowPlayingApplicationDisplayName(int unknown, dispatch_queue_t queue, void (^callback)(_Nullable CFStringRef name)); static uint32_t getTrueElapsedTime(CFDictionaryRef info) { double elapsedTime; @@ -111,7 +111,7 @@ static const char* getMediaByMediaRemote(FFMediaResult* result, bool saveCover) } #if !FF_MODULE_DISABLE_MEDIA -__attribute__((visibility("default"), used)) int ffPrintMediaByMediaRemote(int saveCover) { +[[gnu::visibility("default"), gnu::used]] int ffPrintMediaByMediaRemote(int saveCover) { FFMediaResult media = { .status = ffStrbufCreate(), .song = ffStrbufCreate(), diff --git a/src/detection/media/media_windows.cpp b/src/detection/media/media_windows.cpp index 9cb4108a2..8f608c125 100644 --- a/src/detection/media/media_windows.cpp +++ b/src/detection/media/media_windows.cpp @@ -51,7 +51,7 @@ static inline HRESULT ffQueryInterface(SourceAbi* source, abi_t static HRESULT ffWaitForAsyncOperation(TOperationAbi* operation, TResultAbi** result) { - IAsyncInfo* FF_AUTO_RELEASE_COM_OBJECT asyncInfo = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IAsyncInfo* asyncInfo = nullptr; HRESULT hr = ffQueryInterface(operation, &asyncInfo); if (FAILED(hr)) { return hr; @@ -82,7 +82,7 @@ static HRESULT ffWaitForAsyncOperation(TOperationAbi* operation, TResultAbi** re template static HRESULT ffRunAndWait(TOperation&& operation, abi_t** result) { - abi_t>* FF_AUTO_RELEASE_COM_OBJECT opResult = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t>* opResult = nullptr; HRESULT hr = operation(reinterpret_cast(&opResult)); if (FAILED(hr) || !opResult) { return hr; @@ -95,7 +95,7 @@ template static HRESULT ffRunAndWait2(TOperation&& operation, abi_t** result) { *result = nullptr; - abi_t>* FF_AUTO_RELEASE_COM_OBJECT opResult = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t>* opResult = nullptr; HRESULT hr = operation(reinterpret_cast(&opResult)); if (FAILED(hr) || !opResult) { return hr; @@ -107,7 +107,7 @@ static HRESULT ffRunAndWait2(TOperation&& operation, abi_t** static HRESULT ffSaveThumbnailToTempPath( abi_t* thumbnail, FFstrbuf* destination) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT contentStream = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* contentStream = nullptr; HRESULT hr = ffRunAndWait([=](void** result) { return thumbnail->OpenReadAsync(result); }, @@ -116,7 +116,7 @@ static HRESULT ffSaveThumbnailToTempPath( return FAILED(hr) ? hr : E_FAIL; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT randomAccessStream = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* randomAccessStream = nullptr; hr = ffQueryInterface(contentStream, &randomAccessStream); if (FAILED(hr)) { return hr; @@ -132,25 +132,25 @@ static HRESULT ffSaveThumbnailToTempPath( return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE); } - abi_t* FF_AUTO_RELEASE_COM_OBJECT bufferFactory = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* bufferFactory = nullptr; hr = ffGetActivationFactory(L"Windows.Storage.Streams.Buffer", winrt::guid_of(), &bufferFactory); if (FAILED(hr)) { return hr; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT buffer = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* buffer = nullptr; hr = bufferFactory->Create((UINT32) size, reinterpret_cast(&buffer)); if (FAILED(hr) || !buffer) { return FAILED(hr) ? hr : E_FAIL; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT inputStream = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* inputStream = nullptr; hr = ffQueryInterface(contentStream, &inputStream); if (FAILED(hr)) { return hr; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT readBuffer = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* readBuffer = nullptr; hr = ffRunAndWait2([=](void** result) { return inputStream->ReadAsync(buffer, (uint32_t) size, (uint32_t) winrt::Windows::Storage::Streams::InputStreamOptions::None, result); }, @@ -165,7 +165,7 @@ static HRESULT ffSaveThumbnailToTempPath( return FAILED(hr) ? hr : S_FALSE; } - Windows::Storage::Streams::IBufferByteAccess* FF_AUTO_RELEASE_COM_OBJECT byteAccess = nullptr; + FF_AUTO_RELEASE_COM_OBJECT Windows::Storage::Streams::IBufferByteAccess* byteAccess = nullptr; hr = readBuffer->QueryInterface(IID_PPV_ARGS(&byteAccess)); if (FAILED(hr)) { return hr; @@ -217,14 +217,14 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } do { - abi_t* FF_AUTO_RELEASE_COM_OBJECT managerStatics = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* managerStatics = nullptr; HRESULT hr = ffGetActivationFactory(L"Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager", winrt::guid_of(), &managerStatics); if (FAILED(hr) || !managerStatics) { error = "winrt: RoGetActivationFactory(GlobalSystemMediaTransportControlsSessionManager) failed"; break; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT manager = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* manager = nullptr; hr = ffRunAndWait([=](void** result) { return managerStatics->RequestAsync(result); }, @@ -234,11 +234,11 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { break; } - FF_A_CLEANUP(deleteHstring) HSTRING playerId = nullptr; + [[gnu::cleanup(deleteHstring)]] HSTRING playerId = nullptr; - abi_t* FF_AUTO_RELEASE_COM_OBJECT session = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* session = nullptr; if (instance.config.general.playerName.length) { - abi_t>* FF_AUTO_RELEASE_COM_OBJECT sessions = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t>* sessions = nullptr; hr = manager->GetSessions(reinterpret_cast(&sessions)); if (FAILED(hr) || !sessions) { error = "winrt: GetSessions() failed"; @@ -251,7 +251,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { break; } for (uint32_t i = 0; i < sessionCount; i++) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT currentSession = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* currentSession = nullptr; hr = sessions->GetAt(i, reinterpret_cast(¤tSession)); if (FAILED(hr) || !currentSession) { continue; @@ -294,7 +294,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { ffStrbufSetHstring(&result->playerId, playerId); } - abi_t* FF_AUTO_RELEASE_COM_OBJECT mediaProps = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* mediaProps = nullptr; hr = ffRunAndWait([=](void** result) { return session->TryGetMediaPropertiesAsync(result); }, @@ -304,7 +304,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { break; } - abi_t* FF_AUTO_RELEASE_COM_OBJECT playbackInfo = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* playbackInfo = nullptr; hr = session->GetPlaybackInfo(reinterpret_cast(&playbackInfo)); bool isPlaying = false; double playbackRate = 1.0; @@ -327,7 +327,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } } - abi_t>* FF_AUTO_RELEASE_COM_OBJECT playbackRateRef = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t>* playbackRateRef = nullptr; if (SUCCEEDED(playbackInfo->get_PlaybackRate(reinterpret_cast(&playbackRateRef))) && playbackRateRef) { if (SUCCEEDED(playbackRateRef->get_Value(&playbackRate)) && playbackRate < 0.0) { playbackRate = 0.0; @@ -335,22 +335,22 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } } - FF_A_CLEANUP(deleteHstring) HSTRING title = nullptr; + [[gnu::cleanup(deleteHstring)]] HSTRING title = nullptr; if (SUCCEEDED(mediaProps->get_Title(reinterpret_cast(&title)))) { ffStrbufSetHstring(&result->song, title); } - FF_A_CLEANUP(deleteHstring) HSTRING artist = nullptr; + [[gnu::cleanup(deleteHstring)]] HSTRING artist = nullptr; if (SUCCEEDED(mediaProps->get_Artist(reinterpret_cast(&artist)))) { ffStrbufSetHstring(&result->artist, artist); } - FF_A_CLEANUP(deleteHstring) HSTRING album = nullptr; + [[gnu::cleanup(deleteHstring)]] HSTRING album = nullptr; if (SUCCEEDED(mediaProps->get_AlbumTitle(reinterpret_cast(&album)))) { ffStrbufSetHstring(&result->album, album); } - abi_t* FF_AUTO_RELEASE_COM_OBJECT timelineProps = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* timelineProps = nullptr; hr = session->GetTimelineProperties(reinterpret_cast(&timelineProps)); if (SUCCEEDED(hr) && timelineProps) { int64_t duration = 0; @@ -373,14 +373,14 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } } - abi_t* FF_AUTO_RELEASE_COM_OBJECT appInfoStatics = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* appInfoStatics = nullptr; hr = ffGetActivationFactory(L"Windows.ApplicationModel.AppInfo", winrt::guid_of(), &appInfoStatics); if (SUCCEEDED(hr) && appInfoStatics) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT appInfo = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* appInfo = nullptr; if (SUCCEEDED(appInfoStatics->GetFromAppUserModelId(reinterpret_cast(playerId), reinterpret_cast(&appInfo))) && appInfo) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT displayInfo = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* displayInfo = nullptr; if (SUCCEEDED(appInfo->get_DisplayInfo(reinterpret_cast(&displayInfo))) && displayInfo) { - FF_A_CLEANUP(deleteHstring) HSTRING displayName = nullptr; + [[gnu::cleanup(deleteHstring)]] HSTRING displayName = nullptr; if (SUCCEEDED(displayInfo->get_DisplayName(reinterpret_cast(&displayName)))) { ffStrbufSetHstring(&result->player, displayName); } @@ -396,7 +396,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) { } if (saveCover) { - abi_t* FF_AUTO_RELEASE_COM_OBJECT thumbnail = nullptr; + FF_AUTO_RELEASE_COM_OBJECT abi_t* thumbnail = nullptr; hr = mediaProps->get_Thumbnail(reinterpret_cast(&thumbnail)); if (SUCCEEDED(hr) && thumbnail) { if (SUCCEEDED(ffSaveThumbnailToTempPath(thumbnail, &result->cover)) && result->cover.length > 0) { diff --git a/src/detection/memory/memory_nosupport.c b/src/detection/memory/memory_nosupport.c index b44aaadff..6c11799a3 100644 --- a/src/detection/memory/memory_nosupport.c +++ b/src/detection/memory/memory_nosupport.c @@ -1,5 +1,5 @@ #include "memory.h" -const char* ffDetectMemory(FF_A_UNUSED FFMemoryResult* ram) { +const char* ffDetectMemory([[maybe_unused]] FFMemoryResult* ram) { return "Not supported on this platform"; } diff --git a/src/detection/memory/memory_sunos.c b/src/detection/memory/memory_sunos.c index 68f4cb0fe..f61060b3c 100644 --- a/src/detection/memory/memory_sunos.c +++ b/src/detection/memory/memory_sunos.c @@ -15,7 +15,7 @@ const char* ffDetectMemory(FFMemoryResult* ram) { ram->bytesTotal = (uint64_t) sysconf(_SC_PHYS_PAGES) * pageSize; ram->bytesUsed = ram->bytesTotal - (uint64_t) sysconf(_SC_AVPHYS_PAGES) * pageSize; - FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); + [[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open(); if (kc != nullptr) { kstat_t* ksp = kstat_lookup(kc, "zfs", -1, "arcstats"); if (ksp != nullptr && kstat_read(kc, ksp, nullptr) != -1) { diff --git a/src/detection/mouse/mouse_apple.c b/src/detection/mouse/mouse_apple.c index a2035b564..7f0b96cd0 100644 --- a/src/detection/mouse/mouse_apple.c +++ b/src/detection/mouse/mouse_apple.c @@ -18,15 +18,15 @@ static void enumSet(IOHIDDeviceRef value, FFlist* results) { } const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { - IOHIDManagerRef FF_CFTYPE_AUTO_RELEASE manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); + FF_CFTYPE_AUTO_RELEASE IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (IOHIDManagerOpen(manager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) { return "IOHIDManagerOpen() failed"; } - CFDictionaryRef FF_CFTYPE_AUTO_RELEASE matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Mouse) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + FF_CFTYPE_AUTO_RELEASE CFDictionaryRef matching1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**) (CFStringRef[]) { CFSTR(kIOHIDDeviceUsagePageKey), CFSTR(kIOHIDDeviceUsageKey) }, (const void**) (CFNumberRef[]) { ffCfCreateInt(kHIDPage_GenericDesktop), ffCfCreateInt(kHIDUsage_GD_Mouse) }, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); IOHIDManagerSetDeviceMatching(manager, matching1); - CFSetRef FF_CFTYPE_AUTO_RELEASE set = IOHIDManagerCopyDevices(manager); + FF_CFTYPE_AUTO_RELEASE CFSetRef set = IOHIDManagerCopyDevices(manager); if (set) { CFSetApplyFunction(set, (CFSetApplierFunction) &enumSet, devices); } diff --git a/src/detection/mouse/mouse_nosupport.c b/src/detection/mouse/mouse_nosupport.c index aa1332df4..a3b37e347 100644 --- a/src/detection/mouse/mouse_nosupport.c +++ b/src/detection/mouse/mouse_nosupport.c @@ -1,5 +1,5 @@ #include "mouse.h" -const char* ffDetectMouse(FF_A_UNUSED FFlist* devices /* List of FFMouseDevice */) { +const char* ffDetectMouse([[maybe_unused]] FFlist* devices /* List of FFMouseDevice */) { return "No mouse support on this platform"; } diff --git a/src/detection/mouse/mouse_windows.c b/src/detection/mouse/mouse_windows.c index 0b068cb6c..d60028182 100644 --- a/src/detection/mouse/mouse_windows.c +++ b/src/detection/mouse/mouse_windows.c @@ -18,7 +18,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { if (nDevices == 0) { return "No HID devices found"; } - RAWINPUTDEVICELIST* FF_AUTO_FREE pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices); + FF_AUTO_FREE RAWINPUTDEVICELIST* pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices); if ((nDevices = GetRawInputDeviceList(pRawInputDeviceList, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT) -1) { return "GetRawInputDeviceList(pRawInputDeviceList) failed"; } @@ -48,7 +48,7 @@ const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) { wchar_t buffer[MAX_PATH]; - HANDLE FF_AUTO_CLOSE_FD hHidFile = CreateFileW(devName, 0 /* must be 0 instead of GENERIC_READ */, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); + FF_AUTO_CLOSE_FD HANDLE hHidFile = CreateFileW(devName, 0 /* must be 0 instead of GENERIC_READ */, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (hHidFile != INVALID_HANDLE_VALUE) { if (HidD_GetProductString(hHidFile, buffer, (ULONG) sizeof(buffer))) { ffStrbufSetWS(&device->name, buffer); diff --git a/src/detection/netio/netio_nosupport.c b/src/detection/netio/netio_nosupport.c index 30f73a758..4b35bc0b5 100644 --- a/src/detection/netio/netio_nosupport.c +++ b/src/detection/netio/netio_nosupport.c @@ -1,5 +1,5 @@ #include "netio.h" -const char* ffNetIOGetIoCounters(FF_A_UNUSED FFlist* result, FF_A_UNUSED FFNetIOOptions* options) { +const char* ffNetIOGetIoCounters([[maybe_unused]] FFlist* result, [[maybe_unused]] FFNetIOOptions* options) { return "Not supported on this platform"; } diff --git a/src/detection/netio/netio_sunos.c b/src/detection/netio/netio_sunos.c index 19562c880..2b9a02038 100644 --- a/src/detection/netio/netio_sunos.c +++ b/src/detection/netio/netio_sunos.c @@ -12,7 +12,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) { } const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { - FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); + [[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open(); if (!kc) { return "kstat_open() failed"; } diff --git a/src/detection/netio/netio_windows.c b/src/detection/netio/netio_windows.c index ebaca3e6f..4c3f87b3e 100644 --- a/src/detection/netio/netio_windows.c +++ b/src/detection/netio/netio_windows.c @@ -8,7 +8,7 @@ #include const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { - IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = nullptr; + FF_AUTO_FREE IP_ADAPTER_ADDRESSES* adapter_addresses = nullptr; // Multiple attempts in case interfaces change while // we are in the middle of querying them. diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 5c5327c1d..a7b1ffa3f 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -34,7 +34,7 @@ static bool parseOsRelease(const char* fileName, FFOSResult* result) { } // Common logic for detecting Armbian image version -FF_A_UNUSED static bool detectArmbianVersion(FFOSResult* result) { +[[maybe_unused]] static bool detectArmbianVersion(FFOSResult* result) { // Possible values `PRETTY_NAME` starts with on Armbian: // - `Armbian` for official releases // - `Armbian_community` for community releases @@ -55,7 +55,7 @@ FF_A_UNUSED static bool detectArmbianVersion(FFOSResult* result) { } // Returns false if PrettyName should be updated by caller -FF_A_UNUSED static bool getUbuntuFlavour(FFOSResult* result) { +[[maybe_unused]] static bool getUbuntuFlavour(FFOSResult* result) { if (detectArmbianVersion(result)) { return true; } else if (ffStrbufStartsWithS(&result->prettyName, "Linux Lite ")) { @@ -177,7 +177,7 @@ FF_A_UNUSED static bool getUbuntuFlavour(FFOSResult* result) { return false; } -FF_A_UNUSED static void getDebianVersion(FFOSResult* result) { +[[maybe_unused]] static void getDebianVersion(FFOSResult* result) { FF_STRBUF_AUTO_DESTROY debianVersion = ffStrbufCreate(); ffAppendFileBuffer("/etc/debian_version", &debianVersion); ffStrbufTrimRightSpace(&debianVersion); @@ -190,7 +190,7 @@ FF_A_UNUSED static void getDebianVersion(FFOSResult* result) { ffStrbufSetF(&result->prettyName, "%s %s (%s)", result->name.chars, result->versionID.chars, result->codename.chars); } -FF_A_UNUSED static bool detectDebianDerived(FFOSResult* result) { +[[maybe_unused]] static bool detectDebianDerived(FFOSResult* result) { if (detectArmbianVersion(result)) { return true; } else if (ffStrbufStartsWithS(&result->name, "Loc-OS")) { @@ -306,7 +306,7 @@ FF_A_UNUSED static bool detectDebianDerived(FFOSResult* result) { return false; } -FF_A_UNUSED static bool detectFedoraVariant(FFOSResult* result) { +[[maybe_unused]] static bool detectFedoraVariant(FFOSResult* result) { if (ffStrbufEqualS(&result->variantID, "coreos") || ffStrbufEqualS(&result->variantID, "kinoite") || ffStrbufEqualS(&result->variantID, "sericea") || ffStrbufEqualS(&result->variantID, "silverblue")) { ffStrbufAppendC(&result->id, '-'); ffStrbufAppend(&result->id, &result->variantID); @@ -316,7 +316,7 @@ FF_A_UNUSED static bool detectFedoraVariant(FFOSResult* result) { return false; } -FF_A_UNUSED static bool detectBedrock(FFOSResult* os) { +[[maybe_unused]] static bool detectBedrock(FFOSResult* os) { const char* bedrockRestrict = getenv("BEDROCK_RESTRICT"); if (bedrockRestrict && bedrockRestrict[0] == '1') { return false; @@ -324,7 +324,7 @@ FF_A_UNUSED static bool detectBedrock(FFOSResult* os) { return parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock/strata/bedrock/etc/os-release", os); } -FF_A_UNUSED static void detectDeepinEnhancement(FFOSResult* result) { +[[maybe_unused]] static void detectDeepinEnhancement(FFOSResult* result) { if (ffStrbufContainC(&result->prettyName, '(')) { return; } @@ -352,7 +352,7 @@ FF_A_UNUSED static void detectDeepinEnhancement(FFOSResult* result) { } } -FF_A_UNUSED static void detectAstraVersion(FFOSResult* result) { +[[maybe_unused]] static void detectAstraVersion(FFOSResult* result) { // `PRETTY_NAME` is just `Astra Linux`; the version is in `VERSION_ID`, e.g. `2.12_x86-64` if (result->version.length == 0) { // Should be empty. Just in case ffStrbufAppendSUntilC(&result->version, result->versionID.chars, '_'); diff --git a/src/detection/packages/packages_nosupport.c b/src/detection/packages/packages_nosupport.c index 40300fab3..facc9f545 100644 --- a/src/detection/packages/packages_nosupport.c +++ b/src/detection/packages/packages_nosupport.c @@ -1,4 +1,4 @@ #include "packages.h" -void ffDetectPackagesImpl(FF_A_UNUSED FFPackagesResult* result, FF_A_UNUSED FFPackagesOptions* options) { +void ffDetectPackagesImpl([[maybe_unused]] FFPackagesResult* result, [[maybe_unused]] FFPackagesOptions* options) { } diff --git a/src/detection/packages/packages_windows.c b/src/detection/packages/packages_windows.c index a2f54fb15..b4c3883a5 100644 --- a/src/detection/packages/packages_windows.c +++ b/src/detection/packages/packages_windows.c @@ -92,7 +92,7 @@ static void detectScoop(FFPackagesResult* result) { yyjson_val* root = nullptr; - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_file(scoopPath.chars, 0, nullptr, nullptr); + [[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_file(scoopPath.chars, 0, nullptr, nullptr); if (doc) { root = yyjson_doc_get_root(doc); if (!yyjson_is_obj(root)) { @@ -131,7 +131,7 @@ static void detectScoop(FFPackagesResult* result) { } } -static void detectChoco(FF_A_UNUSED FFPackagesResult* result) { +static void detectChoco([[maybe_unused]] FFPackagesResult* result) { const char* chocoInstall = getenv("ChocolateyInstall"); if (!chocoInstall || chocoInstall[0] == '\0') { return; diff --git a/src/detection/physicaldisk/physicaldisk_apple.c b/src/detection/physicaldisk/physicaldisk_apple.c index 624d49788..47098c944 100644 --- a/src/detection/physicaldisk/physicaldisk_apple.c +++ b/src/detection/physicaldisk/physicaldisk_apple.c @@ -22,7 +22,7 @@ static inline void wrapIoDestroyPlugInInterface(IOCFPlugInInterface*** pluginInf static const char* detectSsdTemp(io_service_t entryPhysical, double* temp) { #ifdef MAC_OS_X_VERSION_10_15 - FF_A_CLEANUP(wrapIoDestroyPlugInInterface) IOCFPlugInInterface** pluginInf = nullptr; + [[gnu::cleanup(wrapIoDestroyPlugInInterface)]] IOCFPlugInInterface** pluginInf = nullptr; int32_t score; if (IOCreatePlugInInterfaceForService(entryPhysical, kIONVMeSMARTUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInf, &score) != kIOReturnSuccess) { return "IOCreatePlugInInterfaceForService() failed"; diff --git a/src/detection/physicaldisk/physicaldisk_nosupport.c b/src/detection/physicaldisk/physicaldisk_nosupport.c index 26e0ce881..6e0dd582e 100644 --- a/src/detection/physicaldisk/physicaldisk_nosupport.c +++ b/src/detection/physicaldisk/physicaldisk_nosupport.c @@ -1,5 +1,5 @@ #include "physicaldisk.h" -const char* ffDetectPhysicalDisk(FF_A_UNUSED FFlist* result, FF_A_UNUSED FFPhysicalDiskOptions* options) { +const char* ffDetectPhysicalDisk([[maybe_unused]] FFlist* result, [[maybe_unused]] FFPhysicalDiskOptions* options) { return "Not supported on this platform"; } diff --git a/src/detection/physicaldisk/physicaldisk_windows.c b/src/detection/physicaldisk/physicaldisk_windows.c index c2c1979d8..459ab98ce 100644 --- a/src/detection/physicaldisk/physicaldisk_windows.c +++ b/src/detection/physicaldisk/physicaldisk_windows.c @@ -314,7 +314,7 @@ static void detectPhysicalDisksByInterfaceClass(const char* type, const GUID* in return; } - wchar_t* FF_AUTO_FREE mszDeviceInterfaces = (wchar_t*) malloc(cchDeviceInterfaces * sizeof(wchar_t)); + FF_AUTO_FREE wchar_t* mszDeviceInterfaces = (wchar_t*) malloc(cchDeviceInterfaces * sizeof(wchar_t)); if (!mszDeviceInterfaces) { return; } @@ -331,7 +331,7 @@ static void detectPhysicalDisksByInterfaceClass(const char* type, const GUID* in // MULTI_SZ: "str1\0str2\0...\0\0" for (const wchar_t* p = mszDeviceInterfaces; *p; p += wcslen(p) + 1) { FF_DEBUG("Probing %s: %ls", type, p); - FF_A_UNUSED const char* error = detectPhysicalDisk(type, p, result, options); + [[maybe_unused]] const char* error = detectPhysicalDisk(type, p, result, options); if (error == nullptr) { FF_DEBUG("Detected device \"%s\"", FF_LIST_LAST(FFPhysicalDiskResult, *result)->name.chars); } else { diff --git a/src/detection/physicalmemory/physicalmemory_apple.m b/src/detection/physicalmemory/physicalmemory_apple.m index d39b4ecbe..c58c2f14b 100644 --- a/src/detection/physicalmemory/physicalmemory_apple.m +++ b/src/detection/physicalmemory/physicalmemory_apple.m @@ -121,7 +121,7 @@ static const char* detectFromSystemProfiler(FFlist* result) return nullptr; } -FF_A_UNUSED static const char* detectFromIokit(FFlist* result) +[[maybe_unused]] static const char* detectFromIokit(FFlist* result) { FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen"); if (!entryDevice) @@ -152,7 +152,7 @@ FF_A_UNUSED static const char* detectFromIokit(FFlist* result) return nullptr; } -const char* ffDetectPhysicalMemory(FF_A_UNUSED FFPhysicalMemoryOptions* options, FFlist* result) +const char* ffDetectPhysicalMemory([[maybe_unused]] FFPhysicalMemoryOptions* options, FFlist* result) { #if __aarch64__ if (detectFromIokit(result) == nullptr) diff --git a/src/detection/physicalmemory/physicalmemory_linux.c b/src/detection/physicalmemory/physicalmemory_linux.c index 12956e197..fe248be0c 100644 --- a/src/detection/physicalmemory/physicalmemory_linux.c +++ b/src/detection/physicalmemory/physicalmemory_linux.c @@ -2,7 +2,7 @@ #include "common/smbios.h" // 7.18 -typedef struct FFSmbiosMemoryDevice { +typedef struct [[gnu::packed]] FFSmbiosMemoryDevice { FFSmbiosHeader Header; // 2.1+ @@ -59,7 +59,7 @@ typedef struct FFSmbiosMemoryDevice { uint16_t Pmic0RevisionNumber; // varies uint16_t RcdManufacturerID; // varies uint16_t RcdRevisionNumber; // varies -} FF_A_PACKED FFSmbiosMemoryDevice; +} FFSmbiosMemoryDevice; static_assert(offsetof(FFSmbiosMemoryDevice, RcdRevisionNumber) == 0x62, "FFSmbiosMemoryDevice: Wrong struct alignment"); diff --git a/src/detection/poweradapter/poweradapter_nosupport.c b/src/detection/poweradapter/poweradapter_nosupport.c index d5e725bf4..0a1bcde8f 100644 --- a/src/detection/poweradapter/poweradapter_nosupport.c +++ b/src/detection/poweradapter/poweradapter_nosupport.c @@ -1,5 +1,5 @@ #include "poweradapter.h" -const char* ffDetectPowerAdapter(FF_A_UNUSED FFlist* results) { +const char* ffDetectPowerAdapter([[maybe_unused]] FFlist* results) { return "Not supported on this platform"; } diff --git a/src/detection/processes/processes_windows.c b/src/detection/processes/processes_windows.c index 82888de1c..78ed840b4 100644 --- a/src/detection/processes/processes_windows.c +++ b/src/detection/processes/processes_windows.c @@ -5,7 +5,7 @@ #include const char* ffDetectProcesses(uint32_t* result) { - SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = nullptr; + FF_AUTO_FREE SYSTEM_PROCESS_INFORMATION* pstart = nullptr; // Multiple attempts in case processes change while // we are in the middle of querying them. diff --git a/src/detection/publicip/publicip.c b/src/detection/publicip/publicip.c index bb4ae434f..74c592035 100644 --- a/src/detection/publicip/publicip.c +++ b/src/detection/publicip/publicip.c @@ -78,7 +78,7 @@ const char* ffDetectPublicIp(FFPublicIPOptions* options, FFPublicIpResult* resul } if (options->url.length == 0) { - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(response.chars, response.length, 0, nullptr, nullptr); + [[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_opts(response.chars, response.length, 0, nullptr, nullptr); if (doc) { yyjson_val* root = yyjson_doc_get_root(doc); ffStrbufAppendJsonVal(&result->ip, yyjson_obj_get(root, "ip")); diff --git a/src/detection/sound/sound_haiku.cpp b/src/detection/sound/sound_haiku.cpp index e7a16e2ed..e2cc4c18f 100644 --- a/src/detection/sound/sound_haiku.cpp +++ b/src/detection/sound/sound_haiku.cpp @@ -7,7 +7,7 @@ extern "C" { #include #include -const char* ffDetectSound(FF_A_UNUSED FFSoundOptions* options, FFlist* devices /* List of FFSoundDevice */) { +const char* ffDetectSound([[maybe_unused]] FFSoundOptions* options, FFlist* devices /* List of FFSoundDevice */) { BMediaRoster* roster = BMediaRoster::Roster(); media_node mediaNode; live_node_info liveInfo; diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index 923d65218..7deb1b5f4 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -11,7 +11,7 @@ struct DetectionInfoBundle { FFSoundOptions* options; }; -static void paSinkInfoCallback(FF_A_UNUSED pa_context* c, const pa_sink_info* i, int eol, void* userdata) { +static void paSinkInfoCallback([[maybe_unused]] pa_context* c, const pa_sink_info* i, int eol, void* userdata) { if (eol > 0 || !i) { return; } @@ -39,7 +39,7 @@ static void paSinkInfoCallback(FF_A_UNUSED pa_context* c, const pa_sink_info* i, device->type = (isMain ? FF_SOUND_TYPE_MAIN : FF_SOUND_TYPE_NONE) | (isActive ? FF_SOUND_TYPE_ACTIVE : FF_SOUND_TYPE_NONE); } -static void paServerInfoCallback(FF_A_UNUSED pa_context* c, const pa_server_info* i, void* userdata) { +static void paServerInfoCallback([[maybe_unused]] pa_context* c, const pa_server_info* i, void* userdata) { if (!i) { return; } diff --git a/src/detection/sound/sound_nosupport.c b/src/detection/sound/sound_nosupport.c index b67236082..b04530f9e 100644 --- a/src/detection/sound/sound_nosupport.c +++ b/src/detection/sound/sound_nosupport.c @@ -1,5 +1,5 @@ #include "sound.h" -const char* ffDetectSound(FF_A_UNUSED FFlist* devices /* List of FFSoundDevice */) { +const char* ffDetectSound([[maybe_unused]] FFlist* devices /* List of FFSoundDevice */) { return "Not supported on this platform"; } diff --git a/src/detection/sound/sound_obsd.c b/src/detection/sound/sound_obsd.c index 790bde41a..e2c4238b5 100644 --- a/src/detection/sound/sound_obsd.c +++ b/src/detection/sound/sound_obsd.c @@ -57,7 +57,7 @@ static void enumerate_props(FFSoundDeviceBundle* bundle, struct sioctl_desc* des } const char* ffDetectSound(FFSoundOptions* options, FFlist* devices) { - FF_A_CLEANUP(close_hdl) struct sioctl_hdl* hdl = sioctl_open(SIO_DEVANY, SIOCTL_READ, 0); + [[gnu::cleanup(close_hdl)]] struct sioctl_hdl* hdl = sioctl_open(SIO_DEVANY, SIOCTL_READ, 0); if (!hdl) { return "sio_open() failed"; } diff --git a/src/detection/sound/sound_windows.cpp b/src/detection/sound/sound_windows.cpp index 2ec923d1d..59823a0b8 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -17,15 +17,15 @@ static void ffCoTaskMemFreeWrapper(void* pptr) { CoTaskMemFree(ptr); } } -#define FF_COTASK_AUTO_FREE FF_A_CLEANUP(ffCoTaskMemFreeWrapper) +#define FF_COTASK_AUTO_FREE [[gnu::cleanup(ffCoTaskMemFreeWrapper)]] static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */, IMMDevice* immDevice, LPWSTR mainDeviceId) { - LPWSTR FF_COTASK_AUTO_FREE immDeviceId = nullptr; + FF_COTASK_AUTO_FREE LPWSTR immDeviceId = nullptr; if (FAILED(immDevice->GetId(&immDeviceId))) { return "immDevice->GetId() failed"; } - IPropertyStore* FF_AUTO_RELEASE_COM_OBJECT immPropStore = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IPropertyStore* immPropStore = nullptr; if (FAILED(immDevice->OpenPropertyStore(STGM_READ, &immPropStore))) { return "immDevice->OpenPropertyStore() failed"; } @@ -54,7 +54,7 @@ static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */ } } - IAudioEndpointVolume* FF_AUTO_RELEASE_COM_OBJECT immEndpointVolume = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IAudioEndpointVolume* immEndpointVolume = nullptr; if (SUCCEEDED(immDevice->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, nullptr, (void**) &immEndpointVolume))) { BOOL muted; if (FAILED(immEndpointVolume->GetMute(&muted)) || !muted) { @@ -74,16 +74,16 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF return error; } - IMMDeviceEnumerator* FF_AUTO_RELEASE_COM_OBJECT pEnum = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMMDeviceEnumerator* pEnum = nullptr; if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pEnum)))) { return "CoCreateInstance(CLSID_MMDeviceEnumerator) failed"; } - LPWSTR FF_COTASK_AUTO_FREE mainDeviceId = nullptr; + FF_COTASK_AUTO_FREE LPWSTR mainDeviceId = nullptr; { - IMMDevice* FF_AUTO_RELEASE_COM_OBJECT pDefaultDevice = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMMDevice* pDefaultDevice = nullptr; if (FAILED(pEnum->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDefaultDevice))) { return "GetDefaultAudioEndpoint() failed"; @@ -98,7 +98,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF } } - IMMDeviceCollection* FF_AUTO_RELEASE_COM_OBJECT pDevices = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMMDeviceCollection* pDevices = nullptr; if (FAILED(pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE | (options->soundType & FF_SOUND_TYPE_ACTIVE ? 0 : DEVICE_STATE_DISABLED), &pDevices))) { return "EnumAudioEndpoints() failed"; @@ -110,7 +110,7 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF } for (uint32_t deviceIdx = 0; deviceIdx < deviceCount; ++deviceIdx) { - IMMDevice* FF_AUTO_RELEASE_COM_OBJECT immDevice = nullptr; + FF_AUTO_RELEASE_COM_OBJECT IMMDevice* immDevice = nullptr; if (FAILED(pDevices->Item(deviceIdx, &immDevice))) { continue; } diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index a365752ea..e3b43a52a 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -173,7 +173,7 @@ static void detectGhostty(const FFstrbuf* exe, FFTerminalFontResult* terminalFon FF_DEBUG("detectGhostty: end"); } -FF_A_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) { +[[maybe_unused]] static void detectTTY(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); ffParsePropFile(FASTFETCH_TARGET_DIR_ETC "/vconsole.conf", "Font =", &fontName); @@ -192,7 +192,7 @@ FF_A_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) { } } -FF_A_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* result) { +[[maybe_unused]] static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* result) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY fontSize = ffStrbufCreate(); diff --git a/src/detection/terminalfont/terminalfont_linux.c b/src/detection/terminalfont/terminalfont_linux.c index 70afc34a6..a351e584e 100644 --- a/src/detection/terminalfont/terminalfont_linux.c +++ b/src/detection/terminalfont/terminalfont_linux.c @@ -277,7 +277,7 @@ static void detectXterm(FFTerminalFontResult* terminalFont) { ffFontInitValues(&terminalFont->font, fontName.chars, fontSize.chars); } -static bool extractStTermFont(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractStTermFont(const char* str, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffStrContains(str, "size=")) { return true; } diff --git a/src/detection/terminalfont/terminalfont_windows.c b/src/detection/terminalfont/terminalfont_windows.c index baf1d5fd3..c03fea1b6 100644 --- a/src/detection/terminalfont/terminalfont_windows.c +++ b/src/detection/terminalfont/terminalfont_windows.c @@ -44,7 +44,7 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) { } static const char* detectFromWTImpl(FFstrbuf* content, FFstrbuf* name, double* size) { - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, nullptr, nullptr); + [[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, nullptr, nullptr); if (!doc) { return "Failed to parse WT JSON config file"; } diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 035853650..911b34dfb 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -51,7 +51,7 @@ static bool getExeVersionGeneral(FFstrbuf* exe, FFstrbuf* version) { return true; } -static bool extractBashVersion(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractBashVersion(const char* line, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffStrStartsWith(line, "@(#)Bash version ")) { return true; } @@ -202,7 +202,7 @@ static bool getShellVersionAsh(FFstrbuf* exe, FFstrbuf* version) { return true; } -static bool getShellVersionXonsh(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { +static bool getShellVersionXonsh([[maybe_unused]] FFstrbuf* exe, FFstrbuf* version) { ffStrbufSetS(version, getenv("XONSH_VERSION")); if (version->length) { return true; @@ -218,7 +218,7 @@ static bool getShellVersionXonsh(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { return true; } -static bool extractZshVersion(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractZshVersion(const char* line, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffStrStartsWith(line, "zsh-")) { return true; } @@ -315,12 +315,12 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) return false; } -FF_A_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionTermux(FFstrbuf* version) { ffStrbufSetS(version, getenv("TERMUX_VERSION")); return version->length > 0; } -static bool extractGeneralVersion(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractGeneralVersion(const char* str, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffCharIsDigit(str[0])) { return true; } @@ -333,7 +333,7 @@ static bool extractGeneralVersion(const char* str, FF_A_UNUSED uint32_t len, voi return false; } -FF_A_UNUSED static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* version) { if (ffIsAbsolutePath(exe->chars)) { ffBinaryExtractStrings(exe->chars, extractGeneralVersion, version, (uint32_t) strlen("0.0.0")); if (version->length) { @@ -351,7 +351,7 @@ FF_A_UNUSED static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* version return true; } -FF_A_UNUSED static bool getTerminalVersionXfce4Terminal(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionXfce4Terminal(FFstrbuf* exe, FFstrbuf* version) { if (ffIsAbsolutePath(exe->chars)) { ffBinaryExtractStrings(exe->chars, extractGeneralVersion, version, (uint32_t) strlen("0.0.0")); if (version->length) { @@ -362,7 +362,7 @@ FF_A_UNUSED static bool getTerminalVersionXfce4Terminal(FFstrbuf* exe, FFstrbuf* return getExeVersionGeneral(exe, version); // xfce4-terminal 1.0.4 (Xfce 4.18)... } -FF_A_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionKgx(FFstrbuf* version) { if (ffProcessAppendStdOut(version, (char* const[]) { "kgx", "--version", nullptr })) { return false; } @@ -373,7 +373,7 @@ FF_A_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version) { return true; } -FF_A_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* version) { const char* konsoleVersion = getenv("KONSOLE_VERSION"); if (konsoleVersion) { // 221201 @@ -395,7 +395,7 @@ FF_A_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* versi return ffStrbufSubstrAfterLastC(version, ' '); } -FF_A_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* version) { uint32_t major = 0, minor = 0, patch = 0; if (ffGetTerminalResponse("\e[>c", 3, "\e[>1;%2u%2u%2u;0c", &major, &minor, &patch) == nullptr) { ffStrbufSetF(version, "%u.%u.%u", major, minor, patch); @@ -412,7 +412,7 @@ FF_A_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* version) return true; } -FF_A_UNUSED static bool getTerminalVersionMateTerminal(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionMateTerminal(FFstrbuf* exe, FFstrbuf* version) { ffBinaryExtractStrings(exe->chars, extractGeneralVersion, version, (uint32_t) strlen("0.0.0")); if (version->length > 0) { return true; @@ -427,7 +427,7 @@ FF_A_UNUSED static bool getTerminalVersionMateTerminal(FFstrbuf* exe, FFstrbuf* return version->length > 0; } -FF_A_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* version) { if (!getExeVersionRaw(exe, version)) { return false; } @@ -438,7 +438,7 @@ FF_A_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* versi return version->length > 0; } -FF_A_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version) { ffStrbufSetS(version, getenv("XTERM_VERSION")); if (!version->length) { if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-v", nullptr })) { @@ -452,7 +452,7 @@ FF_A_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version return version->length > 0; } -FF_A_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr })) { return false; } @@ -463,7 +463,7 @@ FF_A_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* vers return version->length > 0; } -FF_A_UNUSED static bool getTerminalVersionUrxvt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionUrxvt([[maybe_unused]] FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdErr(version, (char* const[]) { "urxvt", // Don't use exe because of urxvtd "-invalid", nullptr })) { @@ -478,7 +478,7 @@ FF_A_UNUSED static bool getTerminalVersionUrxvt(FF_A_UNUSED FFstrbuf* exe, FFstr return version->length > 0; } -FF_A_UNUSED static bool getTerminalVersionSt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionSt([[maybe_unused]] FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "-v", nullptr })) { return false; } @@ -489,7 +489,7 @@ FF_A_UNUSED static bool getTerminalVersionSt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf return version->length > 0; } -FF_A_UNUSED static bool getTerminalVersionLxterminal(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionLxterminal(FFstrbuf* exe, FFstrbuf* version) { if (!getExeVersionRaw(exe, version)) { return false; } @@ -498,7 +498,7 @@ FF_A_UNUSED static bool getTerminalVersionLxterminal(FFstrbuf* exe, FFstrbuf* ve return version->length > 0; } -FF_A_UNUSED static bool getTerminalVersionWeston(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionWeston([[maybe_unused]] FFstrbuf* exe, FFstrbuf* version) { // weston-terminal doesn't report a version, use weston version instead if (ffProcessAppendStdOut(version, (char* const[]) { "weston", "--version", nullptr })) { return false; @@ -510,7 +510,7 @@ FF_A_UNUSED static bool getTerminalVersionWeston(FF_A_UNUSED FFstrbuf* exe, FFst return version->length > 0; } -FF_A_UNUSED static bool extractKmsconVersion(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { +[[maybe_unused]] static bool extractKmsconVersion(const char* str, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffStrStartsWith(str, "v")) { return true; } @@ -523,7 +523,7 @@ FF_A_UNUSED static bool extractKmsconVersion(const char* str, FF_A_UNUSED uint32 return false; } -FF_A_UNUSED static bool getTerminalVersionKmscon(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionKmscon(FFstrbuf* exe, FFstrbuf* version) { if (ffIsAbsolutePath(exe->chars)) { ffBinaryExtractStrings(exe->chars, extractKmsconVersion, version, (uint32_t) strlen("v0.0.0")); if (version->length) { @@ -603,7 +603,7 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version) { return true; } -static bool extractSshdVersion(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractSshdVersion(const char* str, [[maybe_unused]] uint32_t len, void* userdata) { if (!ffStrStartsWith(str, "OpenSSH_") || !ffCharIsDigit(str[strlen("OpenSSH_")])) { return true; } @@ -695,7 +695,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { return getExeVersionGeneral(exe, version); } -FF_A_UNUSED static bool getTerminalVersionPtyxis(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionPtyxis([[maybe_unused]] FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdOut(version, (char* const[]) { "ptyxis", "--version", nullptr }) != nullptr) { return false; } @@ -705,7 +705,7 @@ FF_A_UNUSED static bool getTerminalVersionPtyxis(FF_A_UNUSED FFstrbuf* exe, FFst return true; } -FF_A_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version) { if (ffIsAbsolutePath(exe->chars)) { ffBinaryExtractStrings(exe->chars, extractGeneralVersion, version, (uint32_t) strlen("0.0.0")); if (version->length) { @@ -730,7 +730,7 @@ FF_A_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version return true; } -FF_A_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) { // sakura version is 3.8.8 return false; } @@ -739,7 +739,7 @@ FF_A_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* versio return true; } -FF_A_UNUSED static bool getTerminalVersionTermite(FFstrbuf* exe, FFstrbuf* version) { +[[maybe_unused]] static bool getTerminalVersionTermite(FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", nullptr }) != nullptr) { // termite v16.9\nvte 0.78.1 +BIDI +GNUTLS +ICU +SYSTEMD return false; } @@ -777,7 +777,7 @@ static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version) { #endif -bool fftsGetTerminalVersion(FFstrbuf* processName, FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { +bool fftsGetTerminalVersion(FFstrbuf* processName, [[maybe_unused]] FFstrbuf* exe, FFstrbuf* version) { #ifdef __ANDROID__ if (ffStrbufEqualS(processName, "com.termux")) { diff --git a/src/detection/theme/theme_nosupport.c b/src/detection/theme/theme_nosupport.c index 6f42b964d..4e58860b2 100644 --- a/src/detection/theme/theme_nosupport.c +++ b/src/detection/theme/theme_nosupport.c @@ -1,5 +1,5 @@ #include "theme.h" -const char* ffDetectTheme(FF_A_UNUSED FFThemeResult* result) { +const char* ffDetectTheme([[maybe_unused]] FFThemeResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/tpm/tpm_nosupport.c b/src/detection/tpm/tpm_nosupport.c index 492f37f75..2e48e2b4e 100644 --- a/src/detection/tpm/tpm_nosupport.c +++ b/src/detection/tpm/tpm_nosupport.c @@ -1,5 +1,5 @@ #include "tpm.h" -const char* ffDetectTPM(FF_A_UNUSED FFTPMResult* result) { +const char* ffDetectTPM([[maybe_unused]] FFTPMResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/users/users_linux.c b/src/detection/users/users_linux.c index 8135cb6d6..a5f31d2a0 100644 --- a/src/detection/users/users_linux.c +++ b/src/detection/users/users_linux.c @@ -143,7 +143,7 @@ static void fillUtmpIpAddr(FFUserResult* user, struct utmpx* n) { } } #else -static void fillUtmpIpAddr(FF_A_UNUSED FFUserResult* user, FF_A_UNUSED struct utmpx* n) { +static void fillUtmpIpAddr([[maybe_unused]] FFUserResult* user, [[maybe_unused]] struct utmpx* n) { } #endif diff --git a/src/detection/users/users_obsd.c b/src/detection/users/users_obsd.c index fa10112cc..a9b03072c 100644 --- a/src/detection/users/users_obsd.c +++ b/src/detection/users/users_obsd.c @@ -4,7 +4,7 @@ #include -const char* ffDetectUsers(FF_A_UNUSED FFUsersOptions* options, FFlist* users) { +const char* ffDetectUsers([[maybe_unused]] FFUsersOptions* options, FFlist* users) { FF_AUTO_CLOSE_FILE FILE* fp = fopen(_PATH_UTMP, "r"); if (!fp) { return "fopen(_PATH_UTMP, r) failed"; diff --git a/src/detection/wallpaper/wallpaper_nosupport.c b/src/detection/wallpaper/wallpaper_nosupport.c index 9be8e9183..dd9783ea8 100644 --- a/src/detection/wallpaper/wallpaper_nosupport.c +++ b/src/detection/wallpaper/wallpaper_nosupport.c @@ -1,5 +1,5 @@ #include "wallpaper.h" -const char* ffDetectWallpaper(FF_A_UNUSED FFstrbuf* result) { +const char* ffDetectWallpaper([[maybe_unused]] FFstrbuf* result) { return "Not supported on this platform"; } diff --git a/src/detection/wifi/wifi_android.c b/src/detection/wifi/wifi_android.c index bf1ceab48..4fbc4afb2 100644 --- a/src/detection/wifi/wifi_android.c +++ b/src/detection/wifi/wifi_android.c @@ -20,7 +20,7 @@ const char* ffDetectWifi(FFlist* result) { return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; } - yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); + [[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr); if (!doc) { return "Failed to parse wifi connection info"; } diff --git a/src/detection/wifi/wifi_nosupport.c b/src/detection/wifi/wifi_nosupport.c index bb4a806ea..e49d6607f 100644 --- a/src/detection/wifi/wifi_nosupport.c +++ b/src/detection/wifi/wifi_nosupport.c @@ -1,5 +1,5 @@ #include "wifi.h" -const char* ffDetectWifi(FF_A_UNUSED FFlist* result) { +const char* ffDetectWifi([[maybe_unused]] FFlist* result) { return "Not support on this platform"; } diff --git a/src/detection/wm/wm_apple.m b/src/detection/wm/wm_apple.m index d414c20c1..c4bc780a2 100644 --- a/src/detection/wm/wm_apple.m +++ b/src/detection/wm/wm_apple.m @@ -71,7 +71,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) { return nullptr; } -const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNUSED FFWMOptions* options) { +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, [[maybe_unused]] FFWMOptions* options) { if (!wmName) { return "No WM detected"; } diff --git a/src/detection/wm/wm_linux.c b/src/detection/wm/wm_linux.c index c7c700938..5e3fff085 100644 --- a/src/detection/wm/wm_linux.c +++ b/src/detection/wm/wm_linux.c @@ -7,11 +7,11 @@ #include "common/strutil.h" #include "common/debug.h" -const char* ffDetectWMPlugin(FF_A_UNUSED FFstrbuf* pluginName) { +const char* ffDetectWMPlugin([[maybe_unused]] FFstrbuf* pluginName) { return "Not supported on this platform"; } -static bool extractCommonWmVersion(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractCommonWmVersion(const char* line, [[maybe_unused]] uint32_t len, void* userdata) { int count = 0; sscanf(line, "%*d.%*d.%*d%n", &count); if (count == 0) { @@ -97,7 +97,7 @@ static const char* getHyprland(FFstrbuf* result) { return "Failed to run command `Hyprland --version`"; } -static bool extractSwayVersion(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractSwayVersion(const char* line, [[maybe_unused]] uint32_t len, void* userdata) { FFstrbuf* result = (FFstrbuf*) userdata; if (!ffStrStartsWith(line, "sway")) { return true; @@ -210,7 +210,7 @@ static const char* getWslg(FFstrbuf* result) { #endif // !__ANDROID__ -static bool extractI3Version(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { +static bool extractI3Version(const char* line, [[maybe_unused]] uint32_t len, void* userdata) { int count = 0; sscanf(line, "%*d.%*d%n", &count); if (count == 0) { @@ -305,7 +305,7 @@ static const char* getOpenbox(FFstrbuf* result) { return "Failed to run command `openbox --version`"; } -const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNUSED FFWMOptions* options) { +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, [[maybe_unused]] FFWMOptions* options) { if (!wmName) { return "No WM detected"; } diff --git a/src/detection/wm/wm_nosupport.c b/src/detection/wm/wm_nosupport.c index 65c53489b..8cf845c81 100644 --- a/src/detection/wm/wm_nosupport.c +++ b/src/detection/wm/wm_nosupport.c @@ -1,9 +1,9 @@ #include "wm.h" -const char* ffDetectWMPlugin(FF_A_UNUSED FFstrbuf* pluginName) { +const char* ffDetectWMPlugin([[maybe_unused]] FFstrbuf* pluginName) { return "Not supported on this platform"; } -const char* ffDetectWMVersion(FF_A_UNUSED const FFstrbuf* wmName, FF_A_UNUSED FFstrbuf* result, FF_A_UNUSED FFWMOptions* options) { +const char* ffDetectWMVersion([[maybe_unused]] const FFstrbuf* wmName, [[maybe_unused]] FFstrbuf* result, [[maybe_unused]] FFWMOptions* options) { return "Not supported on this platform"; } diff --git a/src/detection/wm/wm_windows.c b/src/detection/wm/wm_windows.c index 0a3fc9adf..01a336b28 100644 --- a/src/detection/wm/wm_windows.c +++ b/src/detection/wm/wm_windows.c @@ -117,7 +117,7 @@ static bool isProcessTrusted(DWORD processId, FFProcessType processType, UNICODE const char* ffDetectWMPlugin(FFstrbuf* pluginName) { alignas(UNICODE_STRING) uint8_t buffer[4096]; UNICODE_STRING* filePath = (UNICODE_STRING*) buffer; - SYSTEM_PROCESS_INFORMATION* FF_AUTO_FREE pstart = nullptr; + FF_AUTO_FREE SYSTEM_PROCESS_INFORMATION* pstart = nullptr; // Multiple attempts in case processes change while // we are in the middle of querying them. @@ -184,7 +184,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) { return nullptr; } -const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNUSED FFWMOptions* options) { +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, [[maybe_unused]] FFWMOptions* options) { if (!wmName) { return "No WM detected"; } diff --git a/src/detection/zpool/zpool.c b/src/detection/zpool/zpool.c index ee648b725..ebabf45a3 100644 --- a/src/detection/zpool/zpool.c +++ b/src/detection/zpool/zpool.c @@ -85,7 +85,7 @@ const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */) { return "libzfs_init() failed"; } - FF_A_CLEANUP(cleanLibzfs) FFZfsData data = { + [[gnu::cleanup(cleanLibzfs)]] FFZfsData data = { .handle = handle, .result = result, }; @@ -123,7 +123,7 @@ const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */) { #else -const char* ffDetectZpool(FF_A_UNUSED FFlist* result) { +const char* ffDetectZpool([[maybe_unused]] FFlist* result) { return "fastfetch was compiled without libzfs support"; } diff --git a/src/fastfetch.c b/src/fastfetch.c index 38070a5dc..cad134e15 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -15,7 +15,7 @@ #include #include -FF_A_COLD +[[gnu::cold]] static void printCommandFormatHelpJson(void) { yyjson_mut_doc* doc = yyjson_mut_doc_new(nullptr); yyjson_mut_val* root = yyjson_mut_obj(doc); @@ -50,7 +50,7 @@ static void printCommandFormatHelpJson(void) { yyjson_mut_doc_free(doc); } -FF_A_COLD +[[gnu::cold]] static void printCommandFormatHelp(const char* command) { FF_STRBUF_AUTO_DESTROY type = ffStrbufCreateNS((uint32_t) (strlen(command) - strlen("-format")), command); ffStrbufLowerCase(&type); @@ -87,7 +87,7 @@ static void printCommandFormatHelp(const char* command) { fprintf(stderr, "Error: Module '%s' is not supported\n", type.chars); } -FF_A_COLD +[[gnu::cold]] static void printFullHelp() { fputs("Fastfetch is a neofetch-like tool for fetching system information and displaying them in a pretty way\n\n", stdout); if (!instance.config.display.pipe) { @@ -194,7 +194,7 @@ For detailed information on logo options, module configuration, and formatting, https://github.com/fastfetch-cli/fastfetch/wiki/Configuration"); } -FF_A_COLD +[[gnu::cold]] static bool printSpecificCommandHelp(const char* command) { yyjson_doc* doc = yyjson_read(FASTFETCH_DATATEXT_JSON_HELP, strlen(FASTFETCH_DATATEXT_JSON_HELP), YYJSON_READ_NOFLAG); assert(doc); @@ -305,7 +305,7 @@ static bool printSpecificCommandHelp(const char* command) { return false; } -FF_A_COLD +[[gnu::cold]] static void printCommandHelp(const char* command) { if (command == nullptr) { printFullHelp(); @@ -318,7 +318,7 @@ static void printCommandHelp(const char* command) { } } -FF_A_COLD +[[gnu::cold]] static void listAvailablePresets(bool pretty) { FF_LIST_FOR_EACH (FFstrbuf, path, instance.state.platform.dataDirs) { ffStrbufAppendS(path, "fastfetch/presets/"); @@ -333,7 +333,7 @@ static void listAvailablePresets(bool pretty) { } } -FF_A_COLD +[[gnu::cold]] static void listAvailableLogos(void) { FF_LIST_FOR_EACH (FFstrbuf, path, instance.state.platform.dataDirs) { ffStrbufAppendS(path, "fastfetch/logos/"); @@ -341,7 +341,7 @@ static void listAvailableLogos(void) { } } -FF_A_COLD +[[gnu::cold]] static void listConfigPaths(void) { FF_LIST_FOR_EACH (FFstrbuf, folder, instance.state.platform.configDirs) { bool exists = false; @@ -353,7 +353,7 @@ static void listConfigPaths(void) { } } -FF_A_COLD +[[gnu::cold]] static void listDataPaths(void) { FF_LIST_FOR_EACH (FFstrbuf, folder, instance.state.platform.dataDirs) { ffStrbufAppendS(folder, "fastfetch/"); @@ -361,7 +361,7 @@ static void listDataPaths(void) { } } -FF_A_COLD +[[gnu::cold]] static void listModules(bool pretty) { unsigned count = 0; for (int i = 0; i <= 'Z' - 'A'; ++i) { @@ -431,7 +431,7 @@ static bool parseJsoncFile(FFdata* data, const char* path, yyjson_read_flag flg) return true; } -FF_A_COLD +[[gnu::cold]] static void generateConfigFile(FFdata* data, bool force, const char* filePath, bool fullConfig) { if (data->resultDoc) { fprintf(stderr, "Error: duplicated `--gen-config` or `--format json` flags found\n"); @@ -569,7 +569,7 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val exit(414); } -FF_A_COLD +[[gnu::cold]] static void printVersion() { FFVersionResult* result = &ffVersionResult; printf("%s %s%s%s (%s)\n", result->projectName, result->version, result->versionTweak, result->debugMode ? "-debug" : "", result->architecture); @@ -809,7 +809,7 @@ static void run(FFdata* data) { } } -FF_A_COLD +[[gnu::cold]] static void writeConfigFile(FFdata* data) { const FFstrbuf* filename = &data->genConfigPath; diff --git a/src/flashfetch.c b/src/flashfetch.c index e056ca29c..d75dcb512 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -5,7 +5,7 @@ #include "modules/modules.h" #define MODULE_OPTION(name) \ - FF_A_CLEANUP(ffDestroy##name##Options) FF##name##Options options; \ + [[gnu::cleanup(ffDestroy##name##Options)]] FF##name##Options options; \ ffInit##name##Options(&options); // A dirty replicate of neofetch; demonstration only. diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index 8f8700ff1..6113b0929 100644 --- a/src/modules/bios/bios.c +++ b/src/modules/bios/bios.c @@ -88,7 +88,7 @@ void ffGenerateBiosJsonConfig(FFBiosOptions* options, yyjson_mut_doc* doc, yyjso ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateBiosJsonResult(FF_A_UNUSED FFBiosOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBiosJsonResult([[maybe_unused]] FFBiosOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFBiosResult bios; ffStrbufInit(&bios.date); diff --git a/src/modules/bluetoothradio/bluetoothradio.c b/src/modules/bluetoothradio/bluetoothradio.c index 518689af3..9efc0a057 100644 --- a/src/modules/bluetoothradio/bluetoothradio.c +++ b/src/modules/bluetoothradio/bluetoothradio.c @@ -145,7 +145,7 @@ void ffGenerateBluetoothRadioJsonConfig(FFBluetoothRadioOptions* options, yyjson ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateBluetoothRadioJsonResult(FF_A_UNUSED FFBluetoothRadioOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBluetoothRadioJsonResult([[maybe_unused]] FFBluetoothRadioOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(); const char* error = ffDetectBluetoothRadio(&results); diff --git a/src/modules/board/board.c b/src/modules/board/board.c index a0801a274..bc8f37cae 100644 --- a/src/modules/board/board.c +++ b/src/modules/board/board.c @@ -64,7 +64,7 @@ void ffGenerateBoardJsonConfig(FFBoardOptions* options, yyjson_mut_doc* doc, yyj ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateBoardJsonResult(FF_A_UNUSED FFBoardOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBoardJsonResult([[maybe_unused]] FFBoardOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFBoardResult board; ffStrbufInit(&board.name); diff --git a/src/modules/bootmgr/bootmgr.c b/src/modules/bootmgr/bootmgr.c index f44d67a8d..05cb46713 100644 --- a/src/modules/bootmgr/bootmgr.c +++ b/src/modules/bootmgr/bootmgr.c @@ -67,7 +67,7 @@ void ffGenerateBootmgrJsonConfig(FFBootmgrOptions* options, yyjson_mut_doc* doc, ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateBootmgrJsonResult(FF_A_UNUSED FFBootmgrOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBootmgrJsonResult([[maybe_unused]] FFBootmgrOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFBootmgrResult bootmgr = { .name = ffStrbufCreate(), diff --git a/src/modules/break/break.c b/src/modules/break/break.c index 76e9f0fc2..7bca2b61c 100644 --- a/src/modules/break/break.c +++ b/src/modules/break/break.c @@ -2,13 +2,13 @@ #include "logo/logo.h" #include "modules/break/break.h" -bool ffPrintBreak(FF_A_UNUSED FFBreakOptions* options) { +bool ffPrintBreak([[maybe_unused]] FFBreakOptions* options) { ffLogoPrintLine(); putchar('\n'); return true; } -void ffParseBreakJsonObject(FF_A_UNUSED FFBreakOptions* options, FF_A_UNUSED yyjson_val* module) { +void ffParseBreakJsonObject([[maybe_unused]] FFBreakOptions* options, [[maybe_unused]] yyjson_val* module) { yyjson_val *key, *val; size_t idx, max; yyjson_obj_foreach (module, idx, max, key, val) { @@ -20,10 +20,10 @@ void ffParseBreakJsonObject(FF_A_UNUSED FFBreakOptions* options, FF_A_UNUSED yyj } } -void ffInitBreakOptions(FF_A_UNUSED FFBreakOptions* options) { +void ffInitBreakOptions([[maybe_unused]] FFBreakOptions* options) { } -void ffDestroyBreakOptions(FF_A_UNUSED FFBreakOptions* options) { +void ffDestroyBreakOptions([[maybe_unused]] FFBreakOptions* options) { } FFModuleBaseInfo ffBreakModuleInfo = { diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 54bb98940..1d4971fcb 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -148,7 +148,7 @@ void ffGenerateBrightnessJsonConfig(FFBrightnessOptions* options, yyjson_mut_doc yyjson_mut_obj_add_bool(doc, module, "compact", options->compact); } -bool ffGenerateBrightnessJsonResult(FF_A_UNUSED FFBrightnessOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBrightnessJsonResult([[maybe_unused]] FFBrightnessOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(); const char* error = ffDetectBrightness(options, &result); diff --git a/src/modules/btrfs/btrfs.c b/src/modules/btrfs/btrfs.c index 238d17767..d9661c2e3 100644 --- a/src/modules/btrfs/btrfs.c +++ b/src/modules/btrfs/btrfs.c @@ -146,7 +146,7 @@ void ffGenerateBtrfsJsonConfig(FFBtrfsOptions* options, yyjson_mut_doc* doc, yyj ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateBtrfsJsonResult(FF_A_UNUSED FFBtrfsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBtrfsJsonResult([[maybe_unused]] FFBtrfsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(); const char* error = ffDetectBtrfs(&results); diff --git a/src/modules/camera/camera.c b/src/modules/camera/camera.c index 7067bbc2f..08cb10706 100644 --- a/src/modules/camera/camera.c +++ b/src/modules/camera/camera.c @@ -76,7 +76,7 @@ void ffGenerateCameraJsonConfig(FFCameraOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateCameraJsonResult(FF_A_UNUSED FFCameraOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateCameraJsonResult([[maybe_unused]] FFCameraOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(); const char* error = ffDetectCamera(&result); diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index d944baa44..1cd308909 100644 --- a/src/modules/chassis/chassis.c +++ b/src/modules/chassis/chassis.c @@ -66,7 +66,7 @@ void ffGenerateChassisJsonConfig(FFChassisOptions* options, yyjson_mut_doc* doc, ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateChassisJsonResult(FF_A_UNUSED FFChassisOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateChassisJsonResult([[maybe_unused]] FFChassisOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFChassisResult result; ffStrbufInit(&result.type); diff --git a/src/modules/command/command.c b/src/modules/command/command.c index fc4b3cfa0..751b97139 100644 --- a/src/modules/command/command.c +++ b/src/modules/command/command.c @@ -94,7 +94,7 @@ void ffGenerateCommandJsonConfig(FFCommandOptions* options, yyjson_mut_doc* doc, yyjson_mut_obj_add_bool(doc, module, "splitLines", options->splitLines); } -bool ffGenerateCommandJsonResult(FF_A_UNUSED FFCommandOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateCommandJsonResult([[maybe_unused]] FFCommandOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate(); const char* error = ffDetectCommand(options, &result); diff --git a/src/modules/cpucache/cpucache.c b/src/modules/cpucache/cpucache.c index 7263a5160..9753e4127 100644 --- a/src/modules/cpucache/cpucache.c +++ b/src/modules/cpucache/cpucache.c @@ -157,7 +157,7 @@ void ffGenerateCPUCacheJsonConfig(FFCPUCacheOptions* options, yyjson_mut_doc* do yyjson_mut_obj_add_bool(doc, module, "compact", options->compact); } -bool ffGenerateCPUCacheJsonResult(FF_A_UNUSED FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateCPUCacheJsonResult([[maybe_unused]] FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFCPUCacheResult result = { .caches = { diff --git a/src/modules/cursor/cursor.c b/src/modules/cursor/cursor.c index 0b6f6c735..748f78cc7 100644 --- a/src/modules/cursor/cursor.c +++ b/src/modules/cursor/cursor.c @@ -66,7 +66,7 @@ void ffGenerateCursorJsonConfig(FFCursorOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateCursorJsonResult(FF_A_UNUSED FFCursorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateCursorJsonResult([[maybe_unused]] FFCursorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFCursorResult result; ffStrbufInit(&result.error); diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index e902fff42..8e47e147c 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -138,7 +138,7 @@ void ffGenerateDateTimeJsonConfig(FFDateTimeOptions* options, yyjson_mut_doc* do ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateDateTimeJsonResult(FF_A_UNUSED FFDateTimeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateDateTimeJsonResult([[maybe_unused]] FFDateTimeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { yyjson_mut_obj_add_strcpy(doc, module, "result", ffTimeToFullStr(ffTimeGetNow())); return true; } diff --git a/src/modules/de/de.c b/src/modules/de/de.c index d66d20528..ad714d6f5 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -55,7 +55,7 @@ void ffGenerateDEJsonConfig(FFDEOptions* options, yyjson_mut_doc* doc, yyjson_mu ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateDEJsonResult(FF_A_UNUSED FFDEOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateDEJsonResult([[maybe_unused]] FFDEOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFDisplayServerResult* result = ffConnectDisplayServer(); if (result->dePrettyName.length == 0) { diff --git a/src/modules/display/display.c b/src/modules/display/display.c index a7da2e8ba..bdcec58ea 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -294,7 +294,7 @@ void ffGenerateDisplayJsonConfig(FFDisplayOptions* options, yyjson_mut_doc* doc, } } -bool ffGenerateDisplayJsonResult(FF_A_UNUSED FFDisplayOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateDisplayJsonResult([[maybe_unused]] FFDisplayOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFDisplayServerResult* dsResult = ffConnectDisplayServer(); if (dsResult->displays.length == 0) { diff --git a/src/modules/editor/editor.c b/src/modules/editor/editor.c index 23b19372a..352661ecb 100644 --- a/src/modules/editor/editor.c +++ b/src/modules/editor/editor.c @@ -65,7 +65,7 @@ void ffGenerateEditorJsonConfig(FFEditorOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateEditorJsonResult(FF_A_UNUSED FFEditorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateEditorJsonResult([[maybe_unused]] FFEditorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFEditorResult result = { .name = ffStrbufCreate(), .path = ffStrbufCreate(), diff --git a/src/modules/font/font.c b/src/modules/font/font.c index a32a7e80c..14cfa8fb1 100644 --- a/src/modules/font/font.c +++ b/src/modules/font/font.c @@ -57,7 +57,7 @@ void ffGenerateFontJsonConfig(FFFontOptions* options, yyjson_mut_doc* doc, yyjso ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateFontJsonResult(FF_A_UNUSED FFFontOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateFontJsonResult([[maybe_unused]] FFFontOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFFontResult font; for (uint32_t i = 0; i < FF_DETECT_FONT_NUM_FONTS; ++i) { diff --git a/src/modules/gamepad/gamepad.c b/src/modules/gamepad/gamepad.c index d34dcca85..5404cb8c2 100644 --- a/src/modules/gamepad/gamepad.c +++ b/src/modules/gamepad/gamepad.c @@ -138,7 +138,7 @@ void ffGenerateGamepadJsonConfig(FFGamepadOptions* options, yyjson_mut_doc* doc, ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateGamepadJsonResult(FF_A_UNUSED FFGamepadOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateGamepadJsonResult([[maybe_unused]] FFGamepadOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(); const char* error = ffDetectGamepad(&result); diff --git a/src/modules/host/host.c b/src/modules/host/host.c index 2a53cd398..680ba8849 100644 --- a/src/modules/host/host.c +++ b/src/modules/host/host.c @@ -83,7 +83,7 @@ void ffGenerateHostJsonConfig(FFHostOptions* options, yyjson_mut_doc* doc, yyjso ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateHostJsonResult(FF_A_UNUSED FFHostOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateHostJsonResult([[maybe_unused]] FFHostOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFHostResult host; ffStrbufInit(&host.family); diff --git a/src/modules/icons/icons.c b/src/modules/icons/icons.c index d3764ad07..d52ddc24b 100644 --- a/src/modules/icons/icons.c +++ b/src/modules/icons/icons.c @@ -60,7 +60,7 @@ void ffGenerateIconsJsonConfig(FFIconsOptions* options, yyjson_mut_doc* doc, yyj ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateIconsJsonResult(FF_A_UNUSED FFIconsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateIconsJsonResult([[maybe_unused]] FFIconsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFIconsResult result = { .icons1 = ffStrbufCreate(), diff --git a/src/modules/initsystem/initsystem.c b/src/modules/initsystem/initsystem.c index 3c3f3677e..faab272a3 100644 --- a/src/modules/initsystem/initsystem.c +++ b/src/modules/initsystem/initsystem.c @@ -64,7 +64,7 @@ void ffGenerateInitSystemJsonConfig(FFInitSystemOptions* options, yyjson_mut_doc ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateInitSystemJsonResult(FF_A_UNUSED FFInitSystemOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateInitSystemJsonResult([[maybe_unused]] FFInitSystemOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFInitSystemResult result = { .name = ffStrbufCreate(), diff --git a/src/modules/kernel/kernel.c b/src/modules/kernel/kernel.c index c405cbfa4..0c40d39f6 100644 --- a/src/modules/kernel/kernel.c +++ b/src/modules/kernel/kernel.c @@ -40,7 +40,7 @@ void ffGenerateKernelJsonConfig(FFKernelOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateKernelJsonResult(FF_A_UNUSED FFKernelOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateKernelJsonResult([[maybe_unused]] FFKernelOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFPlatformSysinfo* info = &instance.state.platform.sysinfo; yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result"); diff --git a/src/modules/keyboard/keyboard.c b/src/modules/keyboard/keyboard.c index 09c3cd5a3..5e3f5cbfe 100644 --- a/src/modules/keyboard/keyboard.c +++ b/src/modules/keyboard/keyboard.c @@ -99,7 +99,7 @@ void ffGenerateKeyboardJsonConfig(FFKeyboardOptions* options, yyjson_mut_doc* do } } -bool ffGenerateKeyboardJsonResult(FF_A_UNUSED FFKeyboardOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateKeyboardJsonResult([[maybe_unused]] FFKeyboardOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(); const char* error = ffDetectKeyboard(&result); diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index a1317d285..b8e7c1fc3 100644 --- a/src/modules/lm/lm.c +++ b/src/modules/lm/lm.c @@ -65,7 +65,7 @@ void ffGenerateLMJsonConfig(FFLMOptions* options, yyjson_mut_doc* doc, yyjson_mu ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateLMJsonResult(FF_A_UNUSED FFLMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLMJsonResult([[maybe_unused]] FFLMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFLMResult result; ffStrbufInit(&result.service); diff --git a/src/modules/loadavg/loadavg.c b/src/modules/loadavg/loadavg.c index 32ced1261..61939f515 100644 --- a/src/modules/loadavg/loadavg.c +++ b/src/modules/loadavg/loadavg.c @@ -118,7 +118,7 @@ void ffGenerateLoadavgJsonConfig(FFLoadavgOptions* options, yyjson_mut_doc* doc, ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateLoadavgJsonResult(FF_A_UNUSED FFLoadavgOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLoadavgJsonResult([[maybe_unused]] FFLoadavgOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { double result[3] = { 0.0 / 0.0, 0.0 / 0.0, 0.0 / 0.0 }; const char* error = ffDetectLoadavg(result); diff --git a/src/modules/locale/locale.c b/src/modules/locale/locale.c index ef97acf58..9c25341aa 100644 --- a/src/modules/locale/locale.c +++ b/src/modules/locale/locale.c @@ -38,7 +38,7 @@ void ffGenerateLocaleJsonConfig(FFLocaleOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateLocaleJsonResult(FF_A_UNUSED FFLocaleOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLocaleJsonResult([[maybe_unused]] FFLocaleOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_STRBUF_AUTO_DESTROY locale = ffStrbufCreate(); const char* error = ffDetectLocale(&locale); diff --git a/src/modules/localip/localip.c b/src/modules/localip/localip.c index 59068614b..952d72ef6 100644 --- a/src/modules/localip/localip.c +++ b/src/modules/localip/localip.c @@ -350,7 +350,7 @@ void ffGenerateLocalIpJsonConfig(FFLocalIpOptions* options, yyjson_mut_doc* doc, yyjson_mut_obj_add_strbuf(doc, module, "namePrefix", &options->namePrefix); } -bool ffGenerateLocalIpJsonResult(FF_A_UNUSED FFLocalIpOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLocalIpJsonResult([[maybe_unused]] FFLocalIpOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(); const char* error = ffDetectLocalIps(options, &results); diff --git a/src/modules/logo/logo.c b/src/modules/logo/logo.c index a4952a726..a2fd7d2d1 100644 --- a/src/modules/logo/logo.c +++ b/src/modules/logo/logo.c @@ -3,12 +3,12 @@ #include "modules/logo/logo.h" #include "options/logo.h" -bool ffPrintLogo(FF_A_UNUSED FFLogoOptions* options) { +bool ffPrintLogo([[maybe_unused]] FFLogoOptions* options) { ffPrintError(FF_LOGO_MODULE_NAME, 0, nullptr, FF_PRINT_TYPE_DEFAULT, "Supported in JSON format only"); return false; } -void ffParseLogoJsonObject(FF_A_UNUSED FFLogoOptions* options, FF_A_UNUSED yyjson_val* module) { +void ffParseLogoJsonObject([[maybe_unused]] FFLogoOptions* options, [[maybe_unused]] yyjson_val* module) { yyjson_val *key, *val; size_t idx, max; yyjson_obj_foreach (module, idx, max, key, val) { @@ -20,7 +20,7 @@ void ffParseLogoJsonObject(FF_A_UNUSED FFLogoOptions* options, FF_A_UNUSED yyjso } } -bool ffGenerateLogoJsonResult(FF_A_UNUSED FFLogoOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLogoJsonResult([[maybe_unused]] FFLogoOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFLogoSize size = FF_LOGO_SIZE_UNKNOWN; FFOptionsLogo* logoOptions = &instance.config.logo; if (logoOptions->type == FF_LOGO_TYPE_SMALL) { @@ -70,10 +70,10 @@ bool ffGenerateLogoJsonResult(FF_A_UNUSED FFLogoOptions* options, yyjson_mut_doc return true; } -void ffInitLogoOptions(FF_A_UNUSED FFLogoOptions* options) { +void ffInitLogoOptions([[maybe_unused]] FFLogoOptions* options) { } -void ffDestroyLogoOptions(FF_A_UNUSED FFLogoOptions* options) { +void ffDestroyLogoOptions([[maybe_unused]] FFLogoOptions* options) { } FFModuleBaseInfo ffLogoModuleInfo = { diff --git a/src/modules/media/media.c b/src/modules/media/media.c index 0876a9ddd..884d8e452 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -211,7 +211,7 @@ void ffGenerateMediaJsonConfig(FFMediaOptions* options, yyjson_mut_doc* doc, yyj ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateMediaJsonResult(FF_A_UNUSED FFMediaOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateMediaJsonResult([[maybe_unused]] FFMediaOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFMediaResult* media = ffDetectMedia(false); if (media->error.length > 0) { diff --git a/src/modules/memory/memory.c b/src/modules/memory/memory.c index 4fbdf75fb..efdf65643 100644 --- a/src/modules/memory/memory.c +++ b/src/modules/memory/memory.c @@ -92,7 +92,7 @@ void ffGenerateMemoryJsonConfig(FFMemoryOptions* options, yyjson_mut_doc* doc, y ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateMemoryJsonResult(FF_A_UNUSED FFMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateMemoryJsonResult([[maybe_unused]] FFMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFMemoryResult storage = {}; const char* error = ffDetectMemory(&storage); diff --git a/src/modules/monitor/monitor.c b/src/modules/monitor/monitor.c index 636cd447b..41beeaba2 100644 --- a/src/modules/monitor/monitor.c +++ b/src/modules/monitor/monitor.c @@ -90,7 +90,7 @@ void ffGenerateMonitorJsonConfig(FFMonitorOptions* options, yyjson_mut_doc* doc, ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateMonitorJsonResult(FF_A_UNUSED FFMonitorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateMonitorJsonResult([[maybe_unused]] FFMonitorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { yyjson_mut_obj_add_str(doc, module, "error", "Monitor module is an alias of Display module"); return false; } diff --git a/src/modules/mouse/mouse.c b/src/modules/mouse/mouse.c index abc467832..37e78be9a 100644 --- a/src/modules/mouse/mouse.c +++ b/src/modules/mouse/mouse.c @@ -102,7 +102,7 @@ void ffGenerateMouseJsonConfig(FFMouseOptions* options, yyjson_mut_doc* doc, yyj } } -bool ffGenerateMouseJsonResult(FF_A_UNUSED FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateMouseJsonResult([[maybe_unused]] FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(); const char* error = ffDetectMouse(&result); diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index f27ff8200..acfe861cb 100644 --- a/src/modules/opencl/opencl.c +++ b/src/modules/opencl/opencl.c @@ -43,7 +43,7 @@ void ffGenerateOpenCLJsonConfig(FFOpenCLOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateOpenCLJsonResult(FF_A_UNUSED FFOpenCLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateOpenCLJsonResult([[maybe_unused]] FFOpenCLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFOpenCLResult* result = ffDetectOpenCL(); if (result->error != nullptr) { diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index d325089bd..1ecce858a 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -85,7 +85,7 @@ void ffGenerateOpenGLJsonConfig(FFOpenGLOptions* options, yyjson_mut_doc* doc, y } } -bool ffGenerateOpenGLJsonResult(FF_A_UNUSED FFOpenGLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateOpenGLJsonResult([[maybe_unused]] FFOpenGLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFOpenGLResult result; ffStrbufInit(&result.version); diff --git a/src/modules/os/os.c b/src/modules/os/os.c index e402699b0..ea08a567c 100644 --- a/src/modules/os/os.c +++ b/src/modules/os/os.c @@ -120,7 +120,7 @@ void ffGenerateOSJsonConfig(FFOSOptions* options, yyjson_mut_doc* doc, yyjson_mu ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateOSJsonResult(FF_A_UNUSED FFOSOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateOSJsonResult([[maybe_unused]] FFOSOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFOSResult* os = ffDetectOS(); if (os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0) { diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 58d1b3b00..7d2248093 100644 --- a/src/modules/player/player.c +++ b/src/modules/player/player.c @@ -95,7 +95,7 @@ void ffGeneratePlayerJsonConfig(FFPlayerOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGeneratePlayerJsonResult(FF_A_UNUSED FFMediaOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGeneratePlayerJsonResult([[maybe_unused]] FFMediaOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { yyjson_mut_obj_add_str(doc, module, "error", "Player module is an alias of Media module"); return false; } diff --git a/src/modules/poweradapter/poweradapter.c b/src/modules/poweradapter/poweradapter.c index 2e70c000d..12086c9b2 100644 --- a/src/modules/poweradapter/poweradapter.c +++ b/src/modules/poweradapter/poweradapter.c @@ -69,7 +69,7 @@ void ffParsePowerAdapterJsonObject(FFPowerAdapterOptions* options, yyjson_val* m } } -bool ffGeneratePowerAdapterJsonResult(FF_A_UNUSED FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGeneratePowerAdapterJsonResult([[maybe_unused]] FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(); const char* error = ffDetectPowerAdapter(&results); diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index 44ab59d4d..d5542bac4 100644 --- a/src/modules/processes/processes.c +++ b/src/modules/processes/processes.c @@ -40,7 +40,7 @@ void ffGenerateProcessesJsonConfig(FFProcessesOptions* options, yyjson_mut_doc* ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateProcessesJsonResult(FF_A_UNUSED FFProcessesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateProcessesJsonResult([[maybe_unused]] FFProcessesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { uint32_t result; const char* error = ffDetectProcesses(&result); diff --git a/src/modules/shell/shell.c b/src/modules/shell/shell.c index f18c1bfd8..d840135dd 100644 --- a/src/modules/shell/shell.c +++ b/src/modules/shell/shell.c @@ -54,7 +54,7 @@ void ffGenerateShellJsonConfig(FFShellOptions* options, yyjson_mut_doc* doc, yyj ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateShellJsonResult(FF_A_UNUSED FFShellOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateShellJsonResult([[maybe_unused]] FFShellOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFShellResult* result = ffDetectShell(); if (result->processName.length == 0) { diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index 78af47558..78568e717 100644 --- a/src/modules/swap/swap.c +++ b/src/modules/swap/swap.c @@ -147,7 +147,7 @@ void ffGenerateSwapJsonConfig(FFSwapOptions* options, yyjson_mut_doc* doc, yyjso yyjson_mut_obj_add_bool(doc, module, "separate", options->separate); } -bool ffGenerateSwapJsonResult(FF_A_UNUSED FFSwapOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateSwapJsonResult([[maybe_unused]] FFSwapOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(); const char* error = ffDetectSwap(&result); diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 8dc6f4c4b..979f3303b 100644 --- a/src/modules/terminal/terminal.c +++ b/src/modules/terminal/terminal.c @@ -52,7 +52,7 @@ void ffGenerateTerminalJsonConfig(FFTerminalOptions* options, yyjson_mut_doc* do ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateTerminalJsonResult(FF_A_UNUSED FFTerminalOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTerminalJsonResult([[maybe_unused]] FFTerminalOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFTerminalResult* result = ffDetectTerminal(); if (result->processName.length == 0) { diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index 91e45c747..6285b2877 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -58,7 +58,7 @@ void ffGenerateTerminalFontJsonConfig(FFTerminalFontOptions* options, yyjson_mut ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateTerminalFontJsonResult(FF_A_UNUSED FFTerminalFontOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTerminalFontJsonResult([[maybe_unused]] FFTerminalFontOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFTerminalFontResult result; ffFontInit(&result.font); diff --git a/src/modules/terminalsize/terminalsize.c b/src/modules/terminalsize/terminalsize.c index 4a7c555ad..81a9761b3 100644 --- a/src/modules/terminalsize/terminalsize.c +++ b/src/modules/terminalsize/terminalsize.c @@ -50,7 +50,7 @@ void ffGenerateTerminalSizeJsonConfig(FFTerminalSizeOptions* options, yyjson_mut ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateTerminalSizeJsonResult(FF_A_UNUSED FFTerminalSizeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTerminalSizeJsonResult([[maybe_unused]] FFTerminalSizeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFTerminalSizeResult result; if (!ffDetectTerminalSize(&result)) { diff --git a/src/modules/terminaltheme/terminaltheme.c b/src/modules/terminaltheme/terminaltheme.c index 80bcd2950..6e7967b35 100644 --- a/src/modules/terminaltheme/terminaltheme.c +++ b/src/modules/terminaltheme/terminaltheme.c @@ -59,7 +59,7 @@ void ffGenerateTerminalThemeJsonConfig(FFTerminalThemeOptions* options, yyjson_m ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateTerminalThemeJsonResult(FF_A_UNUSED FFTerminalThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTerminalThemeJsonResult([[maybe_unused]] FFTerminalThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFTerminalThemeResult result = {}; if (!ffDetectTerminalTheme(&result, false)) { diff --git a/src/modules/theme/theme.c b/src/modules/theme/theme.c index 70cb778ab..4c88b68f7 100644 --- a/src/modules/theme/theme.c +++ b/src/modules/theme/theme.c @@ -56,7 +56,7 @@ void ffGenerateThemeJsonConfig(FFThemeOptions* options, yyjson_mut_doc* doc, yyj ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateThemeJsonResult(FF_A_UNUSED FFThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateThemeJsonResult([[maybe_unused]] FFThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFThemeResult result = { .theme1 = ffStrbufCreate(), .theme2 = ffStrbufCreate() diff --git a/src/modules/title/title.c b/src/modules/title/title.c index 43893de38..ca7343a92 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -139,7 +139,7 @@ void ffGenerateTitleJsonConfig(FFTitleOptions* options, yyjson_mut_doc* doc, yyj yyjson_mut_obj_add_strbuf(doc, color, "host", &options->colorHost); } -bool ffGenerateTitleJsonResult(FF_A_UNUSED FFTitleOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTitleJsonResult([[maybe_unused]] FFTitleOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result"); #ifdef _WIN32 yyjson_mut_obj_add_strbuf(doc, obj, "userId", &instance.state.platform.sid); diff --git a/src/modules/tpm/tpm.c b/src/modules/tpm/tpm.c index ecdd38609..b6dd62dd8 100644 --- a/src/modules/tpm/tpm.c +++ b/src/modules/tpm/tpm.c @@ -52,7 +52,7 @@ void ffGenerateTPMJsonConfig(FFTPMOptions* options, yyjson_mut_doc* doc, yyjson_ ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateTPMJsonResult(FF_A_UNUSED FFTPMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTPMJsonResult([[maybe_unused]] FFTPMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFTPMResult result = { .version = ffStrbufCreate(), .description = ffStrbufCreate() diff --git a/src/modules/uptime/uptime.c b/src/modules/uptime/uptime.c index e096bfc2f..dd0d90d2b 100644 --- a/src/modules/uptime/uptime.c +++ b/src/modules/uptime/uptime.c @@ -58,7 +58,7 @@ void ffGenerateUptimeJsonConfig(FFUptimeOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateUptimeJsonResult(FF_A_UNUSED FFUptimeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateUptimeJsonResult([[maybe_unused]] FFUptimeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFUptimeResult result; const char* error = ffDetectUptime(&result); diff --git a/src/modules/version/version.c b/src/modules/version/version.c index dcc4bbef1..211eece8d 100644 --- a/src/modules/version/version.c +++ b/src/modules/version/version.c @@ -56,7 +56,7 @@ void ffGenerateVersionJsonConfig(FFVersionOptions* options, yyjson_mut_doc* doc, ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateVersionJsonResult(FF_A_UNUSED FFVersionOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateVersionJsonResult([[maybe_unused]] FFVersionOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFVersionResult* result = &ffVersionResult; yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result"); diff --git a/src/modules/vulkan/vulkan.c b/src/modules/vulkan/vulkan.c index 9ecbd32cf..abfd3612d 100644 --- a/src/modules/vulkan/vulkan.c +++ b/src/modules/vulkan/vulkan.c @@ -62,7 +62,7 @@ void ffGenerateVulkanJsonConfig(FFVulkanOptions* options, yyjson_mut_doc* doc, y ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateVulkanJsonResult(FF_A_UNUSED FFVulkanOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateVulkanJsonResult([[maybe_unused]] FFVulkanOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFVulkanResult* result = ffDetectVulkan(); if (result->error) { diff --git a/src/modules/wallpaper/wallpaper.c b/src/modules/wallpaper/wallpaper.c index a4d17c01a..6d1102953 100644 --- a/src/modules/wallpaper/wallpaper.c +++ b/src/modules/wallpaper/wallpaper.c @@ -54,7 +54,7 @@ void ffGenerateWallpaperJsonConfig(FFWallpaperOptions* options, yyjson_mut_doc* ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateWallpaperJsonResult(FF_A_UNUSED FFWallpaperOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateWallpaperJsonResult([[maybe_unused]] FFWallpaperOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_STRBUF_AUTO_DESTROY fullpath = ffStrbufCreate(); const char* error = ffDetectWallpaper(&fullpath); if (error) { diff --git a/src/modules/wifi/wifi.c b/src/modules/wifi/wifi.c index 42485dce6..0a23cc2d7 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -148,7 +148,7 @@ void ffGenerateWifiJsonConfig(FFWifiOptions* options, yyjson_mut_doc* doc, yyjso ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateWifiJsonResult(FF_A_UNUSED FFWifiOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateWifiJsonResult([[maybe_unused]] FFWifiOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(); const char* error = ffDetectWifi(&result); if (error) { diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 5ec66463b..da492d3de 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -82,7 +82,7 @@ void ffGenerateWMJsonConfig(FFWMOptions* options, yyjson_mut_doc* doc, yyjson_mu yyjson_mut_obj_add_bool(doc, module, "detectPlugin", options->detectPlugin); } -bool ffGenerateWMJsonResult(FF_A_UNUSED FFWMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateWMJsonResult([[maybe_unused]] FFWMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { const FFDisplayServerResult* result = ffConnectDisplayServer(); if (result->wmPrettyName.length == 0) { diff --git a/src/modules/wmtheme/wmtheme.c b/src/modules/wmtheme/wmtheme.c index 775e88a9d..a45c9baa3 100644 --- a/src/modules/wmtheme/wmtheme.c +++ b/src/modules/wmtheme/wmtheme.c @@ -41,7 +41,7 @@ void ffGenerateWMThemeJsonConfig(FFWMThemeOptions* options, yyjson_mut_doc* doc, ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateWMThemeJsonResult(FF_A_UNUSED FFWMThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateWMThemeJsonResult([[maybe_unused]] FFWMThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_STRBUF_AUTO_DESTROY themeOrError = ffStrbufCreate(); if (!ffDetectWmTheme(&themeOrError)) { yyjson_mut_obj_add_strbuf(doc, module, "error", &themeOrError); diff --git a/src/modules/zpool/zpool.c b/src/modules/zpool/zpool.c index 44a6de2a1..cddd1c705 100644 --- a/src/modules/zpool/zpool.c +++ b/src/modules/zpool/zpool.c @@ -148,7 +148,7 @@ void ffGenerateZpoolJsonConfig(FFZpoolOptions* options, yyjson_mut_doc* doc, yyj ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateZpoolJsonResult(FF_A_UNUSED FFZpoolOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateZpoolJsonResult([[maybe_unused]] FFZpoolOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(); const char* error = ffDetectZpool(&results); diff --git a/tests/strbuf.c b/tests/strbuf.c index 2374de615..6007ff908 100644 --- a/tests/strbuf.c +++ b/tests/strbuf.c @@ -769,7 +769,7 @@ int main(void) { ffStrbufAppendUtf32CodePoint(&strbuf, 0x6587); ffStrbufAppendUtf32CodePoint(&strbuf, 0x6cc9); ffStrbufAppendUtf32CodePoint(&strbuf, 0x9a7f); - VERIFY(ffStrbufEqualS(&strbuf, u8"文泉驿")); + VERIFY(ffStrbufEqualS(&strbuf, (const char*) u8"文泉驿")); ffStrbufDestroy(&strbuf); }