diff --git a/src/common/FFcheckmacros.h b/src/common/FFcheckmacros.h deleted file mode 100644 index c4b9c3ebf..000000000 --- a/src/common/FFcheckmacros.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#ifdef _MSC_VER -# include -#endif - -#if defined(__has_attribute) && __has_attribute(__warn_unused_result__) -# define FF_C_NODISCARD __attribute__((__warn_unused_result__)) -#elif defined(_MSC_VER) -# define FF_C_NODISCARD _Check_return_ -#else -# define FF_C_NODISCARD -#endif - -#if defined(__has_attribute) && __has_attribute(__format__) -# define FF_C_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__(printf, formatStrIndex, argsStartIndex))) -#else -# define FF_C_PRINTF(formatStrIndex, argsStartIndex) -#endif - -#if defined(__has_attribute) && __has_attribute(__format__) -# define FF_C_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__(scanf, formatStrIndex, argsStartIndex))) -#else -# define FF_C_SCANF(formatStrIndex, argsStartIndex) -#endif - -#if defined(__has_attribute) && __has_attribute(__nonnull__) -# define FF_C_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__))) -#else -# define FF_C_NONNULL(argIndex, ...) -#endif - -#if defined(__has_attribute) && __has_attribute(__returns_nonnull__) -# define FF_C_RETURNS_NONNULL __attribute__((__returns_nonnull__)) -#else -# define FF_C_RETURNS_NONNULL -#endif diff --git a/src/common/FFlist.h b/src/common/FFlist.h index 9003609f2..5cafb48cc 100644 --- a/src/common/FFlist.h +++ b/src/common/FFlist.h @@ -1,6 +1,6 @@ #pragma once -#include "FFcheckmacros.h" +#include "common/attributes.h" #include #include @@ -48,7 +48,7 @@ static inline void* ffListGet(const FFlist* list, uint32_t index) { return list->data + (index * list->elementSize); } -FF_C_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) { +FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) { for (uint32_t i = 0; i < list->length; i++) { if (compFunc(ffListGet(list, i), compElement)) { return i; @@ -109,7 +109,7 @@ static inline void ffListReserve(FFlist* list, uint32_t newCapacity) { itemVarName - (itemType*) (listVar).data < (intptr_t) (listVar).length; \ ++itemVarName) -#define FF_LIST_AUTO_DESTROY FFlist __attribute__((__cleanup__(ffListDestroy))) +#define FF_LIST_AUTO_DESTROY FFlist FF_A_CLEANUP(ffListDestroy) #define FF_LIST_GET(itemType, listVar, index) \ ({ \ diff --git a/src/common/FFstrbuf.h b/src/common/FFstrbuf.h index da9aba0d2..e191a23ed 100644 --- a/src/common/FFstrbuf.h +++ b/src/common/FFstrbuf.h @@ -1,6 +1,6 @@ #pragma once -#include "FFcheckmacros.h" +#include "common/attributes.h" #include #include @@ -47,7 +47,7 @@ void ffStrbufAppendC(FFstrbuf* strbuf, char c); void ffStrbufAppendNC(FFstrbuf* strbuf, uint32_t num, char c); void ffStrbufAppendNS(FFstrbuf* strbuf, uint32_t length, const char* value); void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int (*transformFunc)(int)); -FF_C_PRINTF(2, 3) +FF_A_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); @@ -61,7 +61,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_C_PRINTF(2, 3) +FF_A_PRINTF(2, 3) void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...); void ffStrbufTrimLeft(FFstrbuf* strbuf, char c); @@ -73,10 +73,10 @@ bool ffStrbufRemoveSubstr(FFstrbuf* strbuf, uint32_t startIndex, uint32_t endInd void ffStrbufRemoveS(FFstrbuf* strbuf, const char* str); void ffStrbufRemoveStrings(FFstrbuf* strbuf, uint32_t numStrings, const char* strings[]); -FF_C_NODISCARD uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c); -FF_C_NODISCARD uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str); +FF_A_NODISCARD uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c); +FF_A_NODISCARD uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str); -FF_C_NODISCARD uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c); +FF_A_NODISCARD uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c); void ffStrbufReplaceAllC(FFstrbuf* strbuf, char find, char replace); @@ -88,7 +88,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_C_NODISCARD uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c); +FF_A_NODISCARD uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c); bool ffStrbufRemoveIgnCaseEndS(FFstrbuf* strbuf, const char* end); @@ -97,9 +97,9 @@ bool ffStrbufEnsureEndsWithC(FFstrbuf* strbuf, char c); void ffStrbufWriteTo(const FFstrbuf* strbuf, FILE* file); void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file); -FF_C_NODISCARD double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue); -FF_C_NODISCARD int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue); -FF_C_NODISCARD uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue); +FF_A_NODISCARD double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue); +FF_A_NODISCARD int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue); +FF_A_NODISCARD uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue); void ffStrbufUpperCase(FFstrbuf* strbuf); void ffStrbufLowerCase(FFstrbuf* strbuf); @@ -151,7 +151,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_C_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) { +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) { FFstrbuf strbuf; ffStrbufInitA(&strbuf, allocate); return strbuf; @@ -166,7 +166,7 @@ static inline void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf* } } -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) { +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) { FFstrbuf strbuf; ffStrbufInitCopy(&strbuf, src); return strbuf; @@ -182,19 +182,19 @@ static inline void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) { } } -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) { +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) { FFstrbuf strbuf; ffStrbufInitMove(&strbuf, src); return strbuf; } -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateVF(const char* format, va_list arguments) { +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateVF(const char* format, va_list arguments) { FFstrbuf strbuf; ffStrbufInitVF(&strbuf, format, arguments); return strbuf; } -FF_C_PRINTF(2, 3) +FF_A_PRINTF(2, 3) static inline void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...) { va_list arguments; va_start(arguments, format); @@ -202,8 +202,8 @@ static inline void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...) { va_end(arguments); } -FF_C_PRINTF(1, 2) -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateF(const char* format, ...) { +FF_A_PRINTF(1, 2) +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateF(const char* format, ...) { FFstrbuf strbuf; va_list arguments; @@ -227,7 +227,7 @@ static inline void ffStrbufDestroy(FFstrbuf* strbuf) { ffStrbufInit(strbuf); } -FF_C_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) { +FF_A_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) { assert(strbuf != NULL); if (strbuf->allocated == 0) { return 0; @@ -283,7 +283,7 @@ static inline void ffStrbufInit(FFstrbuf* strbuf) { strbuf->chars = CHAR_NULL_PTR; } -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreate(void) { +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreate(void) { FFstrbuf strbuf; ffStrbufInit(&strbuf); return strbuf; @@ -300,7 +300,7 @@ static inline void ffStrbufInitStatic(FFstrbuf* strbuf, const char* str) { strbuf->chars = (char*) str; } -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateStatic(const char* str) { +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateStatic(const char* str) { FFstrbuf strbuf; ffStrbufInitStatic(&strbuf, str); return strbuf; @@ -323,7 +323,7 @@ static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char* ffStrbufAppendNS(strbuf, length, str); } -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) { +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) { FFstrbuf strbuf; ffStrbufInitNS(&strbuf, length, str); return strbuf; @@ -339,7 +339,7 @@ static inline void ffStrbufInitS(FFstrbuf* strbuf, const char* str) { ffStrbufAppendS(strbuf, str); } -FF_C_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) { +FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) { FFstrbuf strbuf; ffStrbufInitS(&strbuf, str); return strbuf; @@ -367,72 +367,72 @@ static inline void ffStrbufPrependS(FFstrbuf* strbuf, const char* value) { ffStrbufPrependNS(strbuf, (uint32_t) strlen(value), value); } -static inline FF_C_NODISCARD int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) { +static inline FF_A_NODISCARD 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_C_NODISCARD bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) { +static inline FF_A_NODISCARD bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) { return ffStrbufComp(strbuf, comp) == 0; } -static inline FF_C_NODISCARD int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) { +static inline FF_A_NODISCARD int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) { return strcmp(strbuf->chars, comp); } -static inline FF_C_NODISCARD bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) { +static inline FF_A_NODISCARD bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) { return ffStrbufCompS(strbuf, comp) == 0; } -static inline FF_C_NODISCARD int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) { +static inline FF_A_NODISCARD int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) { return strcasecmp(strbuf->chars, comp); } -static inline FF_C_NODISCARD bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) { +static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) { return ffStrbufIgnCaseCompS(strbuf, comp) == 0; } -static inline FF_C_NODISCARD int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) { +static inline FF_A_NODISCARD int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) { return ffStrbufIgnCaseCompS(strbuf, comp->chars); } -static inline FF_C_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) { +static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) { return ffStrbufIgnCaseComp(strbuf, comp) == 0; } -static inline FF_C_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c) { +static inline FF_A_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c) { return memchr(strbuf->chars, c, strbuf->length) != NULL; } -static inline FF_C_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) { +static inline FF_A_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) { return strstr(strbuf->chars, str) != NULL; } -static inline FF_C_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) { +static inline FF_A_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) { return ffStrbufContainS(strbuf, str->chars); } -static inline FF_C_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) { +static inline FF_A_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) { return strcasestr(strbuf->chars, str) != NULL; } -static inline FF_C_NODISCARD bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) { +static inline FF_A_NODISCARD bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) { return ffStrbufContainIgnCaseS(strbuf, str->chars); } -static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) { +static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) { return ffStrbufNextIndexC(strbuf, 0, c); } -static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) { +static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) { return ffStrbufNextIndexS(strbuf, 0, searched->chars); } -static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) { +static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) { return ffStrbufNextIndexS(strbuf, 0, str); } -static inline FF_C_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) { +static inline FF_A_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) { if (strbuf->length == 0) { return 0; } @@ -448,11 +448,11 @@ static inline bool ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c) { return ffStrbufSubstrBefore(strbuf, ffStrbufLastIndexC(strbuf, c)); } -static inline FF_C_NODISCARD bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) { +static inline FF_A_NODISCARD bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) { return strbuf->chars[0] == c; } -static inline FF_C_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) { +static inline FF_A_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) { if (length > strbuf->length) { return false; } @@ -460,34 +460,34 @@ static inline FF_C_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, c return memcmp(strbuf->chars, start, length) == 0; } -static inline FF_C_NODISCARD bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) { +static inline FF_A_NODISCARD bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) { return ffStrbufStartsWithSN(strbuf, start, (uint32_t) strlen(start)); } -static inline FF_C_NODISCARD bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) { +static inline FF_A_NODISCARD bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) { return ffStrbufStartsWithSN(strbuf, start->chars, start->length); } -static inline FF_C_NODISCARD bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) { +static inline FF_A_NODISCARD 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_C_NODISCARD bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) { +static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) { return ffStrbufStartsWithIgnCaseNS(strbuf, (uint32_t) strlen(start), start); } -static inline FF_C_NODISCARD bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) { +static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) { return ffStrbufStartsWithIgnCaseNS(strbuf, start->length, start->chars); } -static inline FF_C_NODISCARD bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) { +static inline FF_A_NODISCARD bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) { return strbuf->length == 0 ? false : strbuf->chars[strbuf->length - 1] == c; } -static inline FF_C_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) { +static inline FF_A_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) { if (endLength > strbuf->length) { return false; } @@ -495,30 +495,30 @@ static inline FF_C_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uin return memcmp(strbuf->chars + strbuf->length - endLength, end, endLength) == 0; } -static inline FF_C_NODISCARD bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) { +static inline FF_A_NODISCARD bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) { return ffStrbufEndsWithNS(strbuf, (uint32_t) strlen(end), end); } -static inline FF_C_NODISCARD bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) { +static inline FF_A_NODISCARD bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) { return strbuf->length == 0 ? false : fn(strbuf->chars[strbuf->length - 1]); } -static inline FF_C_NODISCARD bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) { +static inline FF_A_NODISCARD bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) { return ffStrbufEndsWithNS(strbuf, end->length, end->chars); } -static inline FF_C_NODISCARD bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) { +static inline FF_A_NODISCARD 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_C_NODISCARD bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) { +static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) { return ffStrbufEndsWithIgnCaseNS(strbuf, (uint32_t) strlen(end), end); } -static inline FF_C_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) { +static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) { return ffStrbufEndsWithIgnCaseNS(strbuf, end->length, end->chars); } @@ -567,4 +567,4 @@ static inline bool ffStrbufSeparatedContainIgnCase(const FFstrbuf* strbuf, const // Returns true if the strbuf is modified bool ffStrbufDecodeHexEscapeSequences(FFstrbuf* strbuf); -#define FF_STRBUF_AUTO_DESTROY FFstrbuf __attribute__((__cleanup__(ffStrbufDestroy))) +#define FF_STRBUF_AUTO_DESTROY FFstrbuf FF_A_CLEANUP(ffStrbufDestroy) diff --git a/src/common/apple/cf_helpers.h b/src/common/apple/cf_helpers.h index 181faa309..8ce58ccc3 100644 --- a/src/common/apple/cf_helpers.h +++ b/src/common/apple/cf_helpers.h @@ -28,7 +28,7 @@ static inline void cfReleaseWrapper(void* type) { } } -#define FF_CFTYPE_AUTO_RELEASE __attribute__((__cleanup__(cfReleaseWrapper))) +#define FF_CFTYPE_AUTO_RELEASE FF_A_CLEANUP(cfReleaseWrapper) static inline void wrapIoObjectRelease(io_object_t* service) { assert(service); @@ -36,4 +36,4 @@ static inline void wrapIoObjectRelease(io_object_t* service) { IOObjectRelease(*service); } } -#define FF_IOOBJECT_AUTO_RELEASE __attribute__((__cleanup__(wrapIoObjectRelease))) +#define FF_IOOBJECT_AUTO_RELEASE FF_A_CLEANUP(wrapIoObjectRelease) diff --git a/src/common/argType.h b/src/common/argType.h index 49871e7af..81217c7f9 100644 --- a/src/common/argType.h +++ b/src/common/argType.h @@ -10,7 +10,7 @@ typedef struct FFArgBuffer { uint32_t length; } FFArgBuffer; -typedef enum __attribute__((__packed__)) FFArgType { +typedef enum FF_A_PACKED FFArgType { FF_ARG_TYPE_NULL = 0, FF_ARG_TYPE_UINT, FF_ARG_TYPE_UINT64, diff --git a/src/common/attributes.h b/src/common/attributes.h new file mode 100644 index 000000000..9d8664126 --- /dev/null +++ b/src/common/attributes.h @@ -0,0 +1,17 @@ +#pragma once + +#ifdef _MSC_VER +# 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__)) diff --git a/src/common/dbus.h b/src/common/dbus.h index 1bfd3a239..b364e1b91 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, NULL); } -# define FF_DBUS_AUTO_DESTROY_DATA __attribute__((__cleanup__(ffDBusDestroyData))) +# define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData) #endif // FF_HAVE_DBUS diff --git a/src/common/ffdata.h b/src/common/ffdata.h index 65edfbb17..189c0fab2 100644 --- a/src/common/ffdata.h +++ b/src/common/ffdata.h @@ -2,7 +2,7 @@ #include "common/FFstrbuf.h" -typedef enum __attribute__((__packed__)) FFDataResultDocType { +typedef enum FF_A_PACKED FFDataResultDocType { FF_RESULT_DOC_TYPE_DEFAULT = 0, FF_RESULT_DOC_TYPE_JSON, FF_RESULT_DOC_TYPE_CONFIG, diff --git a/src/common/impl/commandoption.c b/src/common/impl/commandoption.c index 9c920bb12..19e5b9333 100644 --- a/src/common/impl/commandoption.c +++ b/src/common/impl/commandoption.c @@ -79,7 +79,7 @@ void ffPrepareCommandOption(FFdata* data) { case 'D': case 'd': FF_IF_MODULE_MATCH(FF_DISKIO_MODULE_NAME) { - __attribute__((__cleanup__(ffDestroyDiskIOOptions))) FFDiskIOOptions options; + FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options; ffInitDiskIOOptions(&options); ffPrepareDiskIO(&options); } @@ -88,7 +88,7 @@ void ffPrepareCommandOption(FFdata* data) { case 'N': case 'n': FF_IF_MODULE_MATCH(FF_NETIO_MODULE_NAME) { - __attribute__((__cleanup__(ffDestroyNetIOOptions))) FFNetIOOptions options; + FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options; ffInitNetIOOptions(&options); ffPrepareNetIO(&options); } @@ -97,7 +97,7 @@ void ffPrepareCommandOption(FFdata* data) { case 'P': case 'p': FF_IF_MODULE_MATCH(FF_PUBLICIP_MODULE_NAME) { - __attribute__((__cleanup__(ffDestroyPublicIpOptions))) FFPublicIPOptions options; + FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options; ffInitPublicIpOptions(&options); ffPreparePublicIp(&options); } @@ -106,7 +106,7 @@ void ffPrepareCommandOption(FFdata* data) { case 'W': case 'w': FF_IF_MODULE_MATCH(FF_WEATHER_MODULE_NAME) { - __attribute__((__cleanup__(ffDestroyWeatherOptions))) FFWeatherOptions options; + FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options; ffInitWeatherOptions(&options); ffPrepareWeather(&options); } diff --git a/src/common/impl/init.c b/src/common/impl/init.c index 4d631b05c..77d1f5d80 100644 --- a/src/common/impl/init.c +++ b/src/common/impl/init.c @@ -86,12 +86,12 @@ static void resetConsole(void) { } #ifdef _WIN32 -BOOL WINAPI consoleHandler(FF_MAYBE_UNUSED DWORD signal) { +BOOL WINAPI consoleHandler(FF_A_UNUSED DWORD signal) { resetConsole(); exit(0); } #else -static void exitSignalHandler(FF_MAYBE_UNUSED int signal) { +static void exitSignalHandler(FF_A_UNUSED int signal) { resetConsole(); exit(0); } diff --git a/src/common/impl/jsonconfig.c b/src/common/impl/jsonconfig.c index 5071b8801..0e71cde51 100644 --- a/src/common/impl/jsonconfig.c +++ b/src/common/impl/jsonconfig.c @@ -143,7 +143,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'c': case 'C': { if (ffStrEqualsIgnCase(type, FF_COMMAND_MODULE_NAME)) { - __attribute__((__cleanup__(ffDestroyCommandOptions))) FFCommandOptions options; + FF_A_CLEANUP(ffDestroyCommandOptions) FFCommandOptions options; ffInitCommandOptions(&options); if (module) { ffCommandModuleInfo.parseJsonObject(&options, module); @@ -155,7 +155,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'd': case 'D': { if (ffStrEqualsIgnCase(type, FF_DISKIO_MODULE_NAME)) { - __attribute__((__cleanup__(ffDestroyDiskIOOptions))) FFDiskIOOptions options; + FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options; ffInitDiskIOOptions(&options); if (module) { ffDiskIOModuleInfo.parseJsonObject(&options, module); @@ -167,7 +167,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'n': case 'N': { if (ffStrEqualsIgnCase(type, FF_NETIO_MODULE_NAME)) { - __attribute__((__cleanup__(ffDestroyNetIOOptions))) FFNetIOOptions options; + FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options; ffInitNetIOOptions(&options); if (module) { ffNetIOModuleInfo.parseJsonObject(&options, module); @@ -179,7 +179,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'p': case 'P': { if (ffStrEqualsIgnCase(type, FF_PUBLICIP_MODULE_NAME)) { - __attribute__((__cleanup__(ffDestroyPublicIpOptions))) FFPublicIPOptions options; + FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options; ffInitPublicIpOptions(&options); if (module) { ffPublicIPModuleInfo.parseJsonObject(&options, module); @@ -191,7 +191,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) { case 'w': case 'W': { if (ffStrEqualsIgnCase(type, FF_WEATHER_MODULE_NAME)) { - __attribute__((__cleanup__(ffDestroyWeatherOptions))) FFWeatherOptions options; + FF_A_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 e96b0ae0d..06149eab1 100644 --- a/src/common/impl/kmod_nbsd.c +++ b/src/common/impl/kmod_nbsd.c @@ -4,7 +4,7 @@ #include #include -typedef struct __attribute__((__packed__)) FFNbsdModList { +typedef struct FF_A_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 bca89ee34..c254ba7b2 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_MAYBE_UNUSED const char* modName) { +bool ffKmodLoaded(FF_A_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 39842f476..74403e2bd 100644 --- a/src/common/impl/library.c +++ b/src/common/impl/library.c @@ -102,7 +102,7 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...) { #if _WIN32 -void* dlopen(const char* path, FF_MAYBE_UNUSED int mode) { +void* dlopen(const char* path, FF_A_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 a4b185865..67e486821 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 __attribute__((__packed__)) { + struct FF_A_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_MAYBE_UNUSED int routeCount = 0; + FF_A_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 __attribute__((__packed__)) { + struct FF_A_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_MAYBE_UNUSED int routeCount = 0; + FF_A_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_MAYBE_UNUSED char str[INET6_ADDRSTRLEN]; + FF_A_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_MAYBE_UNUSED char str[INET6_ADDRSTRLEN]; + FF_A_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 4506b9e17..0f28947ea 100644 --- a/src/common/impl/networking_linux.c +++ b/src/common/impl/networking_linux.c @@ -254,7 +254,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos if (state->timeout > 0) { FF_DEBUG("Setting connection timeout: %u ms", state->timeout); - FF_MAYBE_UNUSED uint32_t sec = state->timeout / 1000; + FF_A_UNUSED uint32_t sec = state->timeout / 1000; if (sec == 0) { sec = 1; } @@ -410,7 +410,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf } FF_DEBUG("Starting data reception"); - FF_MAYBE_UNUSED int recvCount = 0; + FF_A_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 6c7599515..65eaf2445 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_MAYBE_UNUSED int recvCount = 0; + FF_A_UNUSED int recvCount = 0; uint32_t contentLength = 0; uint32_t headerEnd = 0; diff --git a/src/common/impl/smbios.c b/src/common/impl/smbios.c index 8fcfea2ca..97b401d61 100644 --- a/src/common/impl/smbios.c +++ b/src/common/impl/smbios.c @@ -67,7 +67,7 @@ static bool parseSmbiosTable(const uint8_t* data, uint32_t length) { const FFSmbiosHeader* endOfTable = NULL; FF_DEBUG("Parsing SMBIOS table structures with length %u bytes", length); - FF_MAYBE_UNUSED int structureCount = 0, totalCount = 0; + FF_A_UNUSED int structureCount = 0, totalCount = 0; for ( const FFSmbiosHeader* header = (const FFSmbiosHeader*) data; (const uint8_t*) header + sizeof(FFSmbiosHeader) < (const uint8_t*) data + length; @@ -194,7 +194,7 @@ typedef struct FFSmbios20EntryPoint { uint32_t StructureTableAddress; uint16_t NumberOfSmbiosStructures; uint8_t SmbiosBcdRevision; -} __attribute__((__packed__)) FFSmbios20EntryPoint; +} FF_A_PACKED FFSmbios20EntryPoint; static_assert(offsetof(FFSmbios20EntryPoint, SmbiosBcdRevision) == 0x1E, "FFSmbios20EntryPoint: Wrong struct alignment"); @@ -209,7 +209,7 @@ typedef struct FFSmbios30EntryPoint { uint8_t Reversed; uint32_t StructureTableMaximumSize; uint64_t StructureTableAddress; -} __attribute__((__packed__)) FFSmbios30EntryPoint; +} FF_A_PACKED FFSmbios30EntryPoint; static_assert(offsetof(FFSmbios30EntryPoint, StructureTableAddress) == 0x10, "FFSmbios30EntryPoint: Wrong struct alignment"); diff --git a/src/common/io.h b/src/common/io.h index 02d4dd3de..16431ee94 100644 --- a/src/common/io.h +++ b/src/common/io.h @@ -49,7 +49,7 @@ static inline bool ffIsValidNativeFD(FFNativeFD fd) { #endif } -FF_C_NONNULL(1) +FF_A_NONNULL(1) static inline bool wrapClose(FFNativeFD* pfd) { assert(pfd); @@ -65,7 +65,7 @@ static inline bool wrapClose(FFNativeFD* pfd) { return true; } -#define FF_AUTO_CLOSE_FD __attribute__((__cleanup__(wrapClose))) +#define FF_AUTO_CLOSE_FD FF_A_CLEANUP(wrapClose) static inline FFNativeFD FFUnixFD2NativeFD(int unixfd) { #ifndef _WIN32 @@ -75,7 +75,7 @@ static inline FFNativeFD FFUnixFD2NativeFD(int unixfd) { #endif } -FF_C_NONNULL(3) +FF_A_NONNULL(3) static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* data) { #ifndef _WIN32 return write(fd, data, dataSize) != -1; @@ -85,20 +85,20 @@ static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* dat #endif } -FF_C_NONNULL(2) +FF_A_NONNULL(2) static inline bool ffWriteFDBuffer(FFNativeFD fd, const FFstrbuf* content) { return ffWriteFDData(fd, content->length, content->chars); } -FF_C_NONNULL(1, 3) +FF_A_NONNULL(1, 3) bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data); -FF_C_NONNULL(1, 2) +FF_A_NONNULL(1, 2) static inline bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer) { return ffWriteFileData(fileName, buffer->length, buffer->chars); } -FF_C_NONNULL(3) +FF_A_NONNULL(3) static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data) { #ifndef _WIN32 return read(fd, data, dataSize); @@ -112,10 +112,10 @@ static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data) { #endif } -FF_C_NONNULL(2) +FF_A_NONNULL(2) bool ffAppendFDBuffer(FFNativeFD fd, FFstrbuf* buffer); -FF_C_NONNULL(1, 3) +FF_A_NONNULL(1, 3) static inline ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data) { FFNativeFD FF_AUTO_CLOSE_FD fd = #ifndef _WIN32 @@ -131,7 +131,7 @@ static inline ssize_t ffReadFileData(const char* fileName, size_t dataSize, void return ffReadFDData(fd, dataSize, data); } -FF_C_NONNULL(2, 4) +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); if (!ffIsValidNativeFD(fd)) { @@ -141,7 +141,7 @@ static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileNam return ffReadFDData(fd, dataSize, data); } -FF_C_NONNULL(1, 2) +FF_A_NONNULL(1, 2) static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) { FFNativeFD FF_AUTO_CLOSE_FD fd = #ifndef _WIN32 @@ -157,7 +157,7 @@ static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) { return ffAppendFDBuffer(fd, buffer); } -FF_C_NONNULL(2, 3) +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); if (!ffIsValidNativeFD(fd)) { @@ -167,32 +167,32 @@ static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileNa return ffAppendFDBuffer(fd, buffer); } -FF_C_NONNULL(2) +FF_A_NONNULL(2) static inline bool ffReadFDBuffer(FFNativeFD fd, FFstrbuf* buffer) { ffStrbufClear(buffer); return ffAppendFDBuffer(fd, buffer); } -FF_C_NONNULL(1, 2) +FF_A_NONNULL(1, 2) static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer) { ffStrbufClear(buffer); return ffAppendFileBuffer(fileName, buffer); } -FF_C_NONNULL(2, 3) +FF_A_NONNULL(2, 3) static inline bool ffReadFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) { ffStrbufClear(buffer); return ffAppendFileBufferRelative(dfd, fileName, buffer); } -typedef enum __attribute__((__packed__)) FFPathType { +typedef enum FF_A_PACKED FFPathType { FF_PATHTYPE_FILE = 1 << 0, FF_PATHTYPE_DIRECTORY = 1 << 1, FF_PATHTYPE_ANY = FF_PATHTYPE_FILE | FF_PATHTYPE_DIRECTORY, FF_PATHTYPE_FORCE_UNSIGNED = UINT8_MAX, } FFPathType; -FF_C_NONNULL(1) +FF_A_NONNULL(1) static inline bool ffPathExists(const char* path, FFPathType pathType) { #ifdef _WIN32 @@ -242,13 +242,13 @@ static inline bool ffPathExists(const char* path, FFPathType pathType) { return false; } -FF_C_NONNULL(1, 2) +FF_A_NONNULL(1, 2) bool ffPathExpandEnv(const char* in, FFstrbuf* out); #define FF_IO_TERM_RESP_WAIT_MS 100 // #554 -FF_C_SCANF(3, 4) -FF_C_NONNULL(1, 3) +FF_A_SCANF(3, 4) +FF_A_NONNULL(1, 3) const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...); // Not thread safe! @@ -262,11 +262,11 @@ static inline void ffUnsuppressIO(bool* suppressed) { *suppressed = false; } -#define FF_SUPPRESS_IO() bool __attribute__((__cleanup__(ffUnsuppressIO), __unused__)) io_suppressed__ = ffSuppressIO(true) +#define FF_SUPPRESS_IO() bool FF_A_CLEANUP(ffUnsuppressIO) FF_A_UNUSED io_suppressed__ = ffSuppressIO(true) void ffListFilesRecursively(const char* path, bool pretty); -FF_C_NONNULL(1) +FF_A_NONNULL(1) static inline bool wrapFclose(FILE** pfile) { assert(pfile); if (!*pfile) { @@ -275,9 +275,9 @@ static inline bool wrapFclose(FILE** pfile) { fclose(*pfile); return true; } -#define FF_AUTO_CLOSE_FILE __attribute__((__cleanup__(wrapFclose))) +#define FF_AUTO_CLOSE_FILE FF_A_CLEANUP(wrapFclose) -FF_C_NONNULL(1) +FF_A_NONNULL(1) #ifndef _WIN32 static inline bool wrapClosedir(DIR** pdir) { assert(pdir); @@ -297,9 +297,9 @@ static inline bool wrapClosedir(HANDLE* pdir) { return true; } #endif -#define FF_AUTO_CLOSE_DIR __attribute__((__cleanup__(wrapClosedir))) +#define FF_AUTO_CLOSE_DIR FF_A_CLEANUP(wrapClosedir) -FF_C_NONNULL(1, 2, 3) +FF_A_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) { diff --git a/src/common/library.h b/src/common/library.h index cbe7802b8..7bb573b8c 100644 --- a/src/common/library.h +++ b/src/common/library.h @@ -1,14 +1,13 @@ #pragma once #include "fastfetch.h" -#include "common/FFcheckmacros.h" #ifndef FF_DISABLE_DLOPEN # if defined(_WIN32) # define FF_DLOPEN_FLAGS 0 -FF_C_NODISCARD void* dlopen(const char* path, int mode); -FF_C_NODISCARD void* dlsym(void* handle, const char* symbol); +FF_A_NODISCARD void* dlopen(const char* path, int mode); +FF_A_NODISCARD void* dlsym(void* handle, const char* symbol); int dlclose(void* handle); # else # include @@ -37,7 +36,7 @@ static inline void ffLibraryUnload(void** handle) { __typeof__(&symbolName) ff##symbolName; # define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ - void* __attribute__((__cleanup__(ffLibraryUnload))) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL); \ + void* FF_A_CLEANUP(ffLibraryUnload) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL); \ if (libraryObjectName == NULL) \ return returnValue; @@ -77,7 +76,7 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...); __typeof__(&symbolName) ff##symbolName; # define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \ - FF_MAYBE_UNUSED void* libraryObjectName = NULL; // Placeholder + FF_A_UNUSED void* libraryObjectName = NULL; // Placeholder # define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \ FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__) @@ -86,13 +85,13 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...); symbolMapping = (__typeof__(&symbolName)) &symbolName; # define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \ - FF_MAYBE_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue); + FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue); # define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \ - FF_MAYBE_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName; + FF_A_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName; # define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \ - FF_MAYBE_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed"); + FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed"); # define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \ FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, returnValue); diff --git a/src/common/mallocHelper.h b/src/common/mallocHelper.h index 215cf3d78..d35fe210b 100644 --- a/src/common/mallocHelper.h +++ b/src/common/mallocHelper.h @@ -20,7 +20,7 @@ static inline void ffWrapFree(const void* pPtr) { } } -#define FF_AUTO_FREE __attribute__((__cleanup__(ffWrapFree))) +#define FF_AUTO_FREE FF_A_CLEANUP(ffWrapFree) // ptr MUST be a malloc'ed pointer static inline size_t ffMallocUsableSize(const void* ptr) { diff --git a/src/common/netif.h b/src/common/netif.h index 3449145b5..b79c47807 100644 --- a/src/common/netif.h +++ b/src/common/netif.h @@ -7,7 +7,7 @@ # include #endif -typedef enum __attribute__((__packed__)) FFNetifDefaultRouteResultStatus { +typedef enum FF_A_PACKED FFNetifDefaultRouteResultStatus { FF_NETIF_UNINITIALIZED, FF_NETIF_INVALID, FF_NETIF_OK diff --git a/src/common/option.h b/src/common/option.h index 1c866a28b..ce0a0ab01 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -36,7 +36,7 @@ typedef struct FFModuleBaseInfo { FFModuleFormatArgList formatArgs; } FFModuleBaseInfo; -typedef enum __attribute__((__packed__)) FFModuleKeyType { +typedef enum FF_A_PACKED FFModuleKeyType { FF_MODULE_KEY_TYPE_NONE = 0, FF_MODULE_KEY_TYPE_STRING = 1 << 0, FF_MODULE_KEY_TYPE_ICON = 1 << 1, @@ -66,10 +66,10 @@ typedef struct FFKeyValuePair { const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName); void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer); -FF_C_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value); -FF_C_NODISCARD int32_t ffOptionParseInt32(const char* argumentKey, const char* value); -FF_C_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]); -FF_C_NODISCARD bool ffOptionParseBoolean(const char* str); +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); void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer); static inline void ffOptionParseColor(const char* value, FFstrbuf* buffer) { ffStrbufClear(buffer); diff --git a/src/common/percent.h b/src/common/percent.h index 5cd4c9c00..c2eeba6b9 100644 --- a/src/common/percent.h +++ b/src/common/percent.h @@ -4,7 +4,7 @@ #include "common/parsing.h" #include "common/option.h" -typedef enum __attribute__((__packed__)) FFPercentageTypeFlags { +typedef enum FF_A_PACKED FFPercentageTypeFlags { FF_PERCENTAGE_TYPE_NONE = 0, FF_PERCENTAGE_TYPE_NUM_BIT = 1 << 0, FF_PERCENTAGE_TYPE_BAR_BIT = 1 << 1, diff --git a/src/common/printing.h b/src/common/printing.h index 9cc99b1b2..c14a6edf3 100644 --- a/src/common/printing.h +++ b/src/common/printing.h @@ -3,7 +3,7 @@ #include "fastfetch.h" #include "common/format.h" -typedef enum __attribute__((__packed__)) FFPrintType { +typedef enum FF_A_PACKED FFPrintType { FF_PRINT_TYPE_DEFAULT = 0, FF_PRINT_TYPE_NO_CUSTOM_KEY = 1 << 0, // key has been formatted outside FF_PRINT_TYPE_NO_CUSTOM_KEY_COLOR = 1 << 1, @@ -16,7 +16,7 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu void 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_C_PRINTF(5, 6) +FF_A_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/settings.h b/src/common/settings.h index 967de9576..02658670e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -2,7 +2,7 @@ #include "fastfetch.h" -typedef enum __attribute__((__packed__)) FFvarianttype { +typedef enum FF_A_PACKED FFvarianttype { FF_VARIANT_TYPE_STRING, FF_VARIANT_TYPE_BOOL, FF_VARIANT_TYPE_INT diff --git a/src/common/smbios.h b/src/common/smbios.h index 057e5e45b..23832d424 100644 --- a/src/common/smbios.h +++ b/src/common/smbios.h @@ -12,7 +12,7 @@ static inline void ffCleanUpSmbiosValue(FFstrbuf* value) { // https://github.com/KunYi/DumpSMBIOS // https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.7.0.pdf -typedef enum __attribute__((__packed__)) FFSmbiosType // : uint8_t +typedef enum FF_A_PACKED FFSmbiosType // : uint8_t { FF_SMBIOS_TYPE_BIOS = 0, FF_SMBIOS_TYPE_SYSTEM_INFO = 1, @@ -79,7 +79,7 @@ typedef struct FFSmbiosHeader { // Unique handle, used to reference this structure from other structures. // Not guaranteed to be consistent across reboots or even multiple reads of the same table. uint16_t Handle; -} __attribute__((__packed__)) FFSmbiosHeader; +} FF_A_PACKED 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/sysctl.h b/src/common/sysctl.h index 3442c4e91..1baabe628 100644 --- a/src/common/sysctl.h +++ b/src/common/sysctl.h @@ -1,18 +1,17 @@ #pragma once #include "fastfetch.h" -#include "common/FFcheckmacros.h" #include #include #ifdef __OpenBSD__ const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result); -FF_C_NODISCARD int ffSysctlGetInt(int mib1, int mib2, int defaultValue); -FF_C_NODISCARD int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue); +FF_A_NODISCARD int ffSysctlGetInt(int mib1, int mib2, int defaultValue); +FF_A_NODISCARD int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue); #else const char* ffSysctlGetString(const char* propName, FFstrbuf* result); -FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue); -FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue); +FF_A_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue); +FF_A_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue); #endif -FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength); +FF_A_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength); diff --git a/src/common/thread.h b/src/common/thread.h index 8dcba25c3..8af7c0790 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -87,7 +87,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_MAYBE_UNUSED uint32_t timeout) { +static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeout) { # if HAVE_TIMEDJOIN_NP if (timeout > 0) { struct timespec ts; @@ -109,7 +109,7 @@ static inline bool ffThreadJoin(FFThreadType thread, FF_MAYBE_UNUSED uint32_t ti #else // FF_HAVE_THREADS # define FF_THREAD_MUTEX_INITIALIZER 0 typedef char FFThreadMutex; -static inline void ffThreadMutexLock(FF_MAYBE_UNUSED FFThreadMutex* mutex) {} -static inline void ffThreadMutexUnlock(FF_MAYBE_UNUSED FFThreadMutex* mutex) {} +static inline void ffThreadMutexLock(FF_A_UNUSED FFThreadMutex* mutex) {} +static inline void ffThreadMutexUnlock(FF_A_UNUSED FFThreadMutex* mutex) {} # define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) #endif // FF_HAVE_THREADS diff --git a/src/common/unused.h b/src/common/unused.h index 78d85800f..98e21a2e6 100644 --- a/src/common/unused.h +++ b/src/common/unused.h @@ -4,8 +4,3 @@ static inline void ffUnused(int dummy, ...) { (void) dummy; } #define FF_UNUSED(...) ffUnused(0, __VA_ARGS__); -#if defined(__GNUC__) || defined(__clang__) -# define FF_MAYBE_UNUSED __attribute__((__unused__)) -#else -# define FF_MAYBE_UNUSED -#endif diff --git a/src/common/windows/com.hpp b/src/common/windows/com.hpp index a9cbcecb6..977233e10 100644 --- a/src/common/windows/com.hpp +++ b/src/common/windows/com.hpp @@ -13,7 +13,7 @@ static inline void ffReleaseComObject(void* ppUnknown) { } } -# define FF_AUTO_RELEASE_COM_OBJECT __attribute__((__cleanup__(ffReleaseComObject))) +# define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject) #else // Win32 COM headers requires C++ compiler diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_android.c index 062d2a533..fd5949a17 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* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); 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 a3701a320..19c275613 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_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) { +const char* ffDetectBattery(FF_A_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 82d6bec1d..265b16566 100644 --- a/src/detection/battery/battery_haiku.c +++ b/src/detection/battery/battery_haiku.c @@ -55,7 +55,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) { return NULL; } -const char* ffDetectBattery(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) { +const char* ffDetectBattery(FF_A_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 1c37f93fa..08a3efb78 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_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) { +const char* ffDetectBattery(FF_A_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 9a7edd23c..6da5250e2 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_MAYBE_UNUSED FFBatteryOptions* options, FFlist* result) { +const char* ffDetectBattery(FF_A_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 32ac33b77..71f84b9f5 100644 --- a/src/detection/battery/battery_windows.c +++ b/src/detection/battery/battery_windows.c @@ -186,7 +186,7 @@ typedef struct FFSmbiosPortableBattery { uint8_t SbdsDeviceChemistry; // string uint8_t DesignCapacityMultiplier; // varies uint16_t OEMSpecific; // varies -} __attribute__((__packed__)) FFSmbiosPortableBattery; +} FF_A_PACKED FFSmbiosPortableBattery; static_assert(offsetof(FFSmbiosPortableBattery, OEMSpecific) == 0x16, "FFSmbiosPortableBattery: Wrong struct alignment"); @@ -256,7 +256,7 @@ static const char* detectBySmbios(FFBatteryResult* battery) { return NULL; } -static const char* detectWithNtApi(FF_MAYBE_UNUSED FFBatteryOptions* options, FFlist* results) { +static const char* detectWithNtApi(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) { SYSTEM_BATTERY_STATE info; if (NT_SUCCESS(NtPowerInformation(SystemBatteryState, NULL, 0, &info, sizeof(info))) && info.BatteryPresent) { FFBatteryResult* battery = (FFBatteryResult*) ffListAdd(results); diff --git a/src/detection/bios/bios_nosupport.c b/src/detection/bios/bios_nosupport.c index 091bf631f..e04483570 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_MAYBE_UNUSED FFBiosResult* bios) { +const char* ffDetectBios(FF_A_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 993278abe..868519e3c 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -38,7 +38,7 @@ typedef struct FFSmbiosBios { // 3.1+ uint16_t ExtendedBiosRomSize; // bit field -} __attribute__((__packed__)) FFSmbiosBios; +} FF_A_PACKED 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 4af766307..5c97a61cc 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_MAYBE_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* devices) { +static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* devices) { FFBluetoothResult* device = ffListAdd(devices); ffStrbufInitS(&device->name, #if __FreeBSD__ @@ -20,7 +20,7 @@ static int enumDev(FF_MAYBE_UNUSED int sockfd, struct bt_devinfo const* dev, FFl return 0; } -const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothResult */) { +const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_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 e9b1ba426..a9ce35950 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_MAYBE_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) { +const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) { using namespace Bluetooth; FF_SUPPRESS_IO(); diff --git a/src/detection/bluetooth/bluetooth_linux.c b/src/detection/bluetooth/bluetooth_linux.c index e7d96e664..1f10968a6 100644 --- a/src/detection/bluetooth/bluetooth_linux.c +++ b/src/detection/bluetooth/bluetooth_linux.c @@ -234,7 +234,7 @@ static uint32_t connectedDevices(void) { #endif -const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothResult */) { +const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) { #ifdef FF_HAVE_DBUS int32_t connectedCount = -1; if (!options->showDisconnected) { diff --git a/src/detection/bluetooth/bluetooth_nosupport.c b/src/detection/bluetooth/bluetooth_nosupport.c index afba201e1..ac93ceed4 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_MAYBE_UNUSED FFBluetoothOptions* options, FF_MAYBE_UNUSED FFlist* devices /* FFBluetoothResult */) { +const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) { return "Not supported on this platform"; } diff --git a/src/detection/bluetoothradio/bluetoothradio_nosupport.c b/src/detection/bluetoothradio/bluetoothradio_nosupport.c index 6176427be..08fb6f8a7 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_MAYBE_UNUSED FFlist* devices /* FFBluetoothRadioResult */) { +const char* ffDetectBluetoothRadio(FF_A_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 88978bbc4..8977b05ab 100644 --- a/src/detection/bluetoothradio/bluetoothradio_windows.c +++ b/src/detection/bluetoothradio/bluetoothradio_windows.c @@ -27,7 +27,7 @@ typedef struct _BTH_RADIO_INFO { // LMP version UCHAR lmpVersion; -} __attribute__((__packed__)) BTH_RADIO_INFO; +} FF_A_PACKED BTH_RADIO_INFO; typedef struct _BTH_LOCAL_RADIO_INFO { // Local BTH_ADDR, class of device, and radio name @@ -44,7 +44,7 @@ typedef struct _BTH_LOCAL_RADIO_INFO { // More information about the local radio (LMP, MFG) BTH_RADIO_INFO radioInfo; -} __attribute__((__packed__)) BTH_LOCAL_RADIO_INFO; +} FF_A_PACKED 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 3865b652e..befc63083 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_MAYBE_UNUSED FFBoardResult* board) { +const char* ffDetectBoard(FF_A_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 388e0675c..079e64d51 100644 --- a/src/detection/board/board_windows.c +++ b/src/detection/board/board_windows.c @@ -15,7 +15,7 @@ typedef struct FFSmbiosBaseboard { uint8_t BoardType; // enum uint8_t NumberOfContainedObjectHandles; // varies uint16_t ContainedObjectHandles[]; // varies -} __attribute__((__packed__)) FFSmbiosBaseboard; +} FF_A_PACKED 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 324e3eafa..bb0171427 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_MAYBE_UNUSED FFBootmgrResult* result) { +const char* ffDetectBootmgr(FF_A_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 602220358..55b1a2dd1 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -8,21 +8,21 @@ // DDC/CI #ifdef __aarch64__ typedef CFTypeRef IOAVServiceRef; -extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) __attribute__((weak_import)); -extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) __attribute__((weak_import)); -extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) __attribute__((weak_import)); -extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) __attribute__((weak_import)); -extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) __attribute__((weak_import)); +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; #else // DDC/CI (Intel) # include # include # include -extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service) __attribute__((weak_import)); +extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service) FF_A_WEAK_IMPORT; #endif // ACPI -extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* brightness) __attribute__((weak_import)); +extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* brightness) FF_A_WEAK_IMPORT; // Works for internal display static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* result) { @@ -50,7 +50,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_MAYBE_UNUSED const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) { +static const char* detectWithDdcci(FF_A_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 ea708ad0d..68bd9f1b3 100644 --- a/src/detection/brightness/brightness_bsd.c +++ b/src/detection/brightness/brightness_bsd.c @@ -9,7 +9,7 @@ # include # include -const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { // https://man.freebsd.org/cgi/man.cgi?query=backlight&sektion=9 char path[] = "/dev/backlight/backlight0"; @@ -46,7 +46,7 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFl #else -const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FF_MAYBE_UNUSED FFlist* result) { +const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) { return "Backlight is supported only on FreeBSD 13 and newer"; } diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index ae9467e28..784ffb1b6 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -92,7 +92,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_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) { +static const char* detectWithDdcci(FF_A_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) @@ -160,7 +160,7 @@ static const char* detectWithDdcci(FF_MAYBE_UNUSED FFBrightnessOptions* options, } #endif -const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness(FF_A_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 9eb56f68f..b61d66abb 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_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness(FF_A_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 133075057..6e9284e96 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_MAYBE_UNUSED FFBrightnessOptions* options, FF_MAYBE_UNUSED FFlist* result) { +const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FF_A_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 f19c3cbad..13122a2da 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_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) { +const char* ffDetectBrightness(FF_A_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.cpp b/src/detection/brightness/brightness_windows.cpp index 7c11fbfb0..ec8e37020 100644 --- a/src/detection/brightness/brightness_windows.cpp +++ b/src/detection/brightness/brightness_windows.cpp @@ -126,7 +126,7 @@ static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer) { return false; } -extern "C" const char* ffDetectBrightness(FF_MAYBE_UNUSED FFBrightnessOptions* options, FFlist* result) { +extern "C" const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); if (hasBuiltinDisplay(displayServer)) { diff --git a/src/detection/btrfs/btrfs_nosupport.c b/src/detection/btrfs/btrfs_nosupport.c index 207902572..b51d2c5cd 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_MAYBE_UNUSED FFlist* result) { +const char* ffDetectBtrfs(FF_A_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 d950829b9..0622e668d 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_MAYBE_UNUSED FFlist* result) { +const char* ffDetectCamera(FF_A_UNUSED FFlist* result) { FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate(); if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL })) { return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed"; } - yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); 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 4e3e60070..bc5b95fbc 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 __attribute__((weak_import)) AVCaptureDeviceType const AVCaptureDeviceTypeExternal; +AVF_EXPORT FF_A_WEAK_IMPORT 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 fae48d4f8..ae5b2432d 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_MAYBE_UNUSED FFlist* result) { +const char* ffDetectCamera(FF_A_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 e91d4eb1d..ceb08a7df 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_MAYBE_UNUSED FFlist* result) { +extern "C" const char* ffDetectCamera(FF_A_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) diff --git a/src/detection/chassis/chassis_nosupport.c b/src/detection/chassis/chassis_nosupport.c index 5cdb873a5..0fc4dd949 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_MAYBE_UNUSED FFChassisResult* result) { +const char* ffDetectChassis(FF_A_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 34b7fd05a..51a4c6c16 100644 --- a/src/detection/chassis/chassis_windows.c +++ b/src/detection/chassis/chassis_windows.c @@ -24,7 +24,7 @@ typedef struct FFSmbiosSystemEnclosure { uint8_t ContainedElementCount; // varies uint8_t ContainedRecordLength; // varies uint8_t ContainedElements[]; // varies -} __attribute__((__packed__)) FFSmbiosSystemEnclosure; +} FF_A_PACKED FFSmbiosSystemEnclosure; static_assert(offsetof(FFSmbiosSystemEnclosure, ContainedElements) == 0x15, "FFSmbiosSystemEnclosure: Wrong struct alignment"); diff --git a/src/detection/cpu/cpu.c b/src/detection/cpu/cpu.c index 75e2fa326..456b4a947 100644 --- a/src/detection/cpu/cpu.c +++ b/src/detection/cpu/cpu.c @@ -505,14 +505,14 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) { } } # else -void ffCPUDetectByCpuid(FF_MAYBE_UNUSED FFCPUResult* cpu) { +void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) { // Unsupported system } # endif #else -void ffCPUDetectByCpuid(FF_MAYBE_UNUSED FFCPUResult* cpu) { +void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) { // Unsupported architecture } diff --git a/src/detection/cpu/cpu_haiku.c b/src/detection/cpu/cpu_haiku.c index 1831a83e0..9a8acb587 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_MAYBE_UNUSED const FFCPUOptions* options, FFCPUResult* cpu) { +const char* ffDetectCPUImpl(FF_A_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 359b24165..8c51d4334 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -553,11 +553,11 @@ static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId) static const char* parseCpuInfo( FFstrbuf* cpuinfo, FFCPUResult* cpu, - FF_MAYBE_UNUSED FFstrbuf* physicalCoresBuffer, - FF_MAYBE_UNUSED FFstrbuf* cpuMHz, - FF_MAYBE_UNUSED FFstrbuf* cpuIsa, - FF_MAYBE_UNUSED FFstrbuf* cpuUarch, - FF_MAYBE_UNUSED FFstrbuf* cpuImplementer) { + 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) { char* line = NULL; size_t len = 0; @@ -709,7 +709,7 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options) { #if __i386__ || __x86_64__ -FF_MAYBE_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) { +FF_A_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) { const char* p = cpuinfo->chars; uint64_t low = 0, high = 0; @@ -728,7 +728,7 @@ FF_MAYBE_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) { return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high)); } -FF_MAYBE_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFCPUResult* cpu) { +FF_A_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"; @@ -843,7 +843,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) { return NULL; } -FF_MAYBE_UNUSED static void parseIsa(FFstrbuf* cpuIsa) { +FF_A_UNUSED static void parseIsa(FFstrbuf* cpuIsa) { // Always use the last part of the ISA string. Ref: #590 #1204 ffStrbufSubstrAfterLastC(cpuIsa, ' '); @@ -863,7 +863,7 @@ FF_MAYBE_UNUSED static void parseIsa(FFstrbuf* cpuIsa) { } } -FF_MAYBE_UNUSED static void detectSocName(FFCPUResult* cpu) { +FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) { if (cpu->name.length > 0) { return; } @@ -983,7 +983,7 @@ FF_MAYBE_UNUSED static void detectSocName(FFCPUResult* cpu) { } # ifdef __loongarch__ -FF_MAYBE_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) { +FF_A_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); @@ -1004,7 +1004,7 @@ FF_MAYBE_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const c } # endif -FF_MAYBE_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) { +FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) { cpu->coresLogical = (uint16_t) get_nprocs_conf(); cpu->coresOnline = (uint16_t) get_nprocs(); diff --git a/src/detection/cpu/cpu_nbsd.c b/src/detection/cpu/cpu_nbsd.c index 2a1edeb94..9c88c0ece 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"; } - __attribute__((__cleanup__(freePropDict))) prop_dictionary_t root = NULL; + FF_A_CLEANUP(freePropDict) prop_dictionary_t root = NULL; 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 cddcf1e11..309883db2 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_MAYBE_UNUSED const FFCPUOptions* options, FF_MAYBE_UNUSED FFCPUResult* cpu) { +const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FF_A_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 01a761758..7d93dd49c 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) { - __attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open(); + FF_A_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 ef9801a09..86edce912 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) { } } - __attribute__((__cleanup__(ffPerfCloseQueryHandle))) + FF_A_CLEANUP(ffPerfCloseQueryHandle) HANDLE hQuery = NULL; if (PerfOpenQueryHandle(NULL, &hQuery) != ERROR_SUCCESS) { @@ -181,7 +181,7 @@ typedef struct FFSmbiosProcessorInfo { // 3.6+ uint16_t ThreadEnabled; // varies -} __attribute__((__packed__)) FFSmbiosProcessorInfo; +} FF_A_PACKED FFSmbiosProcessorInfo; static_assert(offsetof(FFSmbiosProcessorInfo, ThreadEnabled) == 0x30, "FFSmbiosProcessorInfo: Wrong struct alignment"); diff --git a/src/detection/cpucache/cpucache.h b/src/detection/cpucache/cpucache.h index 5d917d9e5..5d512cd12 100644 --- a/src/detection/cpucache/cpucache.h +++ b/src/detection/cpucache/cpucache.h @@ -3,7 +3,7 @@ #include "fastfetch.h" #include "modules/cpucache/option.h" -typedef enum __attribute__((__packed__)) FFCPUCacheType { +typedef enum FF_A_PACKED FFCPUCacheType { FF_CPU_CACHE_TYPE_UNIFIED = 0, FF_CPU_CACHE_TYPE_INSTRUCTION = 1, FF_CPU_CACHE_TYPE_DATA = 2, diff --git a/src/detection/cpucache/cpucache_nosupport.c b/src/detection/cpucache/cpucache_nosupport.c index fae988593..51d22563c 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_MAYBE_UNUSED FFCPUCacheResult* result) { +const char* ffDetectCPUCache(FF_A_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 a712e8d70..ece9d6866 100644 --- a/src/detection/cpucache/cpucache_shared.c +++ b/src/detection/cpucache/cpucache_shared.c @@ -21,7 +21,7 @@ typedef struct FFSmbiosCacheInfo { // 3.1+ uint32_t MaximumCacheSize2; // bit field uint32_t InstalledCacheSize2; // bit field -} __attribute__((__packed__)) FFSmbiosCacheInfo; +} FF_A_PACKED FFSmbiosCacheInfo; static_assert(offsetof(FFSmbiosCacheInfo, InstalledCacheSize2) == 0x17, "FFSmbiosCacheInfo: Wrong struct alignment"); diff --git a/src/detection/cpuusage/cpuusage_nosupport.c b/src/detection/cpuusage/cpuusage_nosupport.c index d802dbdd2..faade7b84 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_MAYBE_UNUSED FFlist* cpuTimes) { +const char* ffGetCpuUsageInfo(FF_A_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 9ef75d83b..4f24dfdc2 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) { - __attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open(); + FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); if (!kc) { return "kstat_open() failed"; } diff --git a/src/detection/cursor/cursor_nosupport.c b/src/detection/cursor/cursor_nosupport.c index 797d4207b..6413d92d3 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_MAYBE_UNUSED FFCursorResult* result) { +void ffDetectCursor(FF_A_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 f754568b4..285c03892 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_MAYBE_UNUSED FFDEOptions* options) { +static void getKDE(FFstrbuf* result, FF_A_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_MAYBE_UNUSED FFDEOptions* options) { } } -static const char* getGnomeByDbus(FF_MAYBE_UNUSED FFstrbuf* result) { +static const char* getGnomeByDbus(FF_A_UNUSED FFstrbuf* result) { #ifdef FF_HAVE_DBUS FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {}; if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != NULL) { @@ -70,7 +70,7 @@ static const char* getGnomeByDbus(FF_MAYBE_UNUSED FFstrbuf* result) { #endif // FF_HAVE_DBUS } -static void getGnome(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { +static void getGnome(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { getGnomeByDbus(result); if (result->length == 0) { @@ -80,7 +80,7 @@ static void getGnome(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { } } -static void getCinnamon(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { +static void getCinnamon(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { ffStrbufSetS(result, getenv("CINNAMON_VERSION")); if (result->length == 0) { @@ -94,7 +94,7 @@ static void getCinnamon(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) } } -static void getMate(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { +static void getMate(FFstrbuf* result, FF_A_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_MAYBE_UNUSED FFDEOptions* options) { +static void getXFCE4(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { getXfce4ByLib(result); if (result->length == 0) { @@ -137,7 +137,7 @@ static void getXFCE4(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { } } -static void getLXQt(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { +static void getLXQt(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { ffParsePropFileData("gconfig/lxqt.pc", "Version:", result); if (result->length == 0) { @@ -156,11 +156,11 @@ static void getLXQt(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { } } -static void getBudgie(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { +static void getBudgie(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { ffParsePropFileData("budgie/budgie-version.xml", "", result); } -static void getUnity(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { +static void getUnity(FFstrbuf* result, FF_A_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_MAYBE_UNUSED FFDEOptions* options) { +static const char* getTrinity(FFstrbuf* result, FF_A_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_MAYBE_UNUSED FFDEOptions* opt return "All methods failed"; } -static const char* getCosmic(FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { +static const char* getCosmic(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) { if (ffProcessAppendStdOut(result, (char* const[]) { "cosmic-comp", "--version", NULL }) == NULL) { // cosmic-comp 0.1.0 (git commit fa88002ba41d2edec25dd7ffdee9719fbb928fc0) ffStrbufSubstrAfterFirstC(result, ' '); diff --git a/src/detection/de/de_nosupport.c b/src/detection/de/de_nosupport.c index 2dc3c4508..d870ae033 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_MAYBE_UNUSED const FFstrbuf* deName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) { +const char* ffDetectDEVersion(FF_A_UNUSED const FFstrbuf* deName, FF_A_UNUSED FFstrbuf* result, FF_A_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 9c4d32fad..02d632019 100644 --- a/src/detection/disk/disk_bsd.c +++ b/src/detection/disk/disk_bsd.c @@ -2,6 +2,7 @@ #include "common/mallocHelper.h" #include "common/stringUtils.h" +#include #include #include @@ -53,7 +54,7 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) { return NULL; } # else -static const char* detectFsLabel(FF_MAYBE_UNUSED struct statfs* fs, FF_MAYBE_UNUSED FFDisk* disk) { +static const char* detectFsLabel(FF_A_UNUSED struct statfs* fs, FF_A_UNUSED FFDisk* disk) { return "Fastfetch was compiled without libgeom support"; } # endif @@ -87,7 +88,7 @@ struct CmnAttrBuf { uint32_t length; attrreference_t nameRef; char nameSpace[NAME_MAX * 3 + 1]; -} __attribute__((aligned(4), packed)); +} FF_A_PACKED; void detectFsInfo(struct statfs* fs, FFDisk* disk) { if (fs->f_flags & MNT_DONTBROWSE) { @@ -98,7 +99,7 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk) { disk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT; } - struct CmnAttrBuf attrBuf; + alignas(4) struct CmnAttrBuf attrBuf; if (getattrlist(disk->mountpoint.chars, &(struct attrlist) { .bitmapcount = ATTR_BIT_MAP_COUNT, .commonattr = ATTR_CMN_NAME, diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index c256527ab..7a004b5de 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_MAYBE_UNUSED const FFlist* disks, FFDisk* currentDisk, FF_MAYBE_UNUSED struct mntent* device) { +static void detectType(FF_A_UNUSED const FFlist* disks, FFDisk* currentDisk, FF_A_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 b2c4ac9b2..eabddbc88 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_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_UNUSED FFlist* disks) { +const char* ffDetectDisksImpl(FF_A_UNUSED FFDiskOptions* options, FF_A_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 b599f0f36..3b8b11d80 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) { - __attribute__((__cleanup__(geom_deletetree))) struct gmesh geomTree = {}; + FF_A_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 c95c8a39a..f5de15d08 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_MAYBE_UNUSED FFlist* result, FF_MAYBE_UNUSED FFDiskIOOptions* options) { +const char* ffDiskIOGetIoCounters(FF_A_UNUSED FFlist* result, FF_A_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 ba3ef01e4..8149e9dcb 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) { - __attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open(); + FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); if (!kc) { return "kstat_open() failed"; } diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index 05900f5ec..523f32f3f 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -46,20 +46,20 @@ #define FF_WM_PROTOCOL_WAYLAND "Wayland" #define FF_WM_PROTOCOL_SURFACEFLINGER "SurfaceFlinger" -typedef enum __attribute__((__packed__)) FFDisplayType { +typedef enum FF_A_PACKED FFDisplayType { FF_DISPLAY_TYPE_UNKNOWN, FF_DISPLAY_TYPE_BUILTIN, FF_DISPLAY_TYPE_EXTERNAL, } FFDisplayType; -typedef enum __attribute__((__packed__)) FFDisplayHdrStatus { +typedef enum FF_A_PACKED FFDisplayHdrStatus { FF_DISPLAY_HDR_STATUS_UNKNOWN, FF_DISPLAY_HDR_STATUS_UNSUPPORTED, FF_DISPLAY_HDR_STATUS_SUPPORTED, FF_DISPLAY_HDR_STATUS_ENABLED, } FFDisplayHdrStatus; -typedef enum __attribute__((__packed__)) FFDisplayVrrStatus { +typedef enum FF_A_PACKED FFDisplayVrrStatus { FF_DISPLAY_DRR_STATUS_UNKNOWN, FF_DISPLAY_DRR_STATUS_DISABLED, FF_DISPLAY_DRR_STATUS_ENABLED, diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index dca985976..cca5f9408 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -11,9 +11,9 @@ #include #ifdef MAC_OS_X_VERSION_10_15 -extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display) __attribute__((weak_import)); -extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display) __attribute__((weak_import)); -extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) __attribute__((weak_import)); +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; #else # include #endif diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index 63a116024..f92c144f9 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -13,7 +13,7 @@ static inline void freeArgBuffer(FFArgBuffer* buffer) { buffer->data = NULL; buffer->length = 0; } -#define FF_AUTO_FREE_ARG_BUFFER __attribute__((__cleanup__(freeArgBuffer))) +#define FF_AUTO_FREE_ARG_BUFFER FF_A_CLEANUP(freeArgBuffer) // http://undoc.airesoft.co.uk/user32.dll/IsThreadDesktopComposited.php BOOL WINAPI IsThreadDesktopComposited(); diff --git a/src/detection/displayserver/linux/drm.c b/src/detection/displayserver/linux/drm.c index 466094624..bee0a003b 100644 --- a/src/detection/displayserver/linux/drm.c +++ b/src/detection/displayserver/linux/drm.c @@ -166,7 +166,7 @@ static inline const char* drmType2Name(uint32_t connector_type) { } } -FF_MAYBE_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edidData, ssize_t* edidLength) { +FF_A_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); @@ -420,7 +420,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) { #endif -const char* ffdsConnectDrm(FF_MAYBE_UNUSED FFDisplayServerResult* result) { +const char* ffdsConnectDrm(FF_A_UNUSED FFDisplayServerResult* result) { #ifdef FF_HAVE_DRM if (instance.config.general.dsForceDrm != FF_DS_FORCE_DRM_TYPE_SYSFS_ONLY) { if (drmConnectLibdrm(result) == NULL) { diff --git a/src/detection/displayserver/linux/wayland/global-output.c b/src/detection/displayserver/linux/wayland/global-output.c index 019f4e216..38b2a01d6 100644 --- a/src/detection/displayserver/linux/wayland/global-output.c +++ b/src/detection/displayserver/linux/wayland/global-output.c @@ -4,7 +4,7 @@ # include "common/stringUtils.h" # include "xdg-output-unstable-v1-client-protocol.h" -static void waylandOutputModeListener(void* data, FF_MAYBE_UNUSED struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) { +static void waylandOutputModeListener(void* data, FF_A_UNUSED struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) { WaylandDisplay* display = data; if (flags & WL_OUTPUT_MODE_CURRENT) { @@ -19,20 +19,20 @@ static void waylandOutputModeListener(void* data, FF_MAYBE_UNUSED struct wl_outp } } -static void waylandOutputScaleListener(void* data, FF_MAYBE_UNUSED struct wl_output* output, int32_t scale) { +static void waylandOutputScaleListener(void* data, FF_A_UNUSED struct wl_output* output, int32_t scale) { WaylandDisplay* display = data; display->dpi = 96 * (uint32_t) scale; } static void waylandOutputGeometryListener(void* data, - FF_MAYBE_UNUSED struct wl_output* output, - FF_MAYBE_UNUSED int32_t x, - FF_MAYBE_UNUSED int32_t y, + FF_A_UNUSED struct wl_output* output, + FF_A_UNUSED int32_t x, + FF_A_UNUSED int32_t y, int32_t physical_width, int32_t physical_height, - FF_MAYBE_UNUSED int32_t subpixel, - FF_MAYBE_UNUSED const char* make, - FF_MAYBE_UNUSED const char* model, + FF_A_UNUSED int32_t subpixel, + FF_A_UNUSED const char* make, + FF_A_UNUSED const char* model, int32_t transform) { WaylandDisplay* display = data; display->physicalWidth = physical_width; @@ -40,7 +40,7 @@ static void waylandOutputGeometryListener(void* data, display->transform = (enum wl_output_transform) transform; } -static void handleXdgLogicalSize(void* data, FF_MAYBE_UNUSED struct zxdg_output_v1* _, int32_t width, FF_MAYBE_UNUSED int32_t height) { +static void handleXdgLogicalSize(void* data, FF_A_UNUSED struct zxdg_output_v1* _, int32_t width, FF_A_UNUSED int32_t height) { WaylandDisplay* display = data; // Seems the values are only useful when ractional scale is enabled if (width < display->width) { diff --git a/src/detection/displayserver/linux/wayland/kde-output.c b/src/detection/displayserver/linux/wayland/kde-output.c index 80161551a..2c5d2a906 100644 --- a/src/detection/displayserver/linux/wayland/kde-output.c +++ b/src/detection/displayserver/linux/wayland/kde-output.c @@ -14,18 +14,18 @@ typedef struct WaylandKdeMode { struct kde_output_device_mode_v2* pMode; } WaylandKdeMode; -static void waylandKdeModeSizeListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_mode_v2* _, int32_t width, int32_t height) { +static void waylandKdeModeSizeListener(void* data, FF_A_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_MAYBE_UNUSED struct kde_output_device_mode_v2* _, int32_t rate) { +static void waylandKdeModeRefreshListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _, int32_t rate) { WaylandKdeMode* mode = (WaylandKdeMode*) data; mode->refreshRate = rate; } -static void waylandKdeModePreferredListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_mode_v2* _) { +static void waylandKdeModePreferredListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _) { WaylandKdeMode* mode = (WaylandKdeMode*) data; mode->preferred = true; } @@ -38,7 +38,7 @@ static const struct kde_output_device_mode_v2_listener modeListener = { .flags = (void*) stubListener, }; -static void waylandKdeModeListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) { +static void waylandKdeModeListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) { WaylandDisplay* wldata = (WaylandDisplay*) data; if (!wldata->internal) { return; @@ -51,7 +51,7 @@ static void waylandKdeModeListener(void* data, FF_MAYBE_UNUSED struct kde_output wldata->parent->ffwl_proxy_add_listener((struct wl_proxy*) mode, (void (**)(void)) &modeListener, newMode); } -static void waylandKdeCurrentModeListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) { +static void waylandKdeCurrentModeListener(void* data, FF_A_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) { @@ -79,12 +79,12 @@ static void waylandKdeCurrentModeListener(void* data, FF_MAYBE_UNUSED struct kde } } -static void waylandKdeScaleListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, wl_fixed_t scale) { +static void waylandKdeScaleListener(void* data, FF_A_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_MAYBE_UNUSED struct kde_output_device_v2* _, const char* raw) { +static void waylandKdeEdidListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, const char* raw) { if (!*raw) { return; } @@ -100,7 +100,7 @@ static void waylandKdeEdidListener(void* data, FF_MAYBE_UNUSED struct kde_output wldata->hdrInfoAvailable = true; } -static void waylandKdeEnabledListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* _, int32_t enabled) { +static void waylandKdeEnabledListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, int32_t enabled) { WaylandDisplay* wldata = (WaylandDisplay*) data; if (!enabled) { wldata->internal = NULL; @@ -108,14 +108,14 @@ static void waylandKdeEnabledListener(void* data, FF_MAYBE_UNUSED struct kde_out } static void waylandKdeGeometryListener(void* data, - FF_MAYBE_UNUSED struct kde_output_device_v2* kde_output_device_v2, - FF_MAYBE_UNUSED int32_t x, - FF_MAYBE_UNUSED int32_t y, + FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, + FF_A_UNUSED int32_t x, + FF_A_UNUSED int32_t y, int32_t physical_width, int32_t physical_height, - FF_MAYBE_UNUSED int32_t subpixel, - FF_MAYBE_UNUSED const char* make, - FF_MAYBE_UNUSED const char* model, + FF_A_UNUSED int32_t subpixel, + FF_A_UNUSED const char* make, + FF_A_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_MAYBE_UNUSED struct kde_output_device_v2* kde_output_device_v2, const char* name) { +static void waylandKdeNameListener(void* data, FF_A_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,12 +132,12 @@ static void waylandKdeNameListener(void* data, FF_MAYBE_UNUSED struct kde_output ffStrbufAppendS(&display->name, name); } -static void waylandKdeHdrListener(void* data, FF_MAYBE_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t hdr_enabled) { +static void waylandKdeHdrListener(void* data, FF_A_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_MAYBE_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t max_bpc) { +static void waylandKdeMaxBitsPerColorListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t max_bpc) { WaylandDisplay* display = data; display->bitDepth = (uint8_t) max_bpc; } @@ -258,7 +258,7 @@ const char* ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* re return NULL; } -static void waylandKdeOutputOrderListener(void* data, FF_MAYBE_UNUSED struct kde_output_order_v1* _, const char* output_name) { +static void waylandKdeOutputOrderListener(void* data, FF_A_UNUSED struct kde_output_order_v1* _, const char* output_name) { uint64_t* id = (uint64_t*) data; if (*id == 0) { *id = ffWaylandGenerateIdFromName(output_name); diff --git a/src/detection/displayserver/linux/wayland/wayland.c b/src/detection/displayserver/linux/wayland/wayland.c index c6943c40d..6e22539ab 100644 --- a/src/detection/displayserver/linux/wayland/wayland.c +++ b/src/detection/displayserver/linux/wayland/wayland.c @@ -103,7 +103,7 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u } } -static FF_MAYBE_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) { +static FF_A_UNUSED 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 @@ -141,7 +141,7 @@ static FF_MAYBE_UNUSED bool matchDrmConnector(const char* connName, WaylandDispl return false; } -void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const char* name) { +void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const char* name) { WaylandDisplay* display = data; if (display->id) { return; @@ -157,7 +157,7 @@ void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const ffStrbufAppendS(&display->name, name); } -void ffWaylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED void* output, const char* description) { +void ffWaylandOutputDescriptionListener(void* data, FF_A_UNUSED void* output, const char* description) { WaylandDisplay* display = data; if (display->description.length) { return; @@ -333,7 +333,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) { #else -const char* ffdsConnectWayland(FF_MAYBE_UNUSED FFDisplayServerResult* result) { +const char* ffdsConnectWayland(FF_A_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 5531b9ffb..b7ea76d2b 100644 --- a/src/detection/displayserver/linux/wayland/wayland.h +++ b/src/detection/displayserver/linux/wayland/wayland.h @@ -9,7 +9,7 @@ # include "../displayserver_linux.h" -typedef enum __attribute__((__packed__)) WaylandProtocolType { +typedef enum FF_A_PACKED WaylandProtocolType { FF_WAYLAND_PROTOCOL_TYPE_NONE, FF_WAYLAND_PROTOCOL_TYPE_GLOBAL, FF_WAYLAND_PROTOCOL_TYPE_ZWLR, @@ -71,8 +71,8 @@ inline static uint64_t ffWaylandGenerateIdFromName(const char* name) { return id; } -void ffWaylandOutputNameListener(void* data, FF_MAYBE_UNUSED void* output, const char* name); -void ffWaylandOutputDescriptionListener(void* data, FF_MAYBE_UNUSED void* output, const char* description); +void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const char* name); +void ffWaylandOutputDescriptionListener(void* data, FF_A_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/displayserver/linux/wayland/zwlr-output.c b/src/detection/displayserver/linux/wayland/zwlr-output.c index 92743d913..d24142a2c 100644 --- a/src/detection/displayserver/linux/wayland/zwlr-output.c +++ b/src/detection/displayserver/linux/wayland/zwlr-output.c @@ -3,12 +3,12 @@ # include "wayland.h" # include "wlr-output-management-unstable-v1-client-protocol.h" -static void waylandZwlrTransformListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t transform) { +static void waylandZwlrTransformListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t transform) { WaylandDisplay* wldata = (WaylandDisplay*) data; wldata->transform = (enum wl_output_transform) transform; } -static void waylandZwlrScaleListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, wl_fixed_t scale) { +static void waylandZwlrScaleListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, wl_fixed_t scale) { WaylandDisplay* wldata = (WaylandDisplay*) data; wldata->dpi = (uint32_t) scale * 3 / 8; // wl_fixed_to_double(scale) * 96; } @@ -21,18 +21,18 @@ typedef struct WaylandZwlrMode { struct zwlr_output_mode_v1* pMode; } WaylandZwlrMode; -static void waylandZwlrModeSizeListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1, int32_t width, int32_t height) { +static void waylandZwlrModeSizeListener(void* data, FF_A_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1, int32_t width, int32_t height) { WaylandZwlrMode* mode = (WaylandZwlrMode*) data; mode->width = width; mode->height = height; } -static void waylandZwlrModeRefreshListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1, int32_t rate) { +static void waylandZwlrModeRefreshListener(void* data, FF_A_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1, int32_t rate) { WaylandZwlrMode* mode = (WaylandZwlrMode*) data; mode->refreshRate = rate; } -static void waylandZwlrModePreferredListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1) { +static void waylandZwlrModePreferredListener(void* data, FF_A_UNUSED struct zwlr_output_mode_v1* zwlr_output_mode_v1) { WaylandZwlrMode* mode = (WaylandZwlrMode*) data; mode->preferred = true; } @@ -44,7 +44,7 @@ static const struct zwlr_output_mode_v1_listener modeListener = { .finished = (void*) stubListener, }; -static void waylandZwlrModeListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, struct zwlr_output_mode_v1* mode) { +static void waylandZwlrModeListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, struct zwlr_output_mode_v1* mode) { WaylandDisplay* wldata = (WaylandDisplay*) data; if (!wldata->internal) { return; @@ -57,7 +57,7 @@ static void waylandZwlrModeListener(void* data, FF_MAYBE_UNUSED struct zwlr_outp wldata->parent->ffwl_proxy_add_listener((struct wl_proxy*) mode, (void (**)(void)) &modeListener, newMode); } -static void waylandZwlrCurrentModeListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, struct zwlr_output_mode_v1* mode) { +static void waylandZwlrCurrentModeListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, struct zwlr_output_mode_v1* mode) { // waylandZwlrModeListener is always run before this WaylandDisplay* wldata = (WaylandDisplay*) data; if (!wldata->internal) { @@ -85,13 +85,13 @@ static void waylandZwlrCurrentModeListener(void* data, FF_MAYBE_UNUSED struct zw } } -static void waylandZwlrPhysicalSizeListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t width, int32_t height) { +static void waylandZwlrPhysicalSizeListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, int32_t width, int32_t height) { WaylandDisplay* wldata = (WaylandDisplay*) data; wldata->physicalWidth = width; wldata->physicalHeight = height; } -static void waylandZwlrEnabledListener(void* data, FF_MAYBE_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, bool enabled) { +static void waylandZwlrEnabledListener(void* data, FF_A_UNUSED struct zwlr_output_head_v1* zwlr_output_head_v1, bool enabled) { WaylandDisplay* wldata = (WaylandDisplay*) data; if (!enabled) { wldata->internal = NULL; @@ -115,7 +115,7 @@ static const struct zwlr_output_head_v1_listener headListener = { .adaptive_sync = (void*) stubListener, }; -static void waylandHandleZwlrHead(void* data, FF_MAYBE_UNUSED struct zwlr_output_manager_v1* zwlr_output_manager_v1, struct zwlr_output_head_v1* head) { +static void waylandHandleZwlrHead(void* data, FF_A_UNUSED struct zwlr_output_manager_v1* zwlr_output_manager_v1, struct zwlr_output_head_v1* head) { WaylandData* wldata = data; FF_LIST_AUTO_DESTROY modes = ffListCreate(sizeof(WaylandZwlrMode)); diff --git a/src/detection/editor/editor.c b/src/detection/editor/editor.c index 99410f551..bb586997b 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_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractNvimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { if (!ffStrStartsWith(str, "NVIM v")) { return true; } @@ -15,7 +15,7 @@ static bool extractNvimVersionFromBinary(const char* str, FF_MAYBE_UNUSED uint32 return false; } -static bool extractVimVersionFromBinary(const char* str, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractVimVersionFromBinary(const char* str, FF_A_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_MAYBE_UNUSED uint32_ return false; } -static bool extractNanoVersionFromBinary(const char* str, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractNanoVersionFromBinary(const char* str, FF_A_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 861e00a8a..26f9ec68a 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_MAYBE_UNUSED FFFontResult* result) { +const char* ffDetectFontImpl(FF_A_UNUSED FFFontResult* result) { FF_UNUSED(result); return "Not supported on this platform"; } diff --git a/src/detection/gamepad/gamepad_nosupport.c b/src/detection/gamepad/gamepad_nosupport.c index de104273f..c0d791e71 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_MAYBE_UNUSED FFlist* devices /* List of FFGamepadDevice */) { +const char* ffDetectGamepad(FF_A_UNUSED FFlist* devices /* List of FFGamepadDevice */) { return "Not supported on this platform"; } diff --git a/src/detection/gpu/d3dkmthk.h b/src/detection/gpu/d3dkmthk.h index 6f19c19f7..cdc0a7592 100644 --- a/src/detection/gpu/d3dkmthk.h +++ b/src/detection/gpu/d3dkmthk.h @@ -3,6 +3,7 @@ #include #include #include +#include #if _WIN32 # include @@ -43,7 +44,7 @@ typedef int32_t NTSTATUS; // 0 for success, -1 for failure # define _In_range_(low, hi) #endif -#define D3DKMT_ALIGN64 __attribute__((aligned(8))) +#define D3DKMT_ALIGN64 alignas(8) typedef struct D3DKMT_HANDLE { union { @@ -308,12 +309,12 @@ typedef struct _DXGK_NODEMETADATA { DXGK_NODEMETADATA_FLAGS Flags; // WDDM 2.2 BOOLEAN GpuMmuSupported; // WDDM 2.0 ??? BOOLEAN IoMmuSupported; -} __attribute__((packed)) DXGK_NODEMETADATA; +} FF_A_PACKED DXGK_NODEMETADATA; typedef struct _D3DKMT_NODEMETADATA { UINT NodeOrdinalAndAdapterIndex; // WDDMv2: High word is physical adapter index, low word is node ordinal DXGK_NODEMETADATA NodeData; -} __attribute__((packed)) D3DKMT_NODEMETADATA; +} FF_A_PACKED 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 3a8850f18..ef8652c1f 100644 --- a/src/detection/gpu/gpu.c +++ b/src/detection/gpu/gpu.c @@ -84,7 +84,7 @@ const char* detectByOpenGL(FFlist* gpus) { ffStrbufInit(&result.slv); ffStrbufInit(&result.library); - __attribute__((__cleanup__(ffDestroyOpenGLOptions))) FFOpenGLOptions options; + FF_A_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 d45e00a21..f396def1d 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_MAYBE_UNUSED static const char* ffAdlStatusToString(int status) { +FF_A_UNUSED static const char* ffAdlStatusToString(int status) { switch (status) { #define FF_ADL_STATUS_CASE(name) \ case name: \ @@ -41,7 +41,7 @@ FF_MAYBE_UNUSED static const char* ffAdlStatusToString(int status) { } // Memory allocation function -static void* __attribute__((__stdcall__)) ffAdlMainMemoryAlloc(int iSize) { +static void* __stdcall ffAdlMainMemoryAlloc(int iSize) { return malloc((size_t) iSize); } diff --git a/src/detection/gpu/gpu_driver_specific.h b/src/detection/gpu/gpu_driver_specific.h index 074a2c6f9..995744238 100644 --- a/src/detection/gpu/gpu_driver_specific.h +++ b/src/detection/gpu/gpu_driver_specific.h @@ -2,7 +2,7 @@ #include "gpu.h" -typedef enum __attribute__((__packed__)) FFGpuDriverConditionType { +typedef enum FF_A_PACKED FFGpuDriverConditionType { FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID = 1 << 0, FF_GPU_DRIVER_CONDITION_TYPE_DEVICE_ID = 1 << 1, FF_GPU_DRIVER_CONDITION_TYPE_LUID = 1 << 2, @@ -47,7 +47,7 @@ const char* ffDetectMthreadsGpuInfo(const FFGpuDriverCondition* cond, FFGpuDrive # define FF_GPU_DRIVER_DLLNAME_PATH_PREFIX #endif -FF_MAYBE_UNUSED static inline bool getDriverSpecificDetectionFn(const char* vendor, __typeof__(&ffDetectNvidiaGpuInfo)* pDetectFn, const char** pDllName) { +FF_A_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 91822b90d..f3089a9aa 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_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl(FF_A_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 de4f3efe4..e4257a105 100644 --- a/src/detection/gpu/gpu_haiku.c +++ b/src/detection/gpu/gpu_haiku.c @@ -3,7 +3,7 @@ #include -const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl(FF_A_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 dae9895f6..dfb595dc9 100644 --- a/src/detection/gpu/gpu_linux.c +++ b/src/detection/gpu/gpu_linux.c @@ -35,7 +35,7 @@ # define FF_HAVE_DRM_ASAHI 1 #endif -static bool pciDetectDriver(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey) { +static bool pciDetectDriver(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer, FF_A_UNUSED const char* drmKey) { uint32_t pciDirLength = pciDir->length; ffStrbufAppendS(pciDir, "/driver"); char pathBuf[PATH_MAX]; @@ -80,7 +80,7 @@ static bool pciDetectDriver(FFstrbuf* result, FFstrbuf* pciDir, FFstrbuf* buffer return true; } -FF_MAYBE_UNUSED static const char* drmFindRenderFromCard(const char* drmCardKey, FFstrbuf* result) { +FF_A_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__ -FF_MAYBE_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const char* name, FF_MAYBE_UNUSED FFstrbuf* buffer, FF_MAYBE_UNUSED const char* drmKey) { +FF_A_UNUSED static const char* drmDetectAsahiSpecific(FFGPUResult* gpu, const char* name, FF_A_UNUSED FFstrbuf* buffer, FF_A_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 aae858c21..0b639f503 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_MAYBE_UNUSED static void shutdownMtml(void) { +FF_A_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 49db29b41..eb90e7be9 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_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl(FF_A_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 9349bcf68..b116580e4 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* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl(FF_A_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 e9842ec93..3ea3fd329 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_MAYBE_UNUSED di_minor_t minor, FFlist* gpus) { +static int walkDevTree(di_node_t node, FF_A_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) { @@ -42,7 +42,7 @@ static int walkDevTree(di_node_t node, FF_MAYBE_UNUSED di_minor_t minor, FFlist* return DI_WALK_CONTINUE; } -const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus) { +const char* ffDetectGPUImpl(FF_A_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 e84963e74..07259d9a4 100644 --- a/src/detection/gpu/gpu_windows.c +++ b/src/detection/gpu/gpu_windows.c @@ -359,7 +359,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_MAYBE_UNUSED const char* error = detectFn( + FF_A_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) | @@ -574,7 +574,7 @@ ffGPUDetectWsl2 #if _WIN32 else if (ffIsWindows10OrGreater()) { const char* ffGPUDetectTypeWithDXCore(LUID adapterLuid, FFGPUResult * gpu); - FF_MAYBE_UNUSED const char* error = ffGPUDetectTypeWithDXCore(adapter->AdapterLuid, gpu); + FF_A_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 79339b0f7..c128e54a4 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_MAYBE_UNUSED void* data, const char* key) { +static bool testXfconfWallpaperPropKey(FF_A_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/gtk_qt/qt.c b/src/detection/gtk_qt/qt.c index 67b787d5e..2e0ed0044 100644 --- a/src/detection/gtk_qt/qt.c +++ b/src/detection/gtk_qt/qt.c @@ -16,7 +16,7 @@ static inline bool allValuesSet(const FFQtResult* result) { result->wallpaper.length > 0; } -typedef enum __attribute__((__packed__)) PlasmaCategory { +typedef enum FF_A_PACKED PlasmaCategory { PLASMA_CATEGORY_GENERAL, PLASMA_CATEGORY_KDE, PLASMA_CATEGORY_ICONS, diff --git a/src/detection/host/host_nosupport.c b/src/detection/host/host_nosupport.c index 0a95f156c..61a725433 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_MAYBE_UNUSED FFHostResult* host) { +const char* ffDetectHost(FF_A_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 42b218423..0f1c34e41 100644 --- a/src/detection/host/host_windows.c +++ b/src/detection/host/host_windows.c @@ -17,13 +17,13 @@ typedef struct FFSmbiosSystemInfo { uint8_t ClockSeqHiAndReserved; uint8_t ClockSeqLow; uint8_t Node[6]; - } __attribute__((__packed__)) UUID; // varies + } FF_A_PACKED UUID; // varies uint8_t WakeUpType; // enum // 2.4+ uint8_t SKUNumber; // string uint8_t Family; // string -} __attribute__((__packed__)) FFSmbiosSystemInfo; +} FF_A_PACKED 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 692dd33fe..ab8cebbc7 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_MAYBE_UNUSED FFIconsResult* result) { +const char* ffDetectIcons(FF_A_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 d8fa3ca9b..cbce56fed 100644 --- a/src/detection/initsystem/initsystem_linux.c +++ b/src/detection/initsystem/initsystem_linux.c @@ -6,7 +6,7 @@ #include #include -FF_MAYBE_UNUSED static bool extractSystemdVersion(const char* str, uint32_t len, void* userdata) { +FF_A_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 431fa4c44..e8ccb8e16 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_MAYBE_UNUSED FFInitSystemResult* result) { +const char* ffDetectInitSystem(FF_A_UNUSED FFInitSystemResult* result) { return "Not supported on this platform"; } diff --git a/src/detection/keyboard/keyboard_nosupport.c b/src/detection/keyboard/keyboard_nosupport.c index 2d6aa024c..6523ed405 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_MAYBE_UNUSED FFlist* devices /* List of FFKeyboardDevice */) { +const char* ffDetectKeyboard(FF_A_UNUSED FFlist* devices /* List of FFKeyboardDevice */) { return "No mouse support on this platform"; } diff --git a/src/detection/lm/lm_linux.c b/src/detection/lm/lm_linux.c index d84e5c3ff..9f00e1cac 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 NULL; } #else -static const char* getSddmVersion(FF_MAYBE_UNUSED FFstrbuf* version) { +static const char* getSddmVersion(FF_A_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 64a71686e..22c180307 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_MAYBE_UNUSED FFLMResult* result) { +const char* ffDetectLM(FF_A_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 d4f6134f7..f14c71795 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_MAYBE_UNUSED double result[3]) { +const char* ffDetectLoadavg(FF_A_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 b4e1aaeb2..997e2ef38 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -980,7 +980,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { #endif #if __sun if (options->showType & FF_LOCALIP_TYPE_SPEED_BIT) { - __attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open(); + FF_A_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 fcc351067..d2311865b 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -67,7 +67,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) { } } - FF_MAYBE_UNUSED int adapterCount = 0, processedCount = 0; + FF_A_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_MAYBE_UNUSED int ipv4Count = 0, ipv6Count = 0; + FF_A_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 93144a5b7..b646ebcc6 100644 --- a/src/detection/media/media_apple.m +++ b/src/detection/media/media_apple.m @@ -8,10 +8,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)) __attribute__((weak_import)); -extern void MRMediaRemoteGetNowPlayingApplicationIsPlaying(dispatch_queue_t queue, void (^callback)(BOOL playing)) __attribute__((weak_import)); -extern void MRMediaRemoteGetNowPlayingApplicationDisplayID(dispatch_queue_t queue, void (^callback)(_Nullable CFStringRef displayID)) __attribute__((weak_import)); -extern void MRMediaRemoteGetNowPlayingApplicationDisplayName(int unknown, dispatch_queue_t queue, void (^callback)(_Nullable CFStringRef name)) __attribute__((weak_import)); +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; static const char* getMediaByMediaRemote(FFMediaResult* result, bool saveCover) { diff --git a/src/detection/memory/memory_nosupport.c b/src/detection/memory/memory_nosupport.c index 8bc534813..b44aaadff 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_MAYBE_UNUSED FFMemoryResult* ram) { +const char* ffDetectMemory(FF_A_UNUSED FFMemoryResult* ram) { return "Not supported on this platform"; } diff --git a/src/detection/mouse/mouse_nosupport.c b/src/detection/mouse/mouse_nosupport.c index d83006c19..aa1332df4 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_MAYBE_UNUSED FFlist* devices /* List of FFMouseDevice */) { +const char* ffDetectMouse(FF_A_UNUSED FFlist* devices /* List of FFMouseDevice */) { return "No mouse support on this platform"; } diff --git a/src/detection/netio/netio_nosupport.c b/src/detection/netio/netio_nosupport.c index fedfd2d5d..30f73a758 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_MAYBE_UNUSED FFlist* result, FF_MAYBE_UNUSED FFNetIOOptions* options) { +const char* ffNetIOGetIoCounters(FF_A_UNUSED FFlist* result, FF_A_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 ef6047ceb..ff32f6d4f 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) { - __attribute__((__cleanup__(kstatFreeWrap))) kstat_ctl_t* kc = kstat_open(); + FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open(); if (!kc) { return "kstat_open() failed"; } diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index b02e252b4..026b6ce00 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -37,7 +37,7 @@ static bool parseOsRelease(const char* fileName, FFOSResult* result) { } // Common logic for detecting Armbian image version -FF_MAYBE_UNUSED static bool detectArmbianVersion(FFOSResult* result) { +FF_A_UNUSED static bool detectArmbianVersion(FFOSResult* result) { // Possible values `PRETTY_NAME` starts with on Armbian: // - `Armbian` for official releases // - `Armbian_community` for community releases @@ -58,7 +58,7 @@ FF_MAYBE_UNUSED static bool detectArmbianVersion(FFOSResult* result) { } // Returns false if PrettyName should be updated by caller -FF_MAYBE_UNUSED static bool getUbuntuFlavour(FFOSResult* result) { +FF_A_UNUSED static bool getUbuntuFlavour(FFOSResult* result) { if (detectArmbianVersion(result)) { return true; } else if (ffStrbufStartsWithS(&result->prettyName, "Linux Lite ")) { @@ -165,7 +165,7 @@ FF_MAYBE_UNUSED static bool getUbuntuFlavour(FFOSResult* result) { return false; } -FF_MAYBE_UNUSED static void getDebianVersion(FFOSResult* result) { +FF_A_UNUSED static void getDebianVersion(FFOSResult* result) { FF_STRBUF_AUTO_DESTROY debianVersion = ffStrbufCreate(); ffAppendFileBuffer("/etc/debian_version", &debianVersion); ffStrbufTrimRightSpace(&debianVersion); @@ -178,7 +178,7 @@ FF_MAYBE_UNUSED static void getDebianVersion(FFOSResult* result) { ffStrbufSetF(&result->prettyName, "%s %s (%s)", result->name.chars, result->versionID.chars, result->codename.chars); } -FF_MAYBE_UNUSED static bool detectDebianDerived(FFOSResult* result) { +FF_A_UNUSED static bool detectDebianDerived(FFOSResult* result) { if (detectArmbianVersion(result)) { return true; } else if (ffStrbufStartsWithS(&result->name, "Loc-OS")) { @@ -272,7 +272,7 @@ FF_MAYBE_UNUSED static bool detectDebianDerived(FFOSResult* result) { return false; } -FF_MAYBE_UNUSED static bool detectFedoraVariant(FFOSResult* result) { +FF_A_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); diff --git a/src/detection/packages/packages_nosupport.c b/src/detection/packages/packages_nosupport.c index c0984db8f..40300fab3 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_MAYBE_UNUSED FFPackagesResult* result, FF_MAYBE_UNUSED FFPackagesOptions* options) { +void ffDetectPackagesImpl(FF_A_UNUSED FFPackagesResult* result, FF_A_UNUSED FFPackagesOptions* options) { } diff --git a/src/detection/packages/packages_windows.c b/src/detection/packages/packages_windows.c index 7e7ff710a..4023a92e0 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 = NULL; - yyjson_doc* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_file(scoopPath.chars, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_file(scoopPath.chars, 0, NULL, NULL); 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_MAYBE_UNUSED FFPackagesResult* result) { +static void detectChoco(FF_A_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 d9bda6aa4..3314eb6c5 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 - __attribute__((__cleanup__(wrapIoDestroyPlugInInterface))) IOCFPlugInInterface** pluginInf = NULL; + FF_A_CLEANUP(wrapIoDestroyPlugInInterface) IOCFPlugInInterface** pluginInf = NULL; 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 e922f8ab4..26e0ce881 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_MAYBE_UNUSED FFlist* result, FF_MAYBE_UNUSED FFPhysicalDiskOptions* options) { +const char* ffDetectPhysicalDisk(FF_A_UNUSED FFlist* result, FF_A_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 dfb857e05..c674c6b9d 100644 --- a/src/detection/physicaldisk/physicaldisk_windows.c +++ b/src/detection/physicaldisk/physicaldisk_windows.c @@ -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_MAYBE_UNUSED const char* error = detectPhysicalDisk(type, p, result, options); + FF_A_UNUSED const char* error = detectPhysicalDisk(type, p, result, options); if (error == NULL) { 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 3300fa926..36eab6d36 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 NULL; } -FF_MAYBE_UNUSED static const char* detectFromIokit(FFlist* result) +FF_A_UNUSED static const char* detectFromIokit(FFlist* result) { FF_IOOBJECT_AUTO_RELEASE io_registry_entry_t entryDevice = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen"); if (!entryDevice) diff --git a/src/detection/physicalmemory/physicalmemory_linux.c b/src/detection/physicalmemory/physicalmemory_linux.c index a032165c5..085608248 100644 --- a/src/detection/physicalmemory/physicalmemory_linux.c +++ b/src/detection/physicalmemory/physicalmemory_linux.c @@ -59,7 +59,7 @@ typedef struct FFSmbiosMemoryDevice { uint16_t Pmic0RevisionNumber; // varies uint16_t RcdManufacturerID; // varies uint16_t RcdRevisionNumber; // varies -} __attribute__((__packed__)) FFSmbiosMemoryDevice; +} FF_A_PACKED FFSmbiosMemoryDevice; static_assert(offsetof(FFSmbiosMemoryDevice, RcdRevisionNumber) == 0x62, "FFSmbiosMemoryDevice: Wrong struct alignment"); diff --git a/src/detection/physicalmemory/physicalmemory_nosupport.c b/src/detection/physicalmemory/physicalmemory_nosupport.c index 998c602c3..eb0ae221d 100644 --- a/src/detection/physicalmemory/physicalmemory_nosupport.c +++ b/src/detection/physicalmemory/physicalmemory_nosupport.c @@ -1,5 +1,5 @@ #include "physicalmemory.h" -const char* ffDetectPhysicalMemory(FF_MAYBE_UNUSED FFlist* result) { +const char* ffDetectPhysicalMemory(FF_A_UNUSED FFlist* result) { return "Not supported on this platform"; } diff --git a/src/detection/poweradapter/poweradapter_nosupport.c b/src/detection/poweradapter/poweradapter_nosupport.c index 4458d1e8a..d5e725bf4 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_MAYBE_UNUSED FFlist* results) { +const char* ffDetectPowerAdapter(FF_A_UNUSED FFlist* results) { return "Not supported on this platform"; } diff --git a/src/detection/publicip/publicip.c b/src/detection/publicip/publicip.c index 4dc56bd66..aa93c99ed 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* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(response.chars, response.length, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(response.chars, response.length, 0, NULL, NULL); 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_linux.c b/src/detection/sound/sound_linux.c index 73cfe29c4..73a5128df 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -23,7 +23,7 @@ static void paSinkInfoCallback(pa_context* c, const pa_sink_info* i, int eol, vo device->main = false; } -static void paServerInfoCallback(FF_MAYBE_UNUSED pa_context* c, const pa_server_info* i, void* userdata) { +static void paServerInfoCallback(FF_A_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 c48b66531..b67236082 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_MAYBE_UNUSED FFlist* devices /* List of FFSoundDevice */) { +const char* ffDetectSound(FF_A_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 653faee07..cedfe5f30 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(FFlist* devices) { - __attribute__((__cleanup__(close_hdl))) struct sioctl_hdl* hdl = sioctl_open(SIO_DEVANY, SIOCTL_READ, 0); + FF_A_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 f2d6c372a..0ae1ed0eb 100644 --- a/src/detection/sound/sound_windows.cpp +++ b/src/detection/sound/sound_windows.cpp @@ -17,7 +17,7 @@ static void ffCoTaskMemFreeWrapper(void* pptr) { CoTaskMemFree(ptr); } } -#define FF_COTASK_AUTO_FREE __attribute__((__cleanup__(ffCoTaskMemFreeWrapper))) +#define FF_COTASK_AUTO_FREE FF_A_CLEANUP(ffCoTaskMemFreeWrapper) const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) { const char* error = ffInitCom(); diff --git a/src/detection/terminalfont/terminalfont.c b/src/detection/terminalfont/terminalfont.c index ffde5f51d..c62b5cc42 100644 --- a/src/detection/terminalfont/terminalfont.c +++ b/src/detection/terminalfont/terminalfont.c @@ -136,7 +136,7 @@ static void detectGhostty(const FFstrbuf* exe, FFTerminalFontResult* terminalFon FF_DEBUG("detectGhostty: end"); } -FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) { +FF_A_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) { FF_STRBUF_AUTO_DESTROY fontName = ffStrbufCreate(); ffParsePropFile(FASTFETCH_TARGET_DIR_ETC "/vconsole.conf", "Font =", &fontName); @@ -155,7 +155,7 @@ FF_MAYBE_UNUSED static void detectTTY(FFTerminalFontResult* terminalFont) { } } -FF_MAYBE_UNUSED static bool detectKitty(const FFstrbuf* exe, FFTerminalFontResult* result) { +FF_A_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 ebc0f6e91..8dd1533dc 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_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractStTermFont(const char* str, FF_A_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 5662b5f6b..a23b8938b 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* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, NULL, NULL); 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 1f5d2169c..04320a7e9 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -48,7 +48,7 @@ static bool getExeVersionGeneral(FFstrbuf* exe, FFstrbuf* version) { return true; } -static bool extractBashVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractBashVersion(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { if (!ffStrStartsWith(line, "@(#)Bash version ")) { return true; } @@ -178,7 +178,7 @@ static bool getShellVersionAsh(FFstrbuf* exe, FFstrbuf* version) { return true; } -static bool getShellVersionXonsh(FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { +static bool getShellVersionXonsh(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { ffStrbufSetS(version, getenv("XONSH_VERSION")); if (version->length) { return true; @@ -194,7 +194,7 @@ static bool getShellVersionXonsh(FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* versio return true; } -static bool extractZshVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractZshVersion(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { if (!ffStrStartsWith(line, "zsh-")) { return true; } @@ -289,12 +289,12 @@ bool fftsGetShellVersion(FFstrbuf* exe, const char* exeName, FFstrbuf* version) return false; } -FF_MAYBE_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version) { ffStrbufSetS(version, getenv("TERMUX_VERSION")); return version->length > 0; } -static bool extractGeneralVersion(const char* str, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractGeneralVersion(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { if (!ffCharIsDigit(str[0])) { return true; } @@ -307,7 +307,7 @@ static bool extractGeneralVersion(const char* str, FF_MAYBE_UNUSED uint32_t len, return false; } -FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* version) { +FF_A_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) { @@ -325,7 +325,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* ver return true; } -FF_MAYBE_UNUSED static bool getTerminalVersionXfce4Terminal(FFstrbuf* exe, FFstrbuf* version) { +FF_A_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) { @@ -336,7 +336,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionXfce4Terminal(FFstrbuf* exe, FFstr return getExeVersionGeneral(exe, version); // xfce4-terminal 1.0.4 (Xfce 4.18)... } -FF_MAYBE_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version) { if (ffProcessAppendStdOut(version, (char* const[]) { "kgx", "--version", NULL })) { return false; } @@ -347,7 +347,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version) { return true; } -FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* version) { const char* konsoleVersion = getenv("KONSOLE_VERSION"); if (konsoleVersion) { // 221201 @@ -365,7 +365,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionKonsole(FFstrbuf* exe, FFstrbuf* v return getExeVersionGeneral(exe, version); } -FF_MAYBE_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* version) { +FF_A_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) == NULL) { ffStrbufSetF(version, "%u.%u.%u", major, minor, patch); @@ -382,7 +382,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionFoot(FFstrbuf* exe, FFstrbuf* vers return true; } -FF_MAYBE_UNUSED static bool getTerminalVersionMateTerminal(FFstrbuf* exe, FFstrbuf* version) { +FF_A_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; @@ -397,7 +397,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionMateTerminal(FFstrbuf* exe, FFstrb return version->length > 0; } -FF_MAYBE_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* version) { if (!getExeVersionRaw(exe, version)) { return false; } @@ -408,7 +408,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionCockpit(FFstrbuf* exe, FFstrbuf* v return version->length > 0; } -FF_MAYBE_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* version) { ffStrbufSetS(version, getenv("XTERM_VERSION")); if (!version->length) { if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-v", NULL })) { @@ -422,7 +422,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* ver return version->length > 0; } -FF_MAYBE_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL })) { return false; } @@ -433,7 +433,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionBlackbox(FFstrbuf* exe, FFstrbuf* return version->length > 0; } -FF_MAYBE_UNUSED static bool getTerminalVersionUrxvt(FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionUrxvt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdErr(version, (char* const[]) { "urxvt", // Don't use exe because of urxvtd "-invalid", NULL })) { @@ -448,7 +448,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionUrxvt(FF_MAYBE_UNUSED FFstrbuf* ex return version->length > 0; } -FF_MAYBE_UNUSED static bool getTerminalVersionSt(FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionSt(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "-v", NULL })) { return false; } @@ -459,7 +459,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionSt(FF_MAYBE_UNUSED FFstrbuf* exe, return version->length > 0; } -FF_MAYBE_UNUSED static bool getTerminalVersionLxterminal(FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionLxterminal(FFstrbuf* exe, FFstrbuf* version) { if (!getExeVersionRaw(exe, version)) { return false; } @@ -468,7 +468,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionLxterminal(FFstrbuf* exe, FFstrbuf return version->length > 0; } -FF_MAYBE_UNUSED static bool getTerminalVersionWeston(FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionWeston(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { // weston-terminal doesn't report a version, use weston version instead if (ffProcessAppendStdOut(version, (char* const[]) { "weston", "--version", NULL })) { return false; @@ -543,7 +543,7 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version) { return true; } -static bool extractSshdVersion(const char* str, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractSshdVersion(const char* str, FF_A_UNUSED uint32_t len, void* userdata) { if (!ffStrStartsWith(str, "OpenSSH_") || !ffCharIsDigit(str[strlen("OpenSSH_")])) { return true; } @@ -658,7 +658,7 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) { return getExeVersionGeneral(exe, version); } -FF_MAYBE_UNUSED static bool getTerminalVersionPtyxis(FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionPtyxis(FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdOut(version, (char* const[]) { "ptyxis", "--version", NULL }) != NULL) { return false; } @@ -668,7 +668,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionPtyxis(FF_MAYBE_UNUSED FFstrbuf* e return true; } -FF_MAYBE_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* version) { +FF_A_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) { @@ -693,7 +693,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionTilix(FFstrbuf* exe, FFstrbuf* ver return true; } -FF_MAYBE_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) { // sakura version is 3.8.8 return false; } @@ -702,7 +702,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionSakura(FFstrbuf* exe, FFstrbuf* ve return true; } -FF_MAYBE_UNUSED static bool getTerminalVersionTermite(FFstrbuf* exe, FFstrbuf* version) { +FF_A_UNUSED static bool getTerminalVersionTermite(FFstrbuf* exe, FFstrbuf* version) { if (ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "--version", NULL }) != NULL) { // termite v16.9\nvte 0.78.1 +BIDI +GNUTLS +ICU +SYSTEMD return false; } @@ -740,7 +740,7 @@ static bool getTerminalVersionConEmu(FFstrbuf* exe, FFstrbuf* version) { #endif -bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) { +bool fftsGetTerminalVersion(FFstrbuf* processName, FF_A_UNUSED FFstrbuf* exe, FFstrbuf* version) { if (!instance.config.general.detectVersion) { return false; } diff --git a/src/detection/theme/theme_nosupport.c b/src/detection/theme/theme_nosupport.c index 2eeacc9a0..6f42b964d 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_MAYBE_UNUSED FFThemeResult* result) { +const char* ffDetectTheme(FF_A_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 3dfb4ab04..492f37f75 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_MAYBE_UNUSED FFTPMResult* result) { +const char* ffDetectTPM(FF_A_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 4436cada3..6606d9415 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_MAYBE_UNUSED FFUserResult* user, FF_MAYBE_UNUSED struct utmpx* n) { +static void fillUtmpIpAddr(FF_A_UNUSED FFUserResult* user, FF_A_UNUSED struct utmpx* n) { } #endif diff --git a/src/detection/users/users_obsd.c b/src/detection/users/users_obsd.c index e573e8542..4c957a57f 100644 --- a/src/detection/users/users_obsd.c +++ b/src/detection/users/users_obsd.c @@ -4,7 +4,7 @@ #include -const char* ffDetectUsers(FF_MAYBE_UNUSED FFUsersOptions* options, FFlist* users) { +const char* ffDetectUsers(FF_A_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 ce4f73d21..9be8e9183 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_MAYBE_UNUSED FFstrbuf* result) { - return "Not supported on this platform"; -} +#include "wallpaper.h" + +const char* ffDetectWallpaper(FF_A_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 37c68a63d..cdcc1eb09 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* __attribute__((__cleanup__(wrapYyjsonFree))) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); + yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL); if (!doc) { return "Failed to parse wifi connection info"; } diff --git a/src/detection/wifi/wifi_linux.c b/src/detection/wifi/wifi_linux.c index 5757589ad..4181d0cdb 100644 --- a/src/detection/wifi/wifi_linux.c +++ b/src/detection/wifi/wifi_linux.c @@ -456,7 +456,7 @@ static const char* detectWifiWithIoctls(FFWifiResult* item) { } #endif // FF_HAVE_LINUX_WIRELESS -const char* ffDetectWifi(FF_MAYBE_UNUSED FFlist* result) { +const char* ffDetectWifi(FF_A_UNUSED FFlist* result) { FF_DEBUG("Starting wifi detection"); struct if_nameindex* infs = if_nameindex(); if (!infs) { diff --git a/src/detection/wifi/wifi_nosupport.c b/src/detection/wifi/wifi_nosupport.c index d3ebd4d14..bb4a806ea 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_MAYBE_UNUSED FFlist* result) { +const char* ffDetectWifi(FF_A_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 42fb8f230..f9865bef2 100644 --- a/src/detection/wm/wm_apple.m +++ b/src/detection/wm/wm_apple.m @@ -86,7 +86,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) return NULL; } -const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_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 646da5cdd..03adbc74d 100644 --- a/src/detection/wm/wm_linux.c +++ b/src/detection/wm/wm_linux.c @@ -8,11 +8,11 @@ #include "common/debug.h" #include "detection/displayserver/displayserver.h" -const char* ffDetectWMPlugin(FF_MAYBE_UNUSED FFstrbuf* pluginName) { +const char* ffDetectWMPlugin(FF_A_UNUSED FFstrbuf* pluginName) { return "Not supported on this platform"; } -static bool extractCommonWmVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractCommonWmVersion(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { int count = 0; sscanf(line, "%*d.%*d.%*d%n", &count); if (count == 0) { @@ -98,7 +98,7 @@ static const char* getHyprland(FFstrbuf* result) { return "Failed to run command `Hyprland --version`"; } -static bool extractSwayVersion(const char* line, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractSwayVersion(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { if (!ffStrStartsWith(line, "sway version ")) { return true; } @@ -182,7 +182,7 @@ static const char* getWslg(FFstrbuf* result) { #endif // !__ANDROID__ -static bool extractI3Version(const char* line, FF_MAYBE_UNUSED uint32_t len, void* userdata) { +static bool extractI3Version(const char* line, FF_A_UNUSED uint32_t len, void* userdata) { int count = 0; sscanf(line, "%*d.%*d%n", &count); if (count == 0) { @@ -277,7 +277,7 @@ static const char* getOpenbox(FFstrbuf* result) { return "Failed to run command `openbox --version`"; } -const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) { +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_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 8d9f1bb84..65c53489b 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_MAYBE_UNUSED FFstrbuf* pluginName) { +const char* ffDetectWMPlugin(FF_A_UNUSED FFstrbuf* pluginName) { return "Not supported on this platform"; } -const char* ffDetectWMVersion(FF_MAYBE_UNUSED const FFstrbuf* wmName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) { +const char* ffDetectWMVersion(FF_A_UNUSED const FFstrbuf* wmName, FF_A_UNUSED FFstrbuf* result, FF_A_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 5bf64440e..ee363995b 100644 --- a/src/detection/wm/wm_windows.c +++ b/src/detection/wm/wm_windows.c @@ -184,7 +184,7 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) { return NULL; } -const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_MAYBE_UNUSED FFWMOptions* options) { +const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, FF_A_UNUSED FFWMOptions* options) { if (!wmName) { return "No WM detected"; } diff --git a/src/detection/zpool/zpool.c b/src/detection/zpool/zpool.c index dfd5f9a04..0780a0941 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"; } - __attribute__((__cleanup__(cleanLibzfs))) FFZfsData data = { + FF_A_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_MAYBE_UNUSED FFlist* result) { +const char* ffDetectZpool(FF_A_UNUSED FFlist* result) { return "fastfetch was compiled without libzfs support"; } diff --git a/src/fastfetch.h b/src/fastfetch.h index 91609c7b5..7e79dc302 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -5,10 +5,6 @@ #include #include -#ifdef _MSC_VER -# define __attribute__(x) -#endif - #include "common/arrayUtils.h" #include "common/FFstrbuf.h" #include "common/FFlist.h" diff --git a/src/flashfetch.c b/src/flashfetch.c index 75ffe7cbd..a41b2e387 100644 --- a/src/flashfetch.c +++ b/src/flashfetch.c @@ -5,7 +5,7 @@ #include "modules/modules.h" #define MODULE_OPTION(name) \ - __attribute__((cleanup(ffDestroy##name##Options))) FF##name##Options options; \ + FF_A_CLEANUP(ffDestroy##name##Options) FF##name##Options options; \ ffInit##name##Options(&options); // A dirty replicate of neofetch; demonstration only. diff --git a/src/logo/image/image.h b/src/logo/image/image.h index 3b00695eb..2fcb40a55 100644 --- a/src/logo/image/image.h +++ b/src/logo/image/image.h @@ -4,7 +4,7 @@ #if defined(FF_HAVE_IMAGEMAGICK7) || defined(FF_HAVE_IMAGEMAGICK6) -typedef enum __attribute__((__packed__)) FFLogoImageResult { +typedef enum FF_A_PACKED FFLogoImageResult { FF_LOGO_IMAGE_RESULT_SUCCESS, // Logo printed FF_LOGO_IMAGE_RESULT_INIT_ERROR, // Failed to load library, try again with next IM version FF_LOGO_IMAGE_RESULT_RUN_ERROR // Failed to load / convert image, cancel whole sixel code diff --git a/src/logo/logo.h b/src/logo/logo.h index 193c76d7f..94c9c59e6 100644 --- a/src/logo/logo.h +++ b/src/logo/logo.h @@ -2,14 +2,14 @@ #include "fastfetch.h" -typedef enum __attribute__((__packed__)) FFLogoLineType { +typedef enum FF_A_PACKED FFLogoLineType { FF_LOGO_LINE_TYPE_NORMAL = 0, FF_LOGO_LINE_TYPE_SMALL_BIT = 1 << 0, // The names of small logo must end with `_small` or `-small` FF_LOGO_LINE_TYPE_ALTER_BIT = 1 << 1, FF_LOGO_LINE_TYPE_FORCE_UNSIGNED = UINT8_MAX, } FFLogoLineType; -typedef enum __attribute__((__packed__)) FFLogoSize { +typedef enum FF_A_PACKED FFLogoSize { FF_LOGO_SIZE_UNKNOWN, FF_LOGO_SIZE_NORMAL, FF_LOGO_SIZE_SMALL, diff --git a/src/modules/bios/bios.c b/src/modules/bios/bios.c index e7f1e32c3..1dbcac8dc 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_MAYBE_UNUSED FFBiosOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBiosJsonResult(FF_A_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 ca32c79b4..c5668e892 100644 --- a/src/modules/bluetoothradio/bluetoothradio.c +++ b/src/modules/bluetoothradio/bluetoothradio.c @@ -139,7 +139,7 @@ void ffGenerateBluetoothRadioJsonConfig(FFBluetoothRadioOptions* options, yyjson ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateBluetoothRadioJsonResult(FF_MAYBE_UNUSED FFBluetoothRadioOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBluetoothRadioJsonResult(FF_A_UNUSED FFBluetoothRadioOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFBluetoothRadioResult)); const char* error = ffDetectBluetoothRadio(&results); diff --git a/src/modules/board/board.c b/src/modules/board/board.c index 2821eb94e..d7b043aea 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_MAYBE_UNUSED FFBoardOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBoardJsonResult(FF_A_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 5247a1df8..0cab6df21 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_MAYBE_UNUSED FFBootmgrOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBootmgrJsonResult(FF_A_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 183509e31..acacbbb5f 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_MAYBE_UNUSED FFBreakOptions* options) { +bool ffPrintBreak(FF_A_UNUSED FFBreakOptions* options) { ffLogoPrintLine(); putchar('\n'); return true; } -void ffParseBreakJsonObject(FF_MAYBE_UNUSED FFBreakOptions* options, FF_MAYBE_UNUSED yyjson_val* module) { +void ffParseBreakJsonObject(FF_A_UNUSED FFBreakOptions* options, FF_A_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_MAYBE_UNUSED FFBreakOptions* options, FF_MAYBE_UN } } -void ffInitBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options) { +void ffInitBreakOptions(FF_A_UNUSED FFBreakOptions* options) { } -void ffDestroyBreakOptions(FF_MAYBE_UNUSED FFBreakOptions* options) { +void ffDestroyBreakOptions(FF_A_UNUSED FFBreakOptions* options) { } FFModuleBaseInfo ffBreakModuleInfo = { diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index e7486faac..3ed12607f 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -140,7 +140,7 @@ void ffGenerateBrightnessJsonConfig(FFBrightnessOptions* options, yyjson_mut_doc yyjson_mut_obj_add_bool(doc, module, "compact", options->compact); } -bool ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBrightnessJsonResult(FF_A_UNUSED FFBrightnessOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFBrightnessResult)); const char* error = ffDetectBrightness(options, &result); diff --git a/src/modules/btrfs/btrfs.c b/src/modules/btrfs/btrfs.c index 8b52cc5a5..8498b6dff 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_MAYBE_UNUSED FFBtrfsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateBtrfsJsonResult(FF_A_UNUSED FFBtrfsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFBtrfsResult)); const char* error = ffDetectBtrfs(&results); diff --git a/src/modules/camera/camera.c b/src/modules/camera/camera.c index fd29c1626..0df33685e 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_MAYBE_UNUSED FFCameraOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateCameraJsonResult(FF_A_UNUSED FFCameraOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFCameraResult)); const char* error = ffDetectCamera(&result); diff --git a/src/modules/chassis/chassis.c b/src/modules/chassis/chassis.c index 79285a862..f7d5415fc 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_MAYBE_UNUSED FFChassisOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateChassisJsonResult(FF_A_UNUSED FFChassisOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFChassisResult result; ffStrbufInit(&result.type); diff --git a/src/modules/colors/option.h b/src/modules/colors/option.h index ea366716e..c9971c71d 100644 --- a/src/modules/colors/option.h +++ b/src/modules/colors/option.h @@ -2,7 +2,7 @@ #include "common/option.h" -typedef enum __attribute__((__packed__)) FFColorsSymbol { +typedef enum FF_A_PACKED FFColorsSymbol { FF_COLORS_SYMBOL_BLOCK, FF_COLORS_SYMBOL_BACKGROUND, FF_COLORS_SYMBOL_CIRCLE, @@ -17,7 +17,7 @@ typedef struct FFBlockConfig { uint8_t range[2]; } FFBlockConfig; -typedef enum __attribute__((__packed__)) FFColorsBrightness { +typedef enum FF_A_PACKED FFColorsBrightness { FF_COLORS_BRIGHTNESS_DEFAULT, FF_COLORS_BRIGHTNESS_NORMAL, FF_COLORS_BRIGHTNESS_LIGHT, diff --git a/src/modules/command/command.c b/src/modules/command/command.c index 3641daab5..989091117 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_MAYBE_UNUSED FFCommandOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateCommandJsonResult(FF_A_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 fcfa87db9..6f9f9bea1 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_MAYBE_UNUSED FFCPUCacheOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateCPUCacheJsonResult(FF_A_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 344483453..e99a9b612 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_MAYBE_UNUSED FFCursorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateCursorJsonResult(FF_A_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 5a1f21fb9..6d4a287b6 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -130,7 +130,7 @@ void ffGenerateDateTimeJsonConfig(FFDateTimeOptions* options, yyjson_mut_doc* do ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateDateTimeJsonResult(FF_MAYBE_UNUSED FFDateTimeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateDateTimeJsonResult(FF_A_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 2738571c9..e3b50ac81 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_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateDEJsonResult(FF_A_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/disk/option.h b/src/modules/disk/option.h index e978897d3..b639db21e 100644 --- a/src/modules/disk/option.h +++ b/src/modules/disk/option.h @@ -3,7 +3,7 @@ #include "common/option.h" #include "common/percent.h" -typedef enum __attribute__((__packed__)) FFDiskVolumeType { +typedef enum FF_A_PACKED FFDiskVolumeType { FF_DISK_VOLUME_TYPE_NONE = 0, FF_DISK_VOLUME_TYPE_REGULAR_BIT = 1 << 0, FF_DISK_VOLUME_TYPE_HIDDEN_BIT = 1 << 1, @@ -14,7 +14,7 @@ typedef enum __attribute__((__packed__)) FFDiskVolumeType { FF_DISK_VOLUME_TYPE_FORCE_UNSIGNED = UINT8_MAX, } FFDiskVolumeType; -typedef enum __attribute__((__packed__)) FFDiskCalcType { +typedef enum FF_A_PACKED FFDiskCalcType { FF_DISK_CALC_TYPE_FREE, FF_DISK_CALC_TYPE_AVAILABLE, } FFDiskCalcType; diff --git a/src/modules/display/display.c b/src/modules/display/display.c index 7e22f08f2..582555874 100644 --- a/src/modules/display/display.c +++ b/src/modules/display/display.c @@ -302,7 +302,7 @@ void ffGenerateDisplayJsonConfig(FFDisplayOptions* options, yyjson_mut_doc* doc, } } -bool ffGenerateDisplayJsonResult(FF_MAYBE_UNUSED FFDisplayOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateDisplayJsonResult(FF_A_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/display/option.h b/src/modules/display/option.h index a1601ba1b..1ae73a406 100644 --- a/src/modules/display/option.h +++ b/src/modules/display/option.h @@ -2,7 +2,7 @@ #include "common/option.h" -typedef enum __attribute__((__packed__)) FFDisplayCompactType { +typedef enum FF_A_PACKED FFDisplayCompactType { FF_DISPLAY_COMPACT_TYPE_NONE = 0, FF_DISPLAY_COMPACT_TYPE_ORIGINAL_BIT = 1 << 0, FF_DISPLAY_COMPACT_TYPE_SCALED_BIT = 1 << 1, @@ -10,7 +10,7 @@ typedef enum __attribute__((__packed__)) FFDisplayCompactType { FF_DISPLAY_COMPACT_TYPE_UNSIGNED = UINT8_MAX, } FFDisplayCompactType; -typedef enum __attribute__((__packed__)) FFDisplayOrder { +typedef enum FF_A_PACKED FFDisplayOrder { FF_DISPLAY_ORDER_NONE, FF_DISPLAY_ORDER_ASC, FF_DISPLAY_ORDER_DESC, diff --git a/src/modules/dns/option.h b/src/modules/dns/option.h index 6747428ba..e20bbece7 100644 --- a/src/modules/dns/option.h +++ b/src/modules/dns/option.h @@ -2,7 +2,7 @@ #include "common/option.h" -typedef enum __attribute__((__packed__)) FFDNSShowType { +typedef enum FF_A_PACKED FFDNSShowType { FF_DNS_TYPE_IPV4_BIT = 1, FF_DNS_TYPE_IPV6_BIT = 2, FF_DNS_TYPE_BOTH = FF_DNS_TYPE_IPV4_BIT | FF_DNS_TYPE_IPV6_BIT, diff --git a/src/modules/editor/editor.c b/src/modules/editor/editor.c index 150850c65..f98f4936e 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_MAYBE_UNUSED FFEditorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateEditorJsonResult(FF_A_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 38807071e..6994c693e 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_MAYBE_UNUSED FFFontOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateFontJsonResult(FF_A_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 7054a7586..8a8f37e35 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_MAYBE_UNUSED FFGamepadOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateGamepadJsonResult(FF_A_UNUSED FFGamepadOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFGamepadDevice)); const char* error = ffDetectGamepad(&result); diff --git a/src/modules/gpu/option.h b/src/modules/gpu/option.h index 720a525da..7ec0df33e 100644 --- a/src/modules/gpu/option.h +++ b/src/modules/gpu/option.h @@ -3,14 +3,14 @@ #include "common/option.h" #include "common/percent.h" -typedef enum __attribute__((__packed__)) FFGPUType { +typedef enum FF_A_PACKED FFGPUType { FF_GPU_TYPE_NONE, // Indicates no specific GPU type. Useful as a hide filter only. FF_GPU_TYPE_UNKNOWN, // Indicates an unknown or unrecognized GPU type. FF_GPU_TYPE_INTEGRATED, FF_GPU_TYPE_DISCRETE, } FFGPUType; -typedef enum __attribute__((__packed__)) FFGPUDetectionMethod { +typedef enum FF_A_PACKED FFGPUDetectionMethod { FF_GPU_DETECTION_METHOD_AUTO, FF_GPU_DETECTION_METHOD_PCI, FF_GPU_DETECTION_METHOD_VULKAN, diff --git a/src/modules/host/host.c b/src/modules/host/host.c index c4401e817..067a2e19a 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_MAYBE_UNUSED FFHostOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateHostJsonResult(FF_A_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 b2c73a13e..af73954f9 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_MAYBE_UNUSED FFIconsOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateIconsJsonResult(FF_A_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 b65a23473..957dafeda 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_MAYBE_UNUSED FFInitSystemOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateInitSystemJsonResult(FF_A_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 11ed9eadf..102c45469 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_MAYBE_UNUSED FFKernelOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateKernelJsonResult(FF_A_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 5f14bf389..524b3469e 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_MAYBE_UNUSED FFKeyboardOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateKeyboardJsonResult(FF_A_UNUSED FFKeyboardOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFKeyboardDevice)); const char* error = ffDetectKeyboard(&result); diff --git a/src/modules/lm/lm.c b/src/modules/lm/lm.c index a6ef04eea..40f252221 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_MAYBE_UNUSED FFLMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLMJsonResult(FF_A_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 6ed1bc36c..d384eaaf2 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_MAYBE_UNUSED FFLoadavgOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLoadavgJsonResult(FF_A_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 e3ae4e66e..ef97acf58 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_MAYBE_UNUSED FFLocaleOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLocaleJsonResult(FF_A_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 b903a3ec1..012b754fc 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_MAYBE_UNUSED FFLocalIpOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLocalIpJsonResult(FF_A_UNUSED FFLocalIpOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFLocalIpResult)); const char* error = ffDetectLocalIps(options, &results); diff --git a/src/modules/localip/option.h b/src/modules/localip/option.h index e220b0e73..0eae2478b 100644 --- a/src/modules/localip/option.h +++ b/src/modules/localip/option.h @@ -2,7 +2,7 @@ #include "common/option.h" -typedef enum __attribute__((__packed__)) FFLocalIpType { +typedef enum FF_A_PACKED FFLocalIpType { FF_LOCALIP_TYPE_NONE, FF_LOCALIP_TYPE_LOOP_BIT = 1 << 0, FF_LOCALIP_TYPE_IPV4_BIT = 1 << 1, @@ -20,7 +20,7 @@ typedef enum __attribute__((__packed__)) FFLocalIpType { } FFLocalIpType; static_assert(sizeof(FFLocalIpType) == sizeof(uint16_t), ""); -typedef enum __attribute__((__packed__)) FFLocalIpIpv6Type { +typedef enum FF_A_PACKED FFLocalIpIpv6Type { FF_LOCALIP_IPV6_TYPE_NONE = 0b00000000, FF_LOCALIP_IPV6_TYPE_GUA_BIT = 0b00000001, FF_LOCALIP_IPV6_TYPE_ULA_BIT = 0b00000010, diff --git a/src/modules/logo/logo.c b/src/modules/logo/logo.c index e71e47aa2..54a0f97d6 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_MAYBE_UNUSED FFLogoOptions* options) { +bool ffPrintLogo(FF_A_UNUSED FFLogoOptions* options) { ffPrintError(FF_LOGO_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_DEFAULT, "Supported in JSON format only"); return false; } -void ffParseLogoJsonObject(FF_MAYBE_UNUSED FFLogoOptions* options, FF_MAYBE_UNUSED yyjson_val* module) { +void ffParseLogoJsonObject(FF_A_UNUSED FFLogoOptions* options, FF_A_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_MAYBE_UNUSED FFLogoOptions* options, FF_MAYBE_UNUS } } -bool ffGenerateLogoJsonResult(FF_MAYBE_UNUSED FFLogoOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateLogoJsonResult(FF_A_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_MAYBE_UNUSED FFLogoOptions* options, yyjson_mut return true; } -void ffInitLogoOptions(FF_MAYBE_UNUSED FFLogoOptions* options) { +void ffInitLogoOptions(FF_A_UNUSED FFLogoOptions* options) { } -void ffDestroyLogoOptions(FF_MAYBE_UNUSED FFLogoOptions* options) { +void ffDestroyLogoOptions(FF_A_UNUSED FFLogoOptions* options) { } FFModuleBaseInfo ffLogoModuleInfo = { diff --git a/src/modules/media/media.c b/src/modules/media/media.c index a894cc9dc..825b12cc0 100644 --- a/src/modules/media/media.c +++ b/src/modules/media/media.c @@ -143,7 +143,7 @@ void ffGenerateMediaJsonConfig(FFMediaOptions* options, yyjson_mut_doc* doc, yyj ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateMediaJsonResult(FF_MAYBE_UNUSED FFMediaOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateMediaJsonResult(FF_A_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 058fe01b7..8c72b9424 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_MAYBE_UNUSED FFMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateMemoryJsonResult(FF_A_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 0a293ce30..a88532ecd 100644 --- a/src/modules/monitor/monitor.c +++ b/src/modules/monitor/monitor.c @@ -98,7 +98,7 @@ void ffGenerateMonitorJsonConfig(FFMonitorOptions* options, yyjson_mut_doc* doc, ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); } -bool ffGenerateMonitorJsonResult(FF_MAYBE_UNUSED FFMonitorOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateMonitorJsonResult(FF_A_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 44a3843f0..cbe52475f 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_MAYBE_UNUSED FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateMouseJsonResult(FF_A_UNUSED FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFMouseDevice)); const char* error = ffDetectMouse(&result); diff --git a/src/modules/opencl/opencl.c b/src/modules/opencl/opencl.c index 22fab1258..d94db5e04 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_MAYBE_UNUSED FFOpenCLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateOpenCLJsonResult(FF_A_UNUSED FFOpenCLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFOpenCLResult* result = ffDetectOpenCL(); if (result->error != NULL) { diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 53504485a..06319d50a 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_MAYBE_UNUSED FFOpenGLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateOpenGLJsonResult(FF_A_UNUSED FFOpenGLOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { bool success = false; FFOpenGLResult result; ffStrbufInit(&result.version); diff --git a/src/modules/opengl/option.h b/src/modules/opengl/option.h index e368d67ba..869c6eca8 100644 --- a/src/modules/opengl/option.h +++ b/src/modules/opengl/option.h @@ -2,7 +2,7 @@ #include "common/option.h" -typedef enum __attribute__((__packed__)) FFOpenGLLibrary { +typedef enum FF_A_PACKED FFOpenGLLibrary { FF_OPENGL_LIBRARY_AUTO, FF_OPENGL_LIBRARY_EGL, FF_OPENGL_LIBRARY_GLX, diff --git a/src/modules/os/os.c b/src/modules/os/os.c index 6f4f743ec..bbf976606 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_MAYBE_UNUSED FFOSOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateOSJsonResult(FF_A_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/packages/option.h b/src/modules/packages/option.h index 212ff84e2..3e1b76e1a 100644 --- a/src/modules/packages/option.h +++ b/src/modules/packages/option.h @@ -2,7 +2,7 @@ #include "common/option.h" -typedef enum __attribute__((__packed__)) FFPackagesFlags { +typedef enum FF_A_PACKED FFPackagesFlags { FF_PACKAGES_FLAG_NONE = 0, FF_PACKAGES_FLAG_APK_BIT = 1ULL << 0, FF_PACKAGES_FLAG_BREW_BIT = 1ULL << 1, diff --git a/src/modules/packages/packages.c b/src/modules/packages/packages.c index 6cb92c708..73ea6cd3c 100644 --- a/src/modules/packages/packages.c +++ b/src/modules/packages/packages.c @@ -389,7 +389,7 @@ void ffGeneratePackagesJsonConfig(FFPackagesOptions* options, yyjson_mut_doc* do yyjson_mut_obj_add_bool(doc, module, "combined", options->combined); } -bool ffGeneratePackagesJsonResult(FF_MAYBE_UNUSED FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGeneratePackagesJsonResult(FF_A_UNUSED FFPackagesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FFPackagesResult counts = {}; ffStrbufInit(&counts.pacmanBranch); diff --git a/src/modules/physicaldisk/option.h b/src/modules/physicaldisk/option.h index d549ba5a5..00ba0138a 100644 --- a/src/modules/physicaldisk/option.h +++ b/src/modules/physicaldisk/option.h @@ -2,7 +2,7 @@ #include "common/option.h" -typedef enum __attribute__((__packed__)) FFPhysicalDiskType { +typedef enum FF_A_PACKED FFPhysicalDiskType { FF_PHYSICALDISK_TYPE_NONE = 0, // If none is set, it's unknown diff --git a/src/modules/physicalmemory/physicalmemory.c b/src/modules/physicalmemory/physicalmemory.c index a27f00b51..48319f85c 100644 --- a/src/modules/physicalmemory/physicalmemory.c +++ b/src/modules/physicalmemory/physicalmemory.c @@ -124,7 +124,7 @@ void ffGeneratePhysicalMemoryJsonConfig(FFPhysicalMemoryOptions* options, yyjson yyjson_mut_obj_add_bool(doc, module, "showEmptySlots", options->showEmptySlots); } -bool ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGeneratePhysicalMemoryJsonResult(FF_A_UNUSED FFPhysicalMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalMemoryResult)); const char* error = ffDetectPhysicalMemory(&result); diff --git a/src/modules/player/player.c b/src/modules/player/player.c index 5a8ea5cb1..424086822 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_MAYBE_UNUSED FFMediaOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGeneratePlayerJsonResult(FF_A_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 440d0def0..3467e7629 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_MAYBE_UNUSED FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGeneratePowerAdapterJsonResult(FF_A_UNUSED FFPowerAdapterOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFPowerAdapterResult)); const char* error = ffDetectPowerAdapter(&results); diff --git a/src/modules/processes/processes.c b/src/modules/processes/processes.c index 3257b1446..0a3c1329b 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_MAYBE_UNUSED FFProcessesOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateProcessesJsonResult(FF_A_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 b3da67511..82d659407 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_MAYBE_UNUSED FFShellOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateShellJsonResult(FF_A_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/sound/option.h b/src/modules/sound/option.h index aaf641c4b..cb8a6f1a4 100644 --- a/src/modules/sound/option.h +++ b/src/modules/sound/option.h @@ -3,7 +3,7 @@ #include "common/option.h" #include "common/percent.h" -typedef enum __attribute__((__packed__)) FFSoundType { +typedef enum FF_A_PACKED FFSoundType { FF_SOUND_TYPE_MAIN, FF_SOUND_TYPE_ACTIVE, FF_SOUND_TYPE_ALL, diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index 26ed845ae..f917fb7be 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -168,7 +168,7 @@ void ffGenerateSoundJsonConfig(FFSoundOptions* options, yyjson_mut_doc* doc, yyj ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateSoundJsonResult(FF_A_UNUSED FFSoundOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFSoundDevice)); const char* error = ffDetectSound(&result); diff --git a/src/modules/swap/swap.c b/src/modules/swap/swap.c index fa5160cd6..e73b7dd3f 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_MAYBE_UNUSED FFSwapOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateSwapJsonResult(FF_A_UNUSED FFSwapOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFSwapResult)); const char* error = ffDetectSwap(&result); diff --git a/src/modules/terminal/terminal.c b/src/modules/terminal/terminal.c index 8838430f0..7e17f4842 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_MAYBE_UNUSED FFTerminalOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTerminalJsonResult(FF_A_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 e3c26d484..7bd8e5076 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_MAYBE_UNUSED FFTerminalFontOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTerminalFontJsonResult(FF_A_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 ac5ddaba0..7b93dedb6 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_MAYBE_UNUSED FFTerminalSizeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTerminalSizeJsonResult(FF_A_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 f4a6efbdc..bb2824545 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_MAYBE_UNUSED FFTerminalThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTerminalThemeJsonResult(FF_A_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 04623124f..4bed76440 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_MAYBE_UNUSED FFThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateThemeJsonResult(FF_A_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 f59d6447b..7e9f469d0 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_MAYBE_UNUSED FFTitleOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTitleJsonResult(FF_A_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 04a271904..dcdfe9280 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_MAYBE_UNUSED FFTPMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateTPMJsonResult(FF_A_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 f6be075b3..b78074dff 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_MAYBE_UNUSED FFUptimeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateUptimeJsonResult(FF_A_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 5435857df..09a929209 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_MAYBE_UNUSED FFVersionOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateVersionJsonResult(FF_A_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 11270f726..c0e84b37a 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_MAYBE_UNUSED FFVulkanOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateVulkanJsonResult(FF_A_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 c40462b96..eb5e68479 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_MAYBE_UNUSED FFWallpaperOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateWallpaperJsonResult(FF_A_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 afa71485c..6b48df6c8 100644 --- a/src/modules/wifi/wifi.c +++ b/src/modules/wifi/wifi.c @@ -149,7 +149,7 @@ void ffGenerateWifiJsonConfig(FFWifiOptions* options, yyjson_mut_doc* doc, yyjso ffPercentGenerateJsonConfig(doc, module, options->percent); } -bool ffGenerateWifiJsonResult(FF_MAYBE_UNUSED FFWifiOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateWifiJsonResult(FF_A_UNUSED FFWifiOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFWifiResult)); const char* error = ffDetectWifi(&result); if (error) { diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index c4358c40c..26a78f23b 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_MAYBE_UNUSED FFWMOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateWMJsonResult(FF_A_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 d9f50635d..da2406c11 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_MAYBE_UNUSED FFWMThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateWMThemeJsonResult(FF_A_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 ac3f2a808..b8f587261 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_MAYBE_UNUSED FFZpoolOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { +bool ffGenerateZpoolJsonResult(FF_A_UNUSED FFZpoolOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { FF_LIST_AUTO_DESTROY results = ffListCreate(sizeof(FFZpoolResult)); const char* error = ffDetectZpool(&results); diff --git a/src/options/display.h b/src/options/display.h index a1e729a44..8c674eabc 100644 --- a/src/options/display.h +++ b/src/options/display.h @@ -5,26 +5,26 @@ #include "common/FFstrbuf.h" #include "common/FFlist.h" -typedef enum __attribute__((__packed__)) FFSizeBinaryPrefixType { +typedef enum FF_A_PACKED FFSizeBinaryPrefixType { FF_SIZE_BINARY_PREFIX_TYPE_IEC, // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard) FF_SIZE_BINARY_PREFIX_TYPE_SI, // 1000 Bytes = 1 kB, 1000 kB = 1 MB, ... FF_SIZE_BINARY_PREFIX_TYPE_JEDEC, // 1024 Bytes = 1 KB, 1024 KB = 1 MB, ... } FFSizeBinaryPrefixType; -typedef enum __attribute__((__packed__)) FFTemperatureUnit { +typedef enum FF_A_PACKED FFTemperatureUnit { FF_TEMPERATURE_UNIT_DEFAULT, FF_TEMPERATURE_UNIT_CELSIUS, FF_TEMPERATURE_UNIT_FAHRENHEIT, FF_TEMPERATURE_UNIT_KELVIN, } FFTemperatureUnit; -typedef enum __attribute__((__packed__)) FFSpaceBeforeUnitType { +typedef enum FF_A_PACKED FFSpaceBeforeUnitType { FF_SPACE_BEFORE_UNIT_DEFAULT, FF_SPACE_BEFORE_UNIT_ALWAYS, FF_SPACE_BEFORE_UNIT_NEVER, } FFSpaceBeforeUnitType; -typedef enum __attribute__((__packed__)) FFFractionTrailingZerosType { +typedef enum FF_A_PACKED FFFractionTrailingZerosType { FF_FRACTION_TRAILING_ZEROS_TYPE_DEFAULT, FF_FRACTION_TRAILING_ZEROS_TYPE_ALWAYS, FF_FRACTION_TRAILING_ZEROS_TYPE_NEVER, diff --git a/src/options/general.c b/src/options/general.c index 599f0717f..8f4f7cf5f 100644 --- a/src/options/general.c +++ b/src/options/general.c @@ -113,7 +113,7 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options) { #endif } -void ffOptionsDestroyGeneral(FF_MAYBE_UNUSED FFOptionsGeneral* options) { +void ffOptionsDestroyGeneral(FF_A_UNUSED FFOptionsGeneral* options) { #if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(__GNU__) ffStrbufDestroy(&options->playerName); #endif diff --git a/src/options/general.h b/src/options/general.h index f74c12091..a5d3f4630 100644 --- a/src/options/general.h +++ b/src/options/general.h @@ -2,7 +2,7 @@ #include "common/ffdata.h" -typedef enum __attribute__((__packed__)) FFDsForceDrmType { +typedef enum FF_A_PACKED FFDsForceDrmType { FF_DS_FORCE_DRM_TYPE_FALSE = 0, // Disable FF_DS_FORCE_DRM_TYPE_TRUE = 1, // Try `libdrm`, then `sysfs` if libdrm failed FF_DS_FORCE_DRM_TYPE_SYSFS_ONLY, // Use `/sys/class/drm` only diff --git a/src/options/logo.h b/src/options/logo.h index 83e2d7860..62e47ea81 100644 --- a/src/options/logo.h +++ b/src/options/logo.h @@ -5,7 +5,7 @@ #define FASTFETCH_LOGO_MAX_NAMES 9 #define FASTFETCH_LOGO_MAX_COLORS 9 // two digits would make parsing much more complicated (index 1 - 9) -typedef enum __attribute__((__packed__)) FFLogoType { +typedef enum FF_A_PACKED FFLogoType { FF_LOGO_TYPE_AUTO, // if something is given, first try builtin, then file. Otherwise detect logo FF_LOGO_TYPE_BUILTIN, // builtin ascii art FF_LOGO_TYPE_SMALL, // builtin ascii art, small version @@ -24,7 +24,7 @@ typedef enum __attribute__((__packed__)) FFLogoType { FF_LOGO_TYPE_NONE, // `--logo none`, but still applies colors to the system information output (unless `--pipe` is set) } FFLogoType; -typedef enum __attribute__((__packed__)) FFLogoPosition { +typedef enum FF_A_PACKED FFLogoPosition { FF_LOGO_POSITION_LEFT, FF_LOGO_POSITION_TOP, FF_LOGO_POSITION_RIGHT,