Global: replaces __attribute__ to C23 [[attribute]]

This commit is contained in:
李通洲
2026-07-10 21:13:03 +08:00
parent ba18705d2e
commit 61656a1a7a
229 changed files with 619 additions and 648 deletions
+6 -8
View File
@@ -1,7 +1,5 @@
#pragma once
#include "common/attributes.h"
#include <stdbool.h>
#include <stdint.h>
#include <assert.h>
@@ -32,24 +30,24 @@ static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capa
list->data = __builtin_expect(capacity == 0, 0) ? nullptr : (uint8_t*) malloc((size_t) capacity * elementSize);
}
FF_A_NODISCARD static inline FFlist ffListCreate() {
[[nodiscard]] static inline FFlist ffListCreate() {
FFlist result;
ffListInit(&result);
return result;
}
FF_A_NODISCARD static inline FFlist ffListCreateA(uint32_t elementSize, uint32_t capacity) {
[[nodiscard]] static inline FFlist ffListCreateA(uint32_t elementSize, uint32_t capacity) {
FFlist result;
ffListInitA(&result, elementSize, capacity);
return result;
}
FF_A_NODISCARD static inline void* ffListGet(const FFlist* list, uint32_t elementSize, uint32_t index) {
[[nodiscard]] static inline void* ffListGet(const FFlist* list, uint32_t elementSize, uint32_t index) {
assert(list->capacity > index);
return list->data + (index * elementSize);
}
FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
[[nodiscard]] static inline uint32_t ffListFirstIndexComp(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
for (uint32_t i = 0; i < list->length; i++) {
if (compFunc(ffListGet(list, elementSize, i), compElement)) {
return i;
@@ -59,7 +57,7 @@ FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, u
return list->length;
}
FF_A_NODISCARD static inline bool ffListContains(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
[[nodiscard]] static inline bool ffListContains(const FFlist* list, uint32_t elementSize, void* compElement, bool (*compFunc)(const void*, const void*)) {
return ffListFirstIndexComp(list, elementSize, compElement, compFunc) != list->length;
}
@@ -117,7 +115,7 @@ static inline void* ffListAdd(FFlist* list, uint32_t elementSize) {
itemVarName - (itemType*) (listVar).data < (intptr_t) (listVar).length; \
++itemVarName)
#define FF_LIST_AUTO_DESTROY FFlist FF_A_CLEANUP(ffListDestroy)
#define FF_LIST_AUTO_DESTROY [[gnu::cleanup(ffListDestroy)]] FFlist
#define FF_LIST_GET(itemType, listVar, index) \
({ \
+52 -54
View File
@@ -1,7 +1,5 @@
#pragma once
#include "common/attributes.h"
#include <stdint.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -37,15 +35,15 @@ static inline void ffStrbufInit(FFstrbuf* strbuf);
void ffStrbufInitA(FFstrbuf* strbuf, uint32_t allocate);
void ffStrbufInitVF(FFstrbuf* strbuf, const char* format, va_list arguments);
void ffStrbufInitMoveNS(FFstrbuf* strbuf, uint32_t length, char* heapStr);
FF_A_PRINTF(2, 3) void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...);
FF_A_PRINTF(1, 2) FF_A_NODISCARD FFstrbuf ffStrbufCreateF(const char* format, ...);
[[gnu::format(printf, 2, 3)]] void ffStrbufInitF(FFstrbuf* strbuf, const char* format, ...);
[[gnu::format(printf, 1, 2)]] [[nodiscard]] FFstrbuf ffStrbufCreateF(const char* format, ...);
void ffStrbufEnsureFixedLengthFree(FFstrbuf* strbuf, uint32_t free);
void ffStrbufEnsureFreeNoCheck(FFstrbuf* strbuf, uint32_t free);
static inline void ffStrbufAppend(FFstrbuf* __restrict strbuf, const FFstrbuf* __restrict value);
void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int (*transformFunc)(int));
FF_A_PRINTF(2, 3) void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...);
[[gnu::format(printf, 2, 3)]] void ffStrbufAppendF(FFstrbuf* strbuf, const char* format, ...);
void ffStrbufAppendVF(FFstrbuf* strbuf, const char* format, va_list arguments);
const char* ffStrbufAppendSUntilC(FFstrbuf* strbuf, const char* value, char until);
@@ -58,7 +56,7 @@ void ffStrbufInsertNC(FFstrbuf* strbuf, uint32_t index, uint32_t num, char c);
// NOTE: Unlike ffStrbufAppend*, ffStrbufSet* functions may NOT reserve extra space
void ffStrbufSet(FFstrbuf* strbuf, const FFstrbuf* value);
void ffStrbufSetNS(FFstrbuf* strbuf, uint32_t length, const char* value);
FF_A_PRINTF(2, 3) void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...);
[[gnu::format(printf, 2, 3)]] void ffStrbufSetF(FFstrbuf* strbuf, const char* format, ...);
void ffStrbufTrimLeft(FFstrbuf* strbuf, char c);
void ffStrbufTrimRight(FFstrbuf* strbuf, char c);
@@ -79,7 +77,7 @@ bool ffStrbufSubstrAfterFirstS(FFstrbuf* strbuf, const char* str);
bool ffStrbufSubstrAfterLastC(FFstrbuf* strbuf, char c);
bool ffStrbufSubstr(FFstrbuf* strbuf, uint32_t start, uint32_t end);
FF_A_NODISCARD uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c);
[[nodiscard]] uint32_t ffStrbufCountC(const FFstrbuf* strbuf, char c);
bool ffStrbufRemoveIgnCaseEndS(FFstrbuf* strbuf, const char* end);
@@ -135,7 +133,7 @@ void ffStrbufAppendUInt(FFstrbuf* strbuf, uint64_t value);
// if `precision < 0`, let yyjson decide the precision
void ffStrbufAppendDouble(FFstrbuf* strbuf, double value, int8_t precision, bool trailingZeros);
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateA(uint32_t allocate) {
FFstrbuf strbuf;
ffStrbufInitA(&strbuf, allocate);
return strbuf;
@@ -150,7 +148,7 @@ static inline void ffStrbufInitCopy(FFstrbuf* __restrict strbuf, const FFstrbuf*
}
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateCopy(const FFstrbuf* src) {
FFstrbuf strbuf;
ffStrbufInitCopy(&strbuf, src);
return strbuf;
@@ -166,7 +164,7 @@ static inline void ffStrbufInitMove(FFstrbuf* strbuf, FFstrbuf* src) {
}
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateMove(FFstrbuf* src) {
FFstrbuf strbuf;
ffStrbufInitMove(&strbuf, src);
return strbuf;
@@ -185,7 +183,7 @@ static inline void ffStrbufDestroy(FFstrbuf* strbuf) {
ffStrbufInit(strbuf);
}
FF_A_NODISCARD static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) {
[[nodiscard]] static inline uint32_t ffStrbufGetFree(const FFstrbuf* strbuf) {
assert(strbuf != nullptr);
if (strbuf->allocated == 0) {
return 0;
@@ -311,7 +309,7 @@ static inline void ffStrbufInit(FFstrbuf* strbuf) {
strbuf->chars = CHAR_NULL_PTR;
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreate(void) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreate(void) {
FFstrbuf strbuf;
ffStrbufInit(&strbuf);
return strbuf;
@@ -328,7 +326,7 @@ static inline void ffStrbufInitStatic(FFstrbuf* strbuf, const char* str) {
strbuf->chars = (char*) str;
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateStatic(const char* str) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateStatic(const char* str) {
FFstrbuf strbuf;
ffStrbufInitStatic(&strbuf, str);
return strbuf;
@@ -351,7 +349,7 @@ static inline void ffStrbufInitNS(FFstrbuf* strbuf, uint32_t length, const char*
ffStrbufAppendNS(strbuf, length, str);
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateNS(uint32_t length, const char* str) {
FFstrbuf strbuf;
ffStrbufInitNS(&strbuf, length, str);
return strbuf;
@@ -367,7 +365,7 @@ static inline void ffStrbufInitS(FFstrbuf* strbuf, const char* str) {
ffStrbufAppendS(strbuf, str);
}
FF_A_NODISCARD static inline FFstrbuf ffStrbufCreateS(const char* str) {
[[nodiscard]] static inline FFstrbuf ffStrbufCreateS(const char* str) {
FFstrbuf strbuf;
ffStrbufInitS(&strbuf, str);
return strbuf;
@@ -387,93 +385,93 @@ static inline void ffStrbufPrependS(FFstrbuf* strbuf, const char* value) {
ffStrbufPrependNS(strbuf, (uint32_t) strlen(value), value);
}
static inline FF_A_NODISCARD int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
[[nodiscard]] static inline int ffStrbufComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
uint32_t length = strbuf->length > comp->length ? comp->length : strbuf->length;
return memcmp(strbuf->chars, comp->chars, length + 1);
}
static inline FF_A_NODISCARD bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
[[nodiscard]] static inline bool ffStrbufEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
return ffStrbufComp(strbuf, comp) == 0;
}
static inline FF_A_NODISCARD int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) {
[[nodiscard]] static inline int ffStrbufCompS(const FFstrbuf* strbuf, const char* comp) {
return strcmp(strbuf->chars, comp);
}
static inline FF_A_NODISCARD bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) {
[[nodiscard]] static inline bool ffStrbufEqualS(const FFstrbuf* strbuf, const char* comp) {
return ffStrbufCompS(strbuf, comp) == 0;
}
static inline FF_A_NODISCARD int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) {
[[nodiscard]] static inline int ffStrbufIgnCaseCompS(const FFstrbuf* strbuf, const char* comp) {
return strcasecmp(strbuf->chars, comp);
}
static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) {
[[nodiscard]] static inline bool ffStrbufIgnCaseEqualS(const FFstrbuf* strbuf, const char* comp) {
return ffStrbufIgnCaseCompS(strbuf, comp) == 0;
}
static inline FF_A_NODISCARD int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
[[nodiscard]] static inline int ffStrbufIgnCaseComp(const FFstrbuf* strbuf, const FFstrbuf* comp) {
return ffStrbufIgnCaseCompS(strbuf, comp->chars);
}
static inline FF_A_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
[[nodiscard]] static inline bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, const FFstrbuf* comp) {
return ffStrbufIgnCaseComp(strbuf, comp) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c) {
[[nodiscard]] static inline bool ffStrbufContainC(const FFstrbuf* strbuf, char c) {
return memchr(strbuf->chars, c, strbuf->length) != nullptr;
}
static inline FF_A_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) {
[[nodiscard]] static inline bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str) {
return strstr(strbuf->chars, str) != nullptr;
}
static inline FF_A_NODISCARD bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) {
[[nodiscard]] static inline bool ffStrbufContain(const FFstrbuf* strbuf, const FFstrbuf* str) {
return ffStrbufContainS(strbuf, str->chars);
}
static inline FF_A_NODISCARD bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) {
[[nodiscard]] static inline bool ffStrbufContainIgnCaseS(const FFstrbuf* strbuf, const char* str) {
return strcasestr(strbuf->chars, str) != nullptr;
}
static inline FF_A_NODISCARD bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) {
[[nodiscard]] static inline bool ffStrbufContainIgnCase(const FFstrbuf* strbuf, const FFstrbuf* str) {
return ffStrbufContainIgnCaseS(strbuf, str->chars);
}
FF_A_NODISCARD static inline uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c) {
[[nodiscard]] static inline uint32_t ffStrbufNextIndexC(const FFstrbuf* strbuf, uint32_t start, char c) {
assert(start <= strbuf->length);
const char* ptr = (const char*) memchr(strbuf->chars + start, c, strbuf->length - start);
return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length;
}
FF_A_NODISCARD static inline uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str) {
[[nodiscard]] static inline uint32_t ffStrbufNextIndexS(const FFstrbuf* strbuf, uint32_t start, const char* str) {
assert(start <= strbuf->length);
const char* ptr = strstr(strbuf->chars + start, str);
return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length;
}
FF_A_NODISCARD static inline uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c) {
[[nodiscard]] static inline uint32_t ffStrbufPreviousIndexC(const FFstrbuf* strbuf, uint32_t start, char c) {
assert(start <= strbuf->length);
const char* ptr = (const char*) memrchr(strbuf->chars, c, start + 1);
return ptr ? (uint32_t) (ptr - strbuf->chars) : strbuf->length;
}
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) {
[[nodiscard]] static inline uint32_t ffStrbufFirstIndexC(const FFstrbuf* strbuf, char c) {
return ffStrbufNextIndexC(strbuf, 0, c);
}
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) {
[[nodiscard]] static inline uint32_t ffStrbufFirstIndex(const FFstrbuf* strbuf, const FFstrbuf* searched) {
return ffStrbufNextIndexS(strbuf, 0, searched->chars);
}
static inline FF_A_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) {
[[nodiscard]] static inline uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf, const char* str) {
return ffStrbufNextIndexS(strbuf, 0, str);
}
static inline FF_A_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) {
[[nodiscard]] static inline uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c) {
if (strbuf->length == 0) {
return 0;
}
@@ -489,11 +487,11 @@ static inline bool ffStrbufSubstrBeforeLastC(FFstrbuf* strbuf, char c) {
return ffStrbufSubstrBefore(strbuf, ffStrbufLastIndexC(strbuf, c));
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) {
[[nodiscard]] static inline bool ffStrbufStartsWithC(const FFstrbuf* strbuf, char c) {
return strbuf->chars[0] == c;
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) {
[[nodiscard]] static inline bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, const char* start, uint32_t length) {
if (length > strbuf->length) {
return false;
}
@@ -501,34 +499,34 @@ static inline FF_A_NODISCARD bool ffStrbufStartsWithSN(const FFstrbuf* strbuf, c
return memcmp(strbuf->chars, start, length) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) {
[[nodiscard]] static inline bool ffStrbufStartsWithS(const FFstrbuf* strbuf, const char* start) {
return ffStrbufStartsWithSN(strbuf, start, (uint32_t) strlen(start));
}
static inline FF_A_NODISCARD bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) {
[[nodiscard]] static inline bool ffStrbufStartsWith(const FFstrbuf* strbuf, const FFstrbuf* start) {
return ffStrbufStartsWithSN(strbuf, start->chars, start->length);
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) {
[[nodiscard]] static inline bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const char* start) {
if (length > strbuf->length) {
return false;
}
return strncasecmp(strbuf->chars, start, length) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) {
[[nodiscard]] static inline bool ffStrbufStartsWithIgnCaseS(const FFstrbuf* strbuf, const char* start) {
return ffStrbufStartsWithIgnCaseNS(strbuf, (uint32_t) strlen(start), start);
}
static inline FF_A_NODISCARD bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) {
[[nodiscard]] static inline bool ffStrbufStartsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* start) {
return ffStrbufStartsWithIgnCaseNS(strbuf, start->length, start->chars);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) {
[[nodiscard]] static inline bool ffStrbufEndsWithC(const FFstrbuf* strbuf, char c) {
return strbuf->length == 0 ? false : strbuf->chars[strbuf->length - 1] == c;
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
[[nodiscard]] static inline bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
if (endLength > strbuf->length) {
return false;
}
@@ -536,30 +534,30 @@ static inline FF_A_NODISCARD bool ffStrbufEndsWithNS(const FFstrbuf* strbuf, uin
return memcmp(strbuf->chars + strbuf->length - endLength, end, endLength) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) {
[[nodiscard]] static inline bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end) {
return ffStrbufEndsWithNS(strbuf, (uint32_t) strlen(end), end);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) {
[[nodiscard]] static inline bool ffStrbufEndsWithFn(const FFstrbuf* strbuf, int (*const fn)(int)) {
return strbuf->length == 0 ? false : fn(strbuf->chars[strbuf->length - 1]);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) {
[[nodiscard]] static inline bool ffStrbufEndsWith(const FFstrbuf* strbuf, const FFstrbuf* end) {
return ffStrbufEndsWithNS(strbuf, end->length, end->chars);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
[[nodiscard]] static inline bool ffStrbufEndsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t endLength, const char* end) {
if (endLength > strbuf->length) {
return false;
}
return strcasecmp(strbuf->chars + strbuf->length - endLength, end) == 0;
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) {
[[nodiscard]] static inline bool ffStrbufEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end) {
return ffStrbufEndsWithIgnCaseNS(strbuf, (uint32_t) strlen(end), end);
}
static inline FF_A_NODISCARD bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) {
[[nodiscard]] static inline bool ffStrbufEndsWithIgnCase(const FFstrbuf* strbuf, const FFstrbuf* end) {
return ffStrbufEndsWithIgnCaseNS(strbuf, end->length, end->chars);
}
@@ -614,19 +612,19 @@ static inline void ffStrbufPutTo(const FFstrbuf* strbuf, FILE* file) {
fputc('\n', file);
}
FF_A_NODISCARD static inline double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue) {
[[nodiscard]] static inline double ffStrbufToDouble(const FFstrbuf* strbuf, double defaultValue) {
char* str_end;
double result = strtod(strbuf->chars, &str_end);
return str_end == strbuf->chars ? defaultValue : result;
}
FF_A_NODISCARD static inline uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue) {
[[nodiscard]] static inline uint64_t ffStrbufToUInt(const FFstrbuf* strbuf, uint64_t defaultValue) {
char* str_end;
unsigned long long result = strtoull(strbuf->chars, &str_end, 10);
return str_end == strbuf->chars ? defaultValue : (uint64_t) result;
}
FF_A_NODISCARD static inline int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue) {
[[nodiscard]] static inline int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int64_t defaultValue) {
char* str_end;
long long result = strtoll(strbuf->chars, &str_end, 10);
return str_end == strbuf->chars ? defaultValue : (int64_t) result;
@@ -635,4 +633,4 @@ FF_A_NODISCARD static inline int64_t ffStrbufToSInt(const FFstrbuf* strbuf, int6
// Returns true if the strbuf is modified
bool ffStrbufDecodeHexEscapeSequences(FFstrbuf* strbuf);
#define FF_STRBUF_AUTO_DESTROY FFstrbuf FF_A_CLEANUP(ffStrbufDestroy)
#define FF_STRBUF_AUTO_DESTROY [[gnu::cleanup(ffStrbufDestroy)]] FFstrbuf
+2 -2
View File
@@ -32,7 +32,7 @@ static inline void cfReleaseWrapper(void* type) {
}
}
#define FF_CFTYPE_AUTO_RELEASE FF_A_CLEANUP(cfReleaseWrapper)
#define FF_CFTYPE_AUTO_RELEASE [[gnu::cleanup(cfReleaseWrapper)]]
static inline void wrapIoObjectRelease(io_object_t* service) {
assert(service);
@@ -40,4 +40,4 @@ static inline void wrapIoObjectRelease(io_object_t* service) {
IOObjectRelease(*service);
}
}
#define FF_IOOBJECT_AUTO_RELEASE FF_A_CLEANUP(wrapIoObjectRelease)
#define FF_IOOBJECT_AUTO_RELEASE [[gnu::cleanup(wrapIoObjectRelease)]]
-20
View File
@@ -1,20 +0,0 @@
#pragma once
#ifndef __has_attribute
#error Unsupported compiler
#define __attribute__(x)
#endif
#define FF_A_FALLTHROUGH __attribute__((__fallthrough__))
#define FF_A_DEPRECATED __attribute__((__deprecated__))
#define FF_A_CLEANUP(func) __attribute__((__cleanup__(func)))
#define FF_A_NODISCARD __attribute__((__warn_unused_result__))
#define FF_A_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__(printf, formatStrIndex, argsStartIndex)))
#define FF_A_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__(scanf, formatStrIndex, argsStartIndex)))
#define FF_A_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__)))
#define FF_A_RETURNS_NONNULL __attribute__((__returns_nonnull__))
#define FF_A_UNUSED __attribute__((__unused__))
#define FF_A_PACKED __attribute__((__packed__))
#define FF_A_WEAK_IMPORT __attribute__((__weak_import__))
#define FF_A_ALWAYS_INLINE __attribute__((__always_inline__))
#define FF_A_COLD __attribute__((__cold__))
+1 -1
View File
@@ -41,6 +41,6 @@ static inline DBusMessage* ffDBusGetAllProperties(FFDBusData* dbus, const char*
return ffDBusGetMethodReply(dbus, busName, objectPath, "org.freedesktop.DBus.Properties", "GetAll", interface, nullptr);
}
#define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData)
#define FF_DBUS_AUTO_DESTROY_DATA [[gnu::cleanup(ffDBusDestroyData)]]
#endif // FF_HAVE_DBUS
+1 -1
View File
@@ -273,7 +273,7 @@ const char* ffBinaryExtractStrings(const char* machoFile, bool (*cb)(const char*
return "Failed to stat file";
}
FF_A_CLEANUP(wrapMunmap) FFMemoryMapping mapping = {
[[gnu::cleanup(wrapMunmap)]] FFMemoryMapping mapping = {
.data = mmap(nullptr, (size_t) st.st_size, PROT_READ, MAP_PRIVATE, fd, 0),
.length = (size_t) st.st_size,
};
+4 -4
View File
@@ -82,7 +82,7 @@ void ffPrepareCommandOption(FFdata* data) {
case 'D':
case 'd':
FF_IF_MODULE_MATCH(FF_DISKIO_MODULE_NAME) {
FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options;
[[gnu::cleanup(ffDestroyDiskIOOptions)]] FFDiskIOOptions options;
ffInitDiskIOOptions(&options);
ffPrepareDiskIO(&options);
}
@@ -93,7 +93,7 @@ void ffPrepareCommandOption(FFdata* data) {
case 'N':
case 'n':
FF_IF_MODULE_MATCH(FF_NETIO_MODULE_NAME) {
FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options;
[[gnu::cleanup(ffDestroyNetIOOptions)]] FFNetIOOptions options;
ffInitNetIOOptions(&options);
ffPrepareNetIO(&options);
}
@@ -104,7 +104,7 @@ void ffPrepareCommandOption(FFdata* data) {
case 'P':
case 'p':
FF_IF_MODULE_MATCH(FF_PUBLICIP_MODULE_NAME) {
FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options;
[[gnu::cleanup(ffDestroyPublicIpOptions)]] FFPublicIPOptions options;
ffInitPublicIpOptions(&options);
ffPreparePublicIp(&options);
}
@@ -115,7 +115,7 @@ void ffPrepareCommandOption(FFdata* data) {
case 'W':
case 'w':
FF_IF_MODULE_MATCH(FF_WEATHER_MODULE_NAME) {
FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options;
[[gnu::cleanup(ffDestroyWeatherOptions)]] FFWeatherOptions options;
ffInitWeatherOptions(&options);
ffPrepareWeather(&options);
}
+1 -1
View File
@@ -112,7 +112,7 @@ static inline bool formatArgSet(const FFformatarg* arg) {
return arg->value != nullptr && ((arg->type == FF_ARG_TYPE_DOUBLE && *(double*) arg->value > 0.0) || (arg->type == FF_ARG_TYPE_FLOAT && *(float*) arg->value > 0.0) || (arg->type == FF_ARG_TYPE_INT && *(int32_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_STRBUF && ((FFstrbuf*) arg->value)->length > 0) || (arg->type == FF_ARG_TYPE_STRING && ffStrSet((char*) arg->value)) || (arg->type == FF_ARG_TYPE_UINT8 && *(uint8_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT16 && *(uint16_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT && *(uint32_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_UINT64 && *(uint64_t*) arg->value > 0) || (arg->type == FF_ARG_TYPE_BOOL && *(bool*) arg->value) || (arg->type == FF_ARG_TYPE_LIST && ((FFlist*) arg->value)->length > 0));
}
FF_A_UNUSED static inline void normalizeArgName(FFstrbuf* dst, const char* src) {
[[maybe_unused]] static inline void normalizeArgName(FFstrbuf* dst, const char* src) {
ffStrbufClear(dst);
bool flag = false;
for (const char* p = src; *p; ++p) {
+2 -2
View File
@@ -105,12 +105,12 @@ static void resetConsole(void) {
}
#ifdef _WIN32
BOOL WINAPI consoleHandler(FF_A_UNUSED DWORD signal) {
BOOL WINAPI consoleHandler([[maybe_unused]] DWORD signal) {
resetConsole();
exit(0);
}
#else
static void exitSignalHandler(FF_A_UNUSED int signal) {
static void exitSignalHandler([[maybe_unused]] int signal) {
resetConsole();
exit(0);
}
+1 -1
View File
@@ -34,7 +34,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data) {
int openFlagsModes = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC;
mode_t openFlagsRights = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
int FF_AUTO_CLOSE_FD fd = open(fileName, openFlagsModes, openFlagsRights);
FF_AUTO_CLOSE_FD int fd = open(fileName, openFlagsModes, openFlagsRights);
if (fd == -1) {
if (errno == ENOENT) {
createSubfolders(fileName);
+1 -1
View File
@@ -157,7 +157,7 @@ bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data) {
}
}
HANDLE FF_AUTO_CLOSE_FD handle = CreateFileW(fileNameW, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
FF_AUTO_CLOSE_FD HANDLE handle = CreateFileW(fileNameW, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle == INVALID_HANDLE_VALUE) {
if (GetLastError() == ERROR_PATH_NOT_FOUND) {
if (!createSubfolders(fileNameW)) {
+5 -5
View File
@@ -139,7 +139,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
if (ffStrEqualsIgnCase(type, FF_CPUUSAGE_MODULE_NAME)) {
ffPrepareCPUUsage();
} else if (ffStrEqualsIgnCase(type, FF_COMMAND_MODULE_NAME)) {
FF_A_CLEANUP(ffDestroyCommandOptions) FFCommandOptions options;
[[gnu::cleanup(ffDestroyCommandOptions)]] FFCommandOptions options;
ffInitCommandOptions(&options);
if (module) {
ffCommandModuleInfo.parseJsonObject(&options, module);
@@ -154,7 +154,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'd':
case 'D': {
if (ffStrEqualsIgnCase(type, FF_DISKIO_MODULE_NAME)) {
FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options;
[[gnu::cleanup(ffDestroyDiskIOOptions)]] FFDiskIOOptions options;
ffInitDiskIOOptions(&options);
if (module) {
ffDiskIOModuleInfo.parseJsonObject(&options, module);
@@ -169,7 +169,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'n':
case 'N': {
if (ffStrEqualsIgnCase(type, FF_NETIO_MODULE_NAME)) {
FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options;
[[gnu::cleanup(ffDestroyNetIOOptions)]] FFNetIOOptions options;
ffInitNetIOOptions(&options);
if (module) {
ffNetIOModuleInfo.parseJsonObject(&options, module);
@@ -184,7 +184,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'p':
case 'P': {
if (ffStrEqualsIgnCase(type, FF_PUBLICIP_MODULE_NAME)) {
FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options;
[[gnu::cleanup(ffDestroyPublicIpOptions)]] FFPublicIPOptions options;
ffInitPublicIpOptions(&options);
if (module) {
ffPublicIPModuleInfo.parseJsonObject(&options, module);
@@ -199,7 +199,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'w':
case 'W': {
if (ffStrEqualsIgnCase(type, FF_WEATHER_MODULE_NAME)) {
FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options;
[[gnu::cleanup(ffDestroyWeatherOptions)]] FFWeatherOptions options;
ffInitWeatherOptions(&options);
if (module) {
ffWeatherModuleInfo.parseJsonObject(&options, module);
+1 -1
View File
@@ -4,7 +4,7 @@
#include <sys/module.h>
#include <sys/param.h>
typedef struct FF_A_PACKED FFNbsdModList {
typedef struct [[gnu::packed]] FFNbsdModList {
int len;
modstat_t mods[];
} FFNbsdModList;
+1 -1
View File
@@ -1,5 +1,5 @@
#include "common/kmod.h"
bool ffKmodLoaded(FF_A_UNUSED const char* modName) {
bool ffKmodLoaded([[maybe_unused]] const char* modName) {
return true; // Don't generate kernel module related errors
}
+1 -1
View File
@@ -108,7 +108,7 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...) {
#if _WIN32
void* dlopen(const char* path, FF_A_UNUSED int mode) {
void* dlopen(const char* path, [[maybe_unused]] int mode) {
wchar_t pathW[MAX_PATH + 1];
ULONG pathWBytes = 0;
+6 -6
View File
@@ -44,7 +44,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
uint32_t pid = ffNetifGetNetlinkPortId(sock_fd);
struct FF_A_PACKED {
struct [[gnu::packed]] {
struct nlmsghdr nlh;
struct rtmsg rtm;
struct rtattr rta;
@@ -97,7 +97,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient
uint32_t minMetric = UINT32_MAX;
FF_A_UNUSED int routeCount = 0;
[[maybe_unused]] int routeCount = 0;
while (true) {
ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, (struct sockaddr*) &src_addr, &src_addr_len);
@@ -254,7 +254,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
uint32_t pid = ffNetifGetNetlinkPortId(sock_fd);
struct FF_A_PACKED {
struct [[gnu::packed]] {
struct nlmsghdr nlh;
struct rtmsg rtm;
struct rtattr rta;
@@ -307,7 +307,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient
uint32_t minMetric = UINT32_MAX;
FF_A_UNUSED int routeCount = 0;
[[maybe_unused]] int routeCount = 0;
while (true) {
ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, (struct sockaddr*) &src_addr, &src_addr_len);
@@ -382,7 +382,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
switch (rta->rta_type) {
case RTA_DST:
if (RTA_PAYLOAD(rta) >= sizeof(struct in6_addr)) {
FF_A_UNUSED char str[INET6_ADDRSTRLEN];
[[maybe_unused]] char str[INET6_ADDRSTRLEN];
FF_DEBUG("Unexpected RTA_DST: %s", inet_ntop(AF_INET6, RTA_DATA(rta), str, sizeof(str)));
goto next;
}
@@ -399,7 +399,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
if (IN6_IS_ADDR_UNSPECIFIED(gw)) {
goto next;
}
FF_A_UNUSED char str[INET6_ADDRSTRLEN];
[[maybe_unused]] char str[INET6_ADDRSTRLEN];
FF_DEBUG("Found gateway: %s", inet_ntop(AF_INET6, gw, str, sizeof(str)));
}
break;
+2 -2
View File
@@ -261,7 +261,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos
if (state->timeout > 0) {
FF_DEBUG("Setting connection timeout: %u ms", state->timeout);
FF_A_UNUSED uint32_t sec = state->timeout / 1000;
[[maybe_unused]] uint32_t sec = state->timeout / 1000;
if (sec == 0) {
sec = 1;
}
@@ -417,7 +417,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
}
FF_DEBUG("Starting data reception");
FF_A_UNUSED int recvCount = 0;
[[maybe_unused]] int recvCount = 0;
uint32_t contentLength = 0;
uint32_t headerEnd = 0;
+1 -1
View File
@@ -275,7 +275,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
}
FF_DEBUG("Starting data reception");
FF_A_UNUSED int recvCount = 0;
[[maybe_unused]] int recvCount = 0;
uint32_t contentLength = 0;
uint32_t headerEnd = 0;
+1 -1
View File
@@ -603,7 +603,7 @@ bool ffSettingsGetEnlightenmentProperty(ffEnlightenmentSettings* result) {
return !!parsed;
}
#else
bool ffSettingsGetEnlightenmentProperty(FF_A_UNUSED ffEnlightenmentSettings* result) {
bool ffSettingsGetEnlightenmentProperty([[maybe_unused]] ffEnlightenmentSettings* result) {
return false;
}
#endif
+5 -5
View File
@@ -66,7 +66,7 @@ static bool parseSmbiosTable(const uint8_t* data, uint32_t length) {
const FFSmbiosHeader* endOfTable = nullptr;
FF_DEBUG("Parsing SMBIOS table structures with length %u bytes", length);
FF_A_UNUSED int structureCount = 0, totalCount = 0;
[[maybe_unused]] int structureCount = 0, totalCount = 0;
for (
const FFSmbiosHeader* header = (const FFSmbiosHeader*) data;
(const uint8_t*) header + sizeof(FFSmbiosHeader) < (const uint8_t*) data + length;
@@ -228,7 +228,7 @@ static bool readPhysicalMemory(int fd, off_t address, size_t length, void* buffe
return true;
}
typedef struct FFSmbios20EntryPoint {
typedef struct [[gnu::packed]] FFSmbios20EntryPoint {
uint8_t AnchorString[4];
uint8_t EntryPointStructureChecksum;
uint8_t EntryPointLength;
@@ -243,11 +243,11 @@ typedef struct FFSmbios20EntryPoint {
uint32_t StructureTableAddress;
uint16_t NumberOfSmbiosStructures;
uint8_t SmbiosBcdRevision;
} FF_A_PACKED FFSmbios20EntryPoint;
} FFSmbios20EntryPoint;
static_assert(offsetof(FFSmbios20EntryPoint, SmbiosBcdRevision) == 0x1E,
"FFSmbios20EntryPoint: Wrong struct alignment");
typedef struct FFSmbios30EntryPoint {
typedef struct [[gnu::packed]] FFSmbios30EntryPoint {
uint8_t AnchorString[5];
uint8_t EntryPointStructureChecksum;
uint8_t EntryPointLength;
@@ -258,7 +258,7 @@ typedef struct FFSmbios30EntryPoint {
uint8_t Reversed;
uint32_t StructureTableMaximumSize;
uint64_t StructureTableAddress;
} FF_A_PACKED FFSmbios30EntryPoint;
} FFSmbios30EntryPoint;
static_assert(offsetof(FFSmbios30EntryPoint, StructureTableAddress) == 0x10,
"FFSmbios30EntryPoint: Wrong struct alignment");
+1
View File
@@ -1,4 +1,5 @@
#include "common/strutil.h"
#include "common/wcwidth.h"
uint8_t ffUtf8CharLenWidth(const char* str, uint32_t length, uint8_t* width) {
if (__builtin_expect(length == 0 || *str == '\0', false)) {
+1 -1
View File
@@ -89,7 +89,7 @@ FFTimeGetAgeResult ffTimeGetAge(uint64_t birthMs, uint64_t nowMs) {
#ifdef _WIN32
double ffQpcMultiplier;
__attribute__((constructor)) static void ffTimeInitQpcMultiplier(void) {
[[gnu::constructor]] static void ffTimeInitQpcMultiplier(void) {
LARGE_INTEGER frequency;
RtlQueryPerformanceFrequency(&frequency);
ffQpcMultiplier = 1000. / (double) frequency.QuadPart;
+6 -6
View File
@@ -30,7 +30,7 @@ static struct trace_event {
} events[4 * 1024 * 1024]; // 4M events, 96 MiB memory usage
static _Atomic uint32_t event_count;
__attribute__((no_instrument_function, always_inline)) static inline uint64_t get_time_us() {
[[gnu::no_instrument_function, gnu::always_inline]] static inline uint64_t get_time_us() {
#if !_WIN32
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -43,12 +43,12 @@ __attribute__((no_instrument_function, always_inline)) static inline uint64_t ge
}
#if _WIN32
__attribute__((constructor, no_instrument_function)) void trace_init() {
[[gnu::constructor, gnu::no_instrument_function]] void trace_init() {
QueryPerformanceFrequency(&freq);
}
#endif
__attribute__((destructor, no_instrument_function)) void trace_fini() {
[[gnu::destructor, gnu::no_instrument_function]] void trace_fini() {
#if _WIN32
uint32_t pid = (uint32_t) GetCurrentProcessId();
#else
@@ -115,7 +115,7 @@ __attribute__((destructor, no_instrument_function)) void trace_fini() {
#endif
}
__attribute__((no_instrument_function)) static void write_event(void* this_fn, bool is_exit) {
[[gnu::no_instrument_function]] static void write_event(void* this_fn, bool is_exit) {
uint32_t idx = atomic_fetch_add_explicit(&event_count, 1, memory_order_relaxed);
if (__builtin_expect(idx >= sizeof(events) / sizeof(events[0]), false)) {
abort();
@@ -137,12 +137,12 @@ __attribute__((no_instrument_function)) static void write_event(void* this_fn, b
}
}
__attribute__((no_instrument_function)) void __cyg_profile_func_enter(void* this_fn, void* call_site) {
[[gnu::no_instrument_function]] void __cyg_profile_func_enter(void* this_fn, void* call_site) {
(void) call_site;
write_event(this_fn, false);
}
__attribute__((no_instrument_function)) void __cyg_profile_func_exit(void* this_fn, void* call_site) {
[[gnu::no_instrument_function]] void __cyg_profile_func_exit(void* this_fn, void* call_site) {
(void) call_site;
write_event(this_fn, true);
}
+33 -31
View File
@@ -40,7 +40,6 @@ HANDLE openat(HANDLE dfd, const char* fileName, int oflag);
HANDLE openatW(HANDLE dfd, const wchar_t* fileName, uint16_t fileNameLen, bool directory);
#endif
FF_A_ALWAYS_INLINE
static inline bool ffIsValidNativeFD(FFNativeFD fd) {
#ifndef _WIN32
return fd >= 0;
@@ -50,7 +49,7 @@ static inline bool ffIsValidNativeFD(FFNativeFD fd) {
#endif
}
FF_A_ALWAYS_INLINE FF_A_NONNULL(1)
[[gnu::always_inline, gnu::nonnull(1)]]
static inline void wrapClose(FFNativeFD* pfd) {
assert(pfd);
@@ -62,7 +61,7 @@ static inline void wrapClose(FFNativeFD* pfd) {
#endif
}
}
#define FF_AUTO_CLOSE_FD FF_A_CLEANUP(wrapClose)
#define FF_AUTO_CLOSE_FD [[gnu::cleanup(wrapClose)]]
static inline FFNativeFD FFUnixFD2NativeFD(int unixfd) {
#ifndef _WIN32
@@ -72,7 +71,8 @@ static inline FFNativeFD FFUnixFD2NativeFD(int unixfd) {
#endif
}
FF_A_NONNULL(3) static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* data) {
[[gnu::nonnull(3)]]
static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize, const void* data) {
#ifndef _WIN32
return write(fd, data, dataSize) != -1;
#else
@@ -81,17 +81,21 @@ FF_A_NONNULL(3) static inline bool ffWriteFDData(FFNativeFD fd, size_t dataSize,
#endif
}
FF_A_NONNULL(2) static inline bool ffWriteFDBuffer(FFNativeFD fd, const FFstrbuf* content) {
[[gnu::nonnull(2)]]
static inline bool ffWriteFDBuffer(FFNativeFD fd, const FFstrbuf* content) {
return ffWriteFDData(fd, content->length, content->chars);
}
FF_A_NONNULL(1, 3) bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
[[gnu::nonnull(1, 3)]]
bool ffWriteFileData(const char* fileName, size_t dataSize, const void* data);
FF_A_NONNULL(1, 2) static inline bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer) {
[[gnu::nonnull(1, 2)]]
static inline bool ffWriteFileBuffer(const char* fileName, const FFstrbuf* buffer) {
return ffWriteFileData(fileName, buffer->length, buffer->chars);
}
FF_A_NONNULL(3) static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data) {
[[gnu::nonnull(3)]]
static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSize, void* data) {
#ifndef _WIN32
return read(fd, data, dataSize);
#else
@@ -104,10 +108,10 @@ FF_A_NONNULL(3) static inline ssize_t ffReadFDData(FFNativeFD fd, size_t dataSiz
#endif
}
FF_A_NONNULL(2) bool ffAppendFDBuffer(FFNativeFD fd, FFstrbuf* buffer);
[[gnu::nonnull(2)]] bool ffAppendFDBuffer(FFNativeFD fd, FFstrbuf* buffer);
FF_A_NONNULL(1, 3) static inline ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data) {
FFNativeFD FF_AUTO_CLOSE_FD fd =
[[gnu::nonnull(1, 3)]] static inline ssize_t ffReadFileData(const char* fileName, size_t dataSize, void* data) {
FF_AUTO_CLOSE_FD FFNativeFD fd =
#ifndef _WIN32
open(fileName, O_RDONLY | O_CLOEXEC);
#else
@@ -121,8 +125,8 @@ FF_A_NONNULL(1, 3) static inline ssize_t ffReadFileData(const char* fileName, si
return ffReadFDData(fd, dataSize, data);
}
FF_A_NONNULL(2, 4) static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileName, size_t dataSize, void* data) {
FFNativeFD FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
[[gnu::nonnull(2, 4)]] static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileName, size_t dataSize, void* data) {
FF_AUTO_CLOSE_FD FFNativeFD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
if (!ffIsValidNativeFD(fd)) {
return -1;
}
@@ -130,8 +134,8 @@ FF_A_NONNULL(2, 4) static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd,
return ffReadFDData(fd, dataSize, data);
}
FF_A_NONNULL(1, 2) static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) {
FFNativeFD FF_AUTO_CLOSE_FD fd =
[[gnu::nonnull(1, 2)]] static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) {
FF_AUTO_CLOSE_FD FFNativeFD fd =
#ifndef _WIN32
open(fileName, O_RDONLY | O_CLOEXEC);
#else
@@ -145,8 +149,8 @@ FF_A_NONNULL(1, 2) static inline bool ffAppendFileBuffer(const char* fileName, F
return ffAppendFDBuffer(fd, buffer);
}
FF_A_NONNULL(2, 3) static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) {
FFNativeFD FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
[[gnu::nonnull(2, 3)]] static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) {
FF_AUTO_CLOSE_FD FFNativeFD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
if (!ffIsValidNativeFD(fd)) {
return false;
}
@@ -154,17 +158,17 @@ FF_A_NONNULL(2, 3) static inline bool ffAppendFileBufferRelative(FFNativeFD dfd,
return ffAppendFDBuffer(fd, buffer);
}
FF_A_NONNULL(2) static inline bool ffReadFDBuffer(FFNativeFD fd, FFstrbuf* buffer) {
[[gnu::nonnull(2)]] static inline bool ffReadFDBuffer(FFNativeFD fd, FFstrbuf* buffer) {
ffStrbufClear(buffer);
return ffAppendFDBuffer(fd, buffer);
}
FF_A_NONNULL(1, 2) static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer) {
[[gnu::nonnull(1, 2)]] static inline bool ffReadFileBuffer(const char* fileName, FFstrbuf* buffer) {
ffStrbufClear(buffer);
return ffAppendFileBuffer(fileName, buffer);
}
FF_A_NONNULL(2, 3) static inline bool ffReadFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) {
[[gnu::nonnull(2, 3)]] static inline bool ffReadFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) {
ffStrbufClear(buffer);
return ffAppendFileBufferRelative(dfd, fileName, buffer);
}
@@ -175,7 +179,7 @@ typedef enum FFPathType: uint8_t {
FF_PATHTYPE_ANY = FF_PATHTYPE_FILE | FF_PATHTYPE_DIRECTORY,
} FFPathType;
FF_A_NONNULL(1) static inline bool ffPathExists(const char* path, FFPathType pathType) {
[[gnu::nonnull(1)]] static inline bool ffPathExists(const char* path, FFPathType pathType) {
#ifdef _WIN32
wchar_t wPath[MAX_PATH];
@@ -224,13 +228,11 @@ FF_A_NONNULL(1) static inline bool ffPathExists(const char* path, FFPathType pat
return false;
}
FF_A_NONNULL(1, 2) bool ffPathExpandEnv(const char* in, FFstrbuf* out);
[[gnu::nonnull(1, 2)]] bool ffPathExpandEnv(const char* in, FFstrbuf* out);
#define FF_IO_TERM_RESP_WAIT_MS 100 // #554
FF_A_SCANF(3, 4)
FF_A_NONNULL(1, 3)
const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...);
[[gnu::format(scanf, 3, 4), gnu::nonnull(1, 3)]] const char* ffGetTerminalResponse(const char* request, int nParams, const char* format, ...);
// Not thread safe!
bool ffSuppressIO(bool suppress);
@@ -243,19 +245,19 @@ static inline void ffUnsuppressIO(bool* suppressed) {
*suppressed = false;
}
#define FF_SUPPRESS_IO() bool FF_A_CLEANUP(ffUnsuppressIO) FF_A_UNUSED io_suppressed__ = ffSuppressIO(true)
#define FF_SUPPRESS_IO() [[maybe_unused, gnu::cleanup(ffUnsuppressIO)]] bool io_suppressed__ = ffSuppressIO(true)
void ffListFilesRecursively(const char* path, bool pretty);
FF_A_NONNULL(1) FF_A_ALWAYS_INLINE static inline void wrapFclose(FILE** pfile) {
[[gnu::nonnull(1), gnu::always_inline]] static inline void wrapFclose(FILE** pfile) {
assert(pfile);
if (*pfile) {
fclose(*pfile);
}
}
#define FF_AUTO_CLOSE_FILE FF_A_CLEANUP(wrapFclose)
#define FF_AUTO_CLOSE_FILE [[gnu::cleanup(wrapFclose)]]
FF_A_NONNULL(1) FF_A_ALWAYS_INLINE
[[gnu::nonnull(1), gnu::always_inline]]
#ifndef _WIN32
static inline void wrapClosedir(DIR** pdir) {
assert(pdir);
@@ -271,9 +273,9 @@ static inline void wrapClosedir(HANDLE* pdir) {
}
}
#endif
#define FF_AUTO_CLOSE_DIR FF_A_CLEANUP(wrapClosedir)
#define FF_AUTO_CLOSE_DIR [[gnu::cleanup(wrapClosedir)]]
FF_A_NONNULL(1, 2, 3) static inline bool ffSearchUserConfigFile(const FFlist* configDirs, const char* fileSubpath, FFstrbuf* result) {
[[gnu::nonnull(1, 2, 3)]] static inline bool ffSearchUserConfigFile(const FFlist* configDirs, const char* fileSubpath, FFstrbuf* result) {
// configDirs is a list of FFstrbufs include the trailing slash
FF_LIST_FOR_EACH (FFstrbuf, dir, *configDirs) {
ffStrbufClear(result);
+7 -7
View File
@@ -6,8 +6,8 @@
#if defined(_WIN32)
#define FF_DLOPEN_FLAGS 0
FF_A_NODISCARD void* dlopen(const char* path, int mode);
FF_A_NODISCARD void* dlsym(void* handle, const char* symbol);
[[nodiscard]] void* dlopen(const char* path, int mode);
[[nodiscard]] void* dlsym(void* handle, const char* symbol);
int dlclose(void* handle);
#else
#include <dlfcn.h>
@@ -36,7 +36,7 @@ static inline void ffLibraryUnload(void** handle) {
__typeof__(&symbolName) ff##symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, libraryFileName, maxVersion, ...) \
void* FF_A_CLEANUP(ffLibraryUnload) libraryObjectName = ffLibraryLoadSingle(libraryFileName, maxVersion); \
[[gnu::cleanup(ffLibraryUnload)]] void* libraryObjectName = ffLibraryLoadSingle(libraryFileName, maxVersion); \
__VA_OPT__(if (__builtin_expect(libraryObjectName == nullptr, false)) libraryObjectName = ffLibraryLoadMulti(__VA_ARGS__, nullptr);) \
if (__builtin_expect(libraryObjectName == nullptr, false)) \
return returnValue;
@@ -78,7 +78,7 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...);
__typeof__(&symbolName) ff##symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
FF_A_UNUSED void* libraryObjectName = nullptr; // Placeholder
[[maybe_unused]] void* libraryObjectName = nullptr; // Placeholder
#define FF_LIBRARY_LOAD_MESSAGE(libraryObjectName, libraryFileName, maxVersion, ...) \
FF_LIBRARY_LOAD(libraryObjectName, , libraryFileName, maxVersion, ##__VA_ARGS__)
@@ -87,13 +87,13 @@ void* ffLibraryLoadMulti(const char* path, int maxVersion, ...);
symbolMapping = (__typeof__(&symbolName)) &symbolName;
#define FF_LIBRARY_LOAD_SYMBOL(library, symbolName, returnValue) \
FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue);
[[maybe_unused]] __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, returnValue);
#define FF_LIBRARY_LOAD_SYMBOL_LAZY(library, symbolName) \
FF_A_UNUSED __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName;
[[maybe_unused]] __auto_type ff##symbolName = (__typeof__(&symbolName)) &symbolName;
#define FF_LIBRARY_LOAD_SYMBOL_MESSAGE(library, symbolName) \
FF_A_UNUSED __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
[[maybe_unused]] __auto_type FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, ff##symbolName, symbolName, "dlsym " #symbolName " failed");
#define FF_LIBRARY_LOAD_SYMBOL_VAR(library, varName, symbolName, returnValue) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName).ff##symbolName, symbolName, returnValue);
+28 -28
View File
@@ -63,95 +63,95 @@ extern struct FFLuaData {
} luaData;
#if !FF_DISABLE_DLOPEN
FF_A_ALWAYS_INLINE void(lua_settop)(lua_State* L, int idx) {
[[gnu::always_inline]] void(lua_settop)(lua_State* L, int idx) {
return luaData.fflua_settop(L, idx);
}
FF_A_ALWAYS_INLINE int(luaL_loadbufferx)(lua_State* L, const char* buff, size_t sz, const char* name, const char* mode) {
[[gnu::always_inline]] int(luaL_loadbufferx)(lua_State* L, const char* buff, size_t sz, const char* name, const char* mode) {
return luaData.ffluaL_loadbufferx(L, buff, sz, name, mode);
}
FF_A_ALWAYS_INLINE const char*(lua_tolstring) (lua_State * L, int idx, size_t* len) {
[[gnu::always_inline]] const char*(lua_tolstring) (lua_State * L, int idx, size_t* len) {
return luaData.fflua_tolstring(L, idx, len);
}
FF_A_ALWAYS_INLINE void(lua_createtable)(lua_State* L, int narr, int nrec) {
[[gnu::always_inline]] void(lua_createtable)(lua_State* L, int narr, int nrec) {
return luaData.fflua_createtable(L, narr, nrec);
}
FF_A_ALWAYS_INLINE void(lua_pushinteger)(lua_State* L, lua_Integer n) {
[[gnu::always_inline]] void(lua_pushinteger)(lua_State* L, lua_Integer n) {
return luaData.fflua_pushinteger(L, n);
}
FF_A_ALWAYS_INLINE void(lua_pushnumber)(lua_State* L, lua_Number n) {
[[gnu::always_inline]] void(lua_pushnumber)(lua_State* L, lua_Number n) {
return luaData.fflua_pushnumber(L, n);
}
FF_A_ALWAYS_INLINE void(lua_pushboolean)(lua_State* L, int b) {
[[gnu::always_inline]] void(lua_pushboolean)(lua_State* L, int b) {
return luaData.fflua_pushboolean(L, b);
}
FF_A_ALWAYS_INLINE const char*(lua_pushlstring) (lua_State * L, const char* s, size_t len) {
[[gnu::always_inline]] const char*(lua_pushlstring) (lua_State * L, const char* s, size_t len) {
return luaData.fflua_pushlstring(L, s, len);
}
FF_A_ALWAYS_INLINE void(lua_pushvalue)(lua_State* L, int idx) {
[[gnu::always_inline]] void(lua_pushvalue)(lua_State* L, int idx) {
return luaData.fflua_pushvalue(L, idx);
}
FF_A_ALWAYS_INLINE void(lua_seti)(lua_State* L, int idx, lua_Integer n) {
[[gnu::always_inline]] void(lua_seti)(lua_State* L, int idx, lua_Integer n) {
return luaData.fflua_seti(L, idx, n);
}
FF_A_ALWAYS_INLINE void(lua_pushnil)(lua_State* L) {
[[gnu::always_inline]] void(lua_pushnil)(lua_State* L) {
return luaData.fflua_pushnil(L);
}
FF_A_ALWAYS_INLINE void(lua_setfield)(lua_State* L, int idx, const char* k) {
[[gnu::always_inline]] void(lua_setfield)(lua_State* L, int idx, const char* k) {
return luaData.fflua_setfield(L, idx, k);
}
FF_A_ALWAYS_INLINE int(lua_pcallk)(lua_State* L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k) {
[[gnu::always_inline]] int(lua_pcallk)(lua_State* L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k) {
return luaData.fflua_pcallk(L, nargs, nresults, errfunc, ctx, k);
}
FF_A_ALWAYS_INLINE int(lua_gettop)(lua_State* L) {
[[gnu::always_inline]] int(lua_gettop)(lua_State* L) {
return luaData.fflua_gettop(L);
}
FF_A_ALWAYS_INLINE const char*(luaL_tolstring) (lua_State * L, int idx, size_t* len) {
[[gnu::always_inline]] const char*(luaL_tolstring) (lua_State * L, int idx, size_t* len) {
return luaData.ffluaL_tolstring(L, idx, len);
}
FF_A_ALWAYS_INLINE int(lua_error)(lua_State* L) {
[[gnu::always_inline]] int(lua_error)(lua_State* L) {
return luaData.fflua_error(L);
}
FF_A_ALWAYS_INLINE void(lua_pushcclosure)(lua_State* L, lua_CFunction fn, int n) {
[[gnu::always_inline]] void(lua_pushcclosure)(lua_State* L, lua_CFunction fn, int n) {
return luaData.fflua_pushcclosure(L, fn, n);
}
FF_A_ALWAYS_INLINE void(luaL_checkany)(lua_State* L, int idx) {
[[gnu::always_inline]] void(luaL_checkany)(lua_State* L, int idx) {
return luaData.ffluaL_checkany(L, idx);
}
FF_A_ALWAYS_INLINE void(lua_callk)(lua_State* L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k) {
[[gnu::always_inline]] void(lua_callk)(lua_State* L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k) {
return luaData.fflua_callk(L, nargs, nresults, ctx, k);
}
FF_A_ALWAYS_INLINE int(lua_isinteger)(lua_State* L, int idx) {
[[gnu::always_inline]] int(lua_isinteger)(lua_State* L, int idx) {
return luaData.fflua_isinteger(L, idx);
}
FF_A_ALWAYS_INLINE int(lua_next)(lua_State* L, int idx) {
[[gnu::always_inline]] int(lua_next)(lua_State* L, int idx) {
return luaData.fflua_next(L, idx);
}
FF_A_ALWAYS_INLINE int(lua_rawgeti)(lua_State* L, int idx, lua_Integer n) {
[[gnu::always_inline]] int(lua_rawgeti)(lua_State* L, int idx, lua_Integer n) {
return luaData.fflua_rawgeti(L, idx, n);
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
#if LUA_VERSION_NUM > 503
lua_Unsigned
#else
@@ -161,23 +161,23 @@ size_t
return luaData.fflua_rawlen(L, idx);
}
FF_A_ALWAYS_INLINE void(lua_setglobal)(lua_State* L, const char* name) {
[[gnu::always_inline]] void(lua_setglobal)(lua_State* L, const char* name) {
return luaData.fflua_setglobal(L, name);
}
FF_A_ALWAYS_INLINE int(lua_toboolean)(lua_State* L, int idx) {
[[gnu::always_inline]] int(lua_toboolean)(lua_State* L, int idx) {
return luaData.fflua_toboolean(L, idx);
}
FF_A_ALWAYS_INLINE lua_Integer(lua_tointegerx)(lua_State* L, int idx, int* isnum) {
[[gnu::always_inline]] lua_Integer(lua_tointegerx)(lua_State* L, int idx, int* isnum) {
return luaData.fflua_tointegerx(L, idx, isnum);
}
FF_A_ALWAYS_INLINE lua_Number(lua_tonumberx)(lua_State* L, int idx, int* isnum) {
[[gnu::always_inline]] lua_Number(lua_tonumberx)(lua_State* L, int idx, int* isnum) {
return luaData.fflua_tonumberx(L, idx, isnum);
}
FF_A_ALWAYS_INLINE int(lua_type)(lua_State* L, int idx) {
[[gnu::always_inline]] int(lua_type)(lua_State* L, int idx) {
return luaData.fflua_type(L, idx);
}
#endif
+2 -3
View File
@@ -2,7 +2,6 @@
#include <stdlib.h>
#include <assert.h>
#include "common/attributes.h"
#if FF_HAVE_MALLOC_USABLE_SIZE || FF_HAVE_MSVC_MSIZE
#if __has_include(<malloc.h>)
@@ -14,7 +13,7 @@
#include <malloc/malloc.h>
#endif
FF_A_ALWAYS_INLINE FF_A_NONNULL(1)
[[gnu::always_inline, gnu::nonnull(1)]]
static inline void ffWrapFree(const void* pPtr) {
assert(pPtr);
if (*(void**) pPtr) {
@@ -22,7 +21,7 @@ static inline void ffWrapFree(const void* pPtr) {
}
}
#define FF_AUTO_FREE FF_A_CLEANUP(ffWrapFree)
#define FF_AUTO_FREE [[gnu::cleanup(ffWrapFree)]]
// ptr MUST be a malloc'ed pointer
static inline size_t ffMallocUsableSize(const void* ptr) {
+4 -4
View File
@@ -65,10 +65,10 @@ typedef struct FFKeyValuePair {
const char* ffOptionTestPrefix(const char* argumentKey, const char* moduleName);
void ffOptionParseString(const char* argumentKey, const char* value, FFstrbuf* buffer);
FF_A_NODISCARD uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value);
FF_A_NODISCARD int32_t ffOptionParseInt32(const char* argumentKey, const char* value);
FF_A_NODISCARD int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]);
FF_A_NODISCARD bool ffOptionParseBoolean(const char* str);
[[nodiscard]] uint32_t ffOptionParseUInt32(const char* argumentKey, const char* value);
[[nodiscard]] int32_t ffOptionParseInt32(const char* argumentKey, const char* value);
[[nodiscard]] int ffOptionParseEnum(const char* argumentKey, const char* requestedKey, FFKeyValuePair pairs[]);
[[nodiscard]] bool ffOptionParseBoolean(const char* str);
void ffOptionParseColorNoClear(const char* value, FFstrbuf* buffer);
static inline void ffOptionParseColor(const char* value, FFstrbuf* buffer) {
ffStrbufClear(buffer);
+1 -1
View File
@@ -15,6 +15,6 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu
bool ffPrintFormat(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, uint32_t numArgs, const FFformatarg* arguments);
#define FF_PRINT_FORMAT_CHECKED(moduleName, moduleIndex, moduleArgs, printType, arguments) \
ffPrintFormat((moduleName), (moduleIndex), (moduleArgs), (printType), (sizeof(arguments) / sizeof(*arguments)), (arguments));
FF_A_PRINTF(5, 6) void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
[[gnu::format(printf, 5, 6)]] void ffPrintError(const char* moduleName, uint8_t moduleIndex, const FFModuleArgs* moduleArgs, FFPrintType printType, const char* message, ...);
void ffPrintColor(const FFstrbuf* colorValue);
void ffPrintCharTimes(char c, uint32_t times);
+2 -2
View File
@@ -67,7 +67,7 @@ typedef enum FFSmbiosType : uint8_t {
} FFSmbiosType;
static_assert(sizeof(FFSmbiosType) == 1, "FFSmbiosType should be 1 byte");
typedef struct FFSmbiosHeader {
typedef struct [[gnu::packed]] FFSmbiosHeader {
// Type of SMBIOS structure. Do NOT test `Type == FF_SMBIOS_END_OF_TABLE` to determine the end of the table,
// as malformed tables may be missing the end-of-table marker.
// **Use FFSmbiosHeaderTable[FF_SMBIOS_TYPE_END_OF_TABLE] pointer instead.**
@@ -79,7 +79,7 @@ typedef struct FFSmbiosHeader {
// Not guaranteed to be consistent across reboots or even multiple reads of the same table.
// Must be less than 0xFF00
uint16_t Handle;
} FF_A_PACKED FFSmbiosHeader;
} FFSmbiosHeader;
static_assert(sizeof(FFSmbiosHeader) == 4, "FFSmbiosHeader should be 4 bytes");
static inline const char* ffSmbiosLocateString(const char* start, uint8_t index /* start from 1 */) {
+10 -13
View File
@@ -5,9 +5,6 @@
#include <string.h>
#include <ctype.h>
#include "common/attributes.h"
#include "common/wcwidth.h"
#ifdef _WIN32
// #include <shlwapi.h>
__stdcall char* StrStrIA(const char* lpFirst, const char* lpSrch);
@@ -29,17 +26,17 @@ static inline bool ffStrSet(const char* str) {
return *str != '\0';
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffStrStartsWithIgnCase(const char* str, const char* compareTo) {
return strncasecmp(str, compareTo, strlen(compareTo)) == 0;
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffStrEqualsIgnCase(const char* str, const char* compareTo) {
return strcasecmp(str, compareTo) == 0;
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffStrStartsWith(const char* str, const char* compareTo) {
return strncmp(str, compareTo, strlen(compareTo)) == 0;
}
@@ -62,32 +59,32 @@ static inline bool ffStrEndsWithIgnCase(const char* str, const char* compareTo)
return strncasecmp(str + strLength - compareToLength, compareTo, compareToLength) == 0;
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffStrEquals(const char* str, const char* compareTo) {
return strcmp(str, compareTo) == 0;
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffStrContains(const char* str, const char* compareTo) {
return strstr(str, compareTo) != nullptr;
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffStrContainsIgnCase(const char* str, const char* compareTo) {
return strcasestr(str, compareTo) != nullptr;
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffStrContainsC(const char* str, char compareTo) {
return strchr(str, compareTo) != nullptr;
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffCharIsEnglishAlphabet(char c) {
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffCharIsDigit(char c) {
return '0' <= c && c <= '9';
}
@@ -99,7 +96,7 @@ uint8_t ffUtf8CharLenWidth(const char* str, uint32_t length, uint8_t* width);
uint32_t ffUtf8StrWidth(const char* str, uint32_t length);
FF_A_ALWAYS_INLINE
[[gnu::always_inline]]
static inline bool ffCharIsHexDigit(char c) {
return ffCharIsDigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F');
}
+5 -5
View File
@@ -7,11 +7,11 @@
#ifdef __OpenBSD__
const char* ffSysctlGetString(int mib1, int mib2, FFstrbuf* result);
FF_A_NODISCARD int ffSysctlGetInt(int mib1, int mib2, int defaultValue);
FF_A_NODISCARD int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue);
[[nodiscard]] int ffSysctlGetInt(int mib1, int mib2, int defaultValue);
[[nodiscard]] int64_t ffSysctlGetInt64(int mib1, int mib2, int64_t defaultValue);
#else
const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
FF_A_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
FF_A_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
[[nodiscard]] int ffSysctlGetInt(const char* propName, int defaultValue);
[[nodiscard]] int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
#endif
FF_A_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
[[nodiscard]] void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);
+3 -3
View File
@@ -90,7 +90,7 @@ static inline FFThreadType ffThreadCreate(void* (*func)(void*), void* data) {
static inline void ffThreadDetach(FFThreadType thread) {
pthread_detach(thread);
}
static inline bool ffThreadJoin(FFThreadType thread, FF_A_UNUSED uint32_t timeout) {
static inline bool ffThreadJoin(FFThreadType thread, [[maybe_unused]] uint32_t timeout) {
#if HAVE_TIMEDJOIN_NP
if (timeout > 0) {
struct timespec ts;
@@ -115,7 +115,7 @@ static inline uintptr_t ffThreadGetCurrentId() {
#else // FF_HAVE_THREADS
#define FF_THREAD_MUTEX_INITIALIZER 0
typedef char FFThreadMutex;
static inline void ffThreadMutexLock(FF_A_UNUSED FFThreadMutex* mutex) {}
static inline void ffThreadMutexUnlock(FF_A_UNUSED FFThreadMutex* mutex) {}
static inline void ffThreadMutexLock([[maybe_unused]] FFThreadMutex* mutex) {}
static inline void ffThreadMutexUnlock([[maybe_unused]] FFThreadMutex* mutex) {}
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType)
#endif // FF_HAVE_THREADS
+1 -2
View File
@@ -1,6 +1,5 @@
#pragma once
#include "common/attributes.h"
#include <assert.h>
#include <unknwn.h>
@@ -20,4 +19,4 @@ static inline void ffReleaseComObject(void* ppUnknown) {
}
}
#define FF_AUTO_RELEASE_COM_OBJECT FF_A_CLEANUP(ffReleaseComObject)
#define FF_AUTO_RELEASE_COM_OBJECT [[gnu::cleanup(ffReleaseComObject)]]
-2
View File
@@ -49,6 +49,4 @@ static inline void ffCloseWmiBlock(HANDLE* hBlock) {
}
}
#define FF_AUTO_CLOSE_WMI_BLOCK __attribute__((cleanup(ffCloseWmiBlock)))
// MOF: https://github.com/tpn/winsdk-10/blob/master/Include/10.0.16299.0/km/wmicore.mof
+1 -1
View File
@@ -21,7 +21,7 @@ static const char* parseTermuxApi(FFBatteryOptions* options, FFlist* results) {
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
}
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr);
[[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr);
if (!doc) {
return "Failed to parse battery info";
}
+1 -1
View File
@@ -8,7 +8,7 @@
#include <sys/fcntl.h>
#include <unistd.h>
const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) {
const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) {
// https://www.freebsd.org/cgi/man.cgi?acpi_battery(4)
// https://gitlab.xfce.org/panel-plugins/xfce4-battery-plugin/-/blob/master/panel-plugin/libacpi.c
+1 -1
View File
@@ -53,7 +53,7 @@ const char* parseBattery(int dfd, const char* battId, FFlist* results) {
return nullptr;
}
const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) {
const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) {
FF_AUTO_CLOSE_DIR DIR* dir = opendir("/dev/power/acpi_battery/");
if (!dir) {
return "opendir(/dev/power/acpi_battery) failed";
+1 -1
View File
@@ -14,7 +14,7 @@
#include <unistd.h>
#include <fcntl.h>
const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* results) {
const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* results) {
FF_AUTO_CLOSE_FD int fd = open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed";
+1 -1
View File
@@ -6,7 +6,7 @@
#include <unistd.h>
#include <fcntl.h>
const char* ffDetectBattery(FF_A_UNUSED FFBatteryOptions* options, FFlist* result) {
const char* ffDetectBattery([[maybe_unused]] FFBatteryOptions* options, FFlist* result) {
FF_AUTO_CLOSE_FD int devfd = open("/dev/apm", O_RDONLY | O_CLOEXEC);
if (devfd < 0) {
+1 -1
View File
@@ -51,7 +51,7 @@ static FFBatteryWmiEntry* getBatteryEntry(FFlist* entries, FFlist* results, ULON
}
static const char* queryWmiAllData(const GUID* guid, const char* guidStr, PWNODE_ALL_DATA* pAllData, ULONG* pBufferSize) {
FF_AUTO_CLOSE_WMI_BLOCK HANDLE hBlock = nullptr;
[[gnu::cleanup(ffCloseWmiBlock)]] HANDLE hBlock = nullptr;
ULONG status = WmiOpenBlock(guid, WMIGUID_QUERY, &hBlock);
if (status != ERROR_SUCCESS) {
FF_DEBUG("WMI: WmiOpenBlock() failed for %s: %s", guidStr, ffDebugWin32Error(status));
+1 -1
View File
@@ -1,5 +1,5 @@
#include "bios.h"
const char* ffDetectBios(FF_A_UNUSED FFBiosResult* bios) {
const char* ffDetectBios([[maybe_unused]] FFBiosResult* bios) {
return "Not supported on this platform";
}
+2 -2
View File
@@ -19,7 +19,7 @@
#include <IOKit/IOKitLib.h>
#endif
typedef struct FFSmbiosBios {
typedef struct [[gnu::packed]] FFSmbiosBios {
FFSmbiosHeader Header;
uint8_t Vendor; // string
@@ -38,7 +38,7 @@ typedef struct FFSmbiosBios {
// 3.1+
uint16_t ExtendedBiosRomSize; // bit field
} FF_A_PACKED FFSmbiosBios;
} FFSmbiosBios;
static_assert(offsetof(FFSmbiosBios, ExtendedBiosRomSize) == 0x18,
"FFSmbiosBios: Wrong struct alignment");
+2 -2
View File
@@ -3,7 +3,7 @@
#define L2CAP_SOCKET_CHECKED
#include <bluetooth.h>
static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist* devices) {
static int enumDev([[maybe_unused]] int sockfd, struct bt_devinfo const* dev, FFlist* devices) {
FFBluetoothResult* device = FF_LIST_ADD(FFBluetoothResult, *devices);
ffStrbufInitS(&device->name,
#if __FreeBSD__
@@ -20,7 +20,7 @@ static int enumDev(FF_A_UNUSED int sockfd, struct bt_devinfo const* dev, FFlist*
return 0;
}
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) {
const char* ffDetectBluetooth([[maybe_unused]] FFBluetoothOptions* options, [[maybe_unused]] FFlist* devices /* FFBluetoothResult */) {
// struct hostent* ent = bt_gethostent();
if (bt_devenum((void*) enumDev, devices) < 0) {
return "bt_devenum() failed";
+1 -1
View File
@@ -5,7 +5,7 @@ extern "C" {
#include <bluetooth/LocalDevice.h>
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) {
const char* ffDetectBluetooth([[maybe_unused]] FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) {
using namespace Bluetooth;
FF_SUPPRESS_IO();
@@ -1,5 +1,5 @@
#include "bluetooth.h"
const char* ffDetectBluetooth(FF_A_UNUSED FFBluetoothOptions* options, FF_A_UNUSED FFlist* devices /* FFBluetoothResult */) {
const char* ffDetectBluetooth([[maybe_unused]] FFBluetoothOptions* options, [[maybe_unused]] FFlist* devices /* FFBluetoothResult */) {
return "Not supported on this platform";
}
+1 -1
View File
@@ -38,7 +38,7 @@ static const char* ffBluetoothDetectBattery(FFlist* devices) {
return nullptr;
}
wchar_t* FF_AUTO_FREE idList = (wchar_t*) malloc((size_t) idListLength * sizeof(wchar_t));
FF_AUTO_FREE wchar_t* idList = (wchar_t*) malloc((size_t) idListLength * sizeof(wchar_t));
if (!idList) {
return "malloc() failed";
}
@@ -1,5 +1,5 @@
#include "bluetoothradio.h"
const char* ffDetectBluetoothRadio(FF_A_UNUSED FFlist* devices /* FFBluetoothRadioResult */) {
const char* ffDetectBluetoothRadio([[maybe_unused]] FFlist* devices /* FFBluetoothRadioResult */) {
return "Not supported on this platform";
}
@@ -14,7 +14,7 @@
#define IOCTL_BTH_GET_LOCAL_INFO BTH_CTL(BTH_IOCTL_BASE + 0x00)
#define LMP_LE_SUPPORTED(x) ((x >> 38) & 1)
typedef struct _BTH_RADIO_INFO {
typedef struct [[gnu::packed]] _BTH_RADIO_INFO {
// Supported LMP features of the radio. Use LMP_XXX() to extract
// the desired bits.
ULONGLONG lmpSupportedFeatures;
@@ -27,9 +27,9 @@ typedef struct _BTH_RADIO_INFO {
// LMP version
UCHAR lmpVersion;
} FF_A_PACKED BTH_RADIO_INFO;
} BTH_RADIO_INFO;
typedef struct _BTH_LOCAL_RADIO_INFO {
typedef struct [[gnu::packed]] _BTH_LOCAL_RADIO_INFO {
// Local BTH_ADDR, class of device, and radio name
BTH_DEVICE_INFO localInfo;
@@ -44,7 +44,7 @@ typedef struct _BTH_LOCAL_RADIO_INFO {
// More information about the local radio (LMP, MFG)
BTH_RADIO_INFO radioInfo;
} FF_A_PACKED BTH_LOCAL_RADIO_INFO;
} BTH_LOCAL_RADIO_INFO;
static_assert(sizeof(BTH_LOCAL_RADIO_INFO) == 292, "BTH_LOCAL_RADIO_INFO should be 292 bytes");
#pragma GCC diagnostic ignored "-Wpointer-sign"
+1 -1
View File
@@ -1,5 +1,5 @@
#include "board.h"
const char* ffDetectBoard(FF_A_UNUSED FFBoardResult* board) {
const char* ffDetectBoard([[maybe_unused]] FFBoardResult* board) {
return "Not supported on this platform";
}
+2 -2
View File
@@ -1,7 +1,7 @@
#include "board.h"
#include "common/smbios.h"
typedef struct FFSmbiosBaseboard {
typedef struct [[gnu::packed]] FFSmbiosBaseboard {
FFSmbiosHeader Header;
uint8_t Manufacturer; // string
@@ -15,7 +15,7 @@ typedef struct FFSmbiosBaseboard {
uint8_t BoardType; // enum
uint8_t NumberOfContainedObjectHandles; // varies
uint16_t ContainedObjectHandles[]; // varies
} FF_A_PACKED FFSmbiosBaseboard;
} FFSmbiosBaseboard;
static_assert(offsetof(FFSmbiosBaseboard, ContainedObjectHandles) == 0x0F,
"FFSmbiosBaseboard: Wrong struct alignment");
+1 -1
View File
@@ -1,5 +1,5 @@
#include "bootmgr.h"
const char* ffDetectBootmgr(FF_A_UNUSED FFBootmgrResult* result) {
const char* ffDetectBootmgr([[maybe_unused]] FFBootmgrResult* result) {
return "Not supported on this platform";
}
+8 -8
View File
@@ -9,21 +9,21 @@
// DDC/CI
#ifdef __aarch64__
typedef CFTypeRef IOAVServiceRef;
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator) FF_A_WEAK_IMPORT;
extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service) FF_A_WEAK_IMPORT;
extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2) FF_A_WEAK_IMPORT;
extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize) FF_A_WEAK_IMPORT;
extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize) FF_A_WEAK_IMPORT;
[[clang::weak_import]] extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator);
[[clang::weak_import]] extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service);
[[clang::weak_import]] extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2);
[[clang::weak_import]] extern IOReturn IOAVServiceReadI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t offset, void* outputBuffer, uint32_t outputBufferSize);
[[clang::weak_import]] extern IOReturn IOAVServiceWriteI2C(IOAVServiceRef service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize);
#else
// DDC/CI (Intel)
#include <IOKit/IOKitLib.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <IOKit/i2c/IOI2CInterface.h>
extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service) FF_A_WEAK_IMPORT;
[[clang::weak_import]] extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service);
#endif
// ACPI
extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* brightness) FF_A_WEAK_IMPORT;
[[clang::weak_import]] extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float* brightness);
// Works for internal display
static const char* detectWithDisplayServices(const FFDisplayServerResult* displayServer, FFlist* result) {
@@ -51,7 +51,7 @@ static const char* detectWithDisplayServices(const FFDisplayServerResult* displa
#ifdef __aarch64__
// https://github.com/waydabber/m1ddc
// Works for Apple Silicon and USB-C adapter connection ( but not HTMI )
static const char* detectWithDdcci(FF_A_UNUSED const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) {
static const char* detectWithDdcci([[maybe_unused]] const FFDisplayServerResult* displayServer, FFBrightnessOptions* options, FFlist* result) {
if (!IOAVServiceCreate || !IOAVServiceReadI2C || !IOAVServiceWriteI2C) {
return "IOAVService is not available";
}
+5 -5
View File
@@ -12,7 +12,7 @@
#if __has_include(<dev/iicbus/iic.h>)
#include <dev/iicbus/iic.h>
const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
const char* detectWithDdcci([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
// FIXME: doesn't work for me
for (char i = '0'; i <= '9'; ++i) {
char path[] = "/dev/iic0";
@@ -74,7 +74,7 @@ const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* re
#else
const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) {
const char* detectWithDdcci([[maybe_unused]] FFBrightnessOptions* options, [[maybe_unused]] FFlist* result) {
FF_DEBUG("DDC/CI support is not available on this system");
return "DDC/CI is supported only on FreeBSD";
}
@@ -84,7 +84,7 @@ const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSE
#if __has_include(<sys/backlight.h>)
#include <sys/backlight.h>
const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
const char* detectWithBacklight([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
// https://man.freebsd.org/cgi/man.cgi?query=backlight&sektion=9
char path[] = "/dev/backlight/backlight0";
@@ -130,14 +130,14 @@ const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FFlist
#else
const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) {
const char* detectWithBacklight([[maybe_unused]] FFBrightnessOptions* options, [[maybe_unused]] FFlist* result) {
FF_DEBUG("Backlight support is not available on this system");
return "Backlight is supported only on FreeBSD 13 and newer";
}
#endif
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
detectWithBacklight(options, result);
if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && result->length == 0) {
@@ -6,7 +6,7 @@ extern "C" {
#include <Application.h>
#include <Screen.h>
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
// We need a valid be_app to query the app_server here.
BApplication app("application/x-vnd.fastfetch-cli-fastfetch");
BScreen screen{}; // default screen is the main one
+2 -2
View File
@@ -90,7 +90,7 @@ double ddca_set_default_sleep_multiplier(double multiplier); // ddcutil 1.4
DDCA_Status ddca_init(const char* libopts, int syslog_level, int opts);
#endif
static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
static const char* detectWithDdcci([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
FF_LIBRARY_LOAD_MESSAGE(libddcutil, "libddcutil" FF_LIBRARY_EXTENSION, 5);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_display_info_list2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_open_display2)
@@ -158,7 +158,7 @@ static const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFl
}
#endif
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
detectWithBacklight(result);
#ifdef FF_HAVE_DDCUTIL
+1 -1
View File
@@ -2,7 +2,7 @@
#include "common/sysctl.h"
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
// https://man.netbsd.org/NetBSD-10.1/acpiout.4#DESCRIPTION
char key[] = "hw.acpi.acpiout0.brightness";
char* pn = key + strlen("hw.acpi.acpiout");
@@ -1,5 +1,5 @@
#include "brightness.h"
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) {
const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, [[maybe_unused]] FFlist* result) {
return "Not supported on this platform";
}
+1 -1
View File
@@ -6,7 +6,7 @@
#include <unistd.h>
#include <fcntl.h>
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
char path[] = "/dev/ttyCX";
for (char i = '0'; i <= '9'; ++i) {
path[strlen("/dev/ttyC")] = i;
@@ -45,7 +45,7 @@ static const char* detectWithWmi(FFlist* result) {
0xd43412ac, 0x67f9, 0x4fbb, { 0xa0, 0x81, 0x17, 0x52, 0xa2, 0xc3, 0x3e, 0x84 }
};
FF_AUTO_CLOSE_WMI_BLOCK HANDLE hBlock = nullptr;
[[gnu::cleanup(ffCloseWmiBlock)]] HANDLE hBlock = nullptr;
ULONG status = WmiOpenBlock(&WmiMonitorBrightnessGuid, WMIGUID_QUERY, &hBlock);
if (status != 0) {
@@ -204,7 +204,7 @@ static bool hasBuiltinDisplay(const FFDisplayServerResult* displayServer) {
return false;
}
const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
const FFDisplayServerResult* displayServer = ffConnectDisplayServer();
FF_DEBUG("start, displayCount=%u", displayServer->displays.length);
+1 -1
View File
@@ -1,5 +1,5 @@
#include "btrfs.h"
const char* ffDetectBtrfs(FF_A_UNUSED FFlist* result) {
const char* ffDetectBtrfs([[maybe_unused]] FFlist* result) {
return "Not supported on this platform";
}
+2 -2
View File
@@ -13,14 +13,14 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) {
}
}
const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
const char* ffDetectCamera([[maybe_unused]] FFlist* result) {
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, nullptr })) {
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
}
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr);
[[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr);
if (!doc) {
return "Failed to parse camera info";
}
+1 -1
View File
@@ -8,7 +8,7 @@
#ifdef MAC_OS_VERSION_14_0
// To make fastfetch compiled on newer macOS versions runs on older ones
AVF_EXPORT FF_A_WEAK_IMPORT AVCaptureDeviceType const AVCaptureDeviceTypeExternal;
[[clang::weak_import]] AVF_EXPORT AVCaptureDeviceType const AVCaptureDeviceTypeExternal;
#endif
const char* ffDetectCamera(FFlist* result)
+1 -1
View File
@@ -1,5 +1,5 @@
#include "camera.h"
const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
const char* ffDetectCamera([[maybe_unused]] FFlist* result) {
return "Not support on this platform";
}
+7 -7
View File
@@ -10,7 +10,7 @@ extern "C" {
#include <mfapi.h>
#include <mfidl.h>
extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
extern "C" const char* ffDetectCamera([[maybe_unused]] FFlist* result) {
FF_LIBRARY_LOAD_MESSAGE(mfplat, "mfplat" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mfplat, MFCreateAttributes)
FF_LIBRARY_LOAD_MESSAGE(mf, "mf" FF_LIBRARY_EXTENSION, 1)
@@ -21,7 +21,7 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
return error;
}
IMFAttributes* FF_AUTO_RELEASE_COM_OBJECT attrs = nullptr;
FF_AUTO_RELEASE_COM_OBJECT IMFAttributes* attrs = nullptr;
if (FAILED(ffMFCreateAttributes(&attrs, 1))) {
return "MFCreateAttributes() failed";
}
@@ -40,7 +40,7 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
}
for (uint32_t i = 0; i < count; i++) {
IMFActivate* FF_AUTO_RELEASE_COM_OBJECT device = devices[i];
FF_AUTO_RELEASE_COM_OBJECT IMFActivate* device = devices[i];
wchar_t buffer[256];
uint32_t length = 0;
@@ -60,25 +60,25 @@ extern "C" const char* ffDetectCamera(FF_A_UNUSED FFlist* result) {
ffStrbufSetNWS(&camera->id, length, buffer);
}
IMFMediaSource* FF_AUTO_RELEASE_COM_OBJECT source = nullptr;
FF_AUTO_RELEASE_COM_OBJECT IMFMediaSource* source = nullptr;
if (FAILED(device->ActivateObject(IID_PPV_ARGS(&source)))) {
continue;
}
on_scope_exit destroySource([&] { source->Shutdown(); });
IMFPresentationDescriptor* FF_AUTO_RELEASE_COM_OBJECT pd = nullptr;
FF_AUTO_RELEASE_COM_OBJECT IMFPresentationDescriptor* pd = nullptr;
if (FAILED(source->CreatePresentationDescriptor(&pd))) {
continue;
}
IMFStreamDescriptor* FF_AUTO_RELEASE_COM_OBJECT sd = nullptr;
FF_AUTO_RELEASE_COM_OBJECT IMFStreamDescriptor* sd = nullptr;
BOOL selected;
if (FAILED(pd->GetStreamDescriptorByIndex(0, &selected, &sd))) {
continue;
}
IMFMediaTypeHandler* FF_AUTO_RELEASE_COM_OBJECT handler = nullptr;
FF_AUTO_RELEASE_COM_OBJECT IMFMediaTypeHandler* handler = nullptr;
if (FAILED(sd->GetMediaTypeHandler(&handler))) {
continue;
}
+1 -1
View File
@@ -1,5 +1,5 @@
#include "chassis.h"
const char* ffDetectChassis(FF_A_UNUSED FFChassisResult* result) {
const char* ffDetectChassis([[maybe_unused]] FFChassisResult* result) {
return "Not supported on this platform";
}
+2 -2
View File
@@ -2,7 +2,7 @@
#include "common/smbios.h"
// 7.4
typedef struct FFSmbiosSystemEnclosure {
typedef struct [[gnu::packed]] FFSmbiosSystemEnclosure {
FFSmbiosHeader Header;
uint8_t Manufacturer; // string
@@ -24,7 +24,7 @@ typedef struct FFSmbiosSystemEnclosure {
uint8_t ContainedElementCount; // varies
uint8_t ContainedRecordLength; // varies
uint8_t ContainedElements[]; // varies
} FF_A_PACKED FFSmbiosSystemEnclosure;
} FFSmbiosSystemEnclosure;
static_assert(offsetof(FFSmbiosSystemEnclosure, ContainedElements) == 0x15,
"FFSmbiosSystemEnclosure: Wrong struct alignment");
+7 -7
View File
@@ -278,7 +278,7 @@ static const FFCodecMftEncoderSubtype FF_D3D11VA_MFT_ENCODER_SUBTYPES[] = {
};
static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, __typeof__(&D3D11CreateDevice) ffD3D11CreateDevice) {
ID3D11Device* FF_AUTO_RELEASE_COM_OBJECT d3dDevice = nullptr;
FF_AUTO_RELEASE_COM_OBJECT ID3D11Device* d3dDevice = nullptr;
D3D_FEATURE_LEVEL featureLevel;
if (FAILED(ffD3D11CreateDevice(
adapter,
@@ -295,7 +295,7 @@ static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, __typeof__(&D
return FF_CODEC_TYPE_NONE;
}
ID3D11VideoDevice* FF_AUTO_RELEASE_COM_OBJECT videoDevice = nullptr;
FF_AUTO_RELEASE_COM_OBJECT ID3D11VideoDevice* videoDevice = nullptr;
if (FAILED(d3dDevice->QueryInterface(__uuidof(ID3D11VideoDevice), (void**) &videoDevice)) || !videoDevice) {
return FF_CODEC_TYPE_NONE;
}
@@ -320,7 +320,7 @@ static FFCodecType ffDetectD3d11vaDecoders(IDXGIAdapter1* adapter, __typeof__(&D
}
static FFCodecType ffDetectD3d11MftEncoders(const LUID& adapterLuid, __typeof__(&MFCreateAttributes) ffMFCreateAttributes, __typeof__(&MFTEnum2) ffMFTEnum2) {
IMFAttributes* FF_AUTO_RELEASE_COM_OBJECT attributes = nullptr;
FF_AUTO_RELEASE_COM_OBJECT IMFAttributes* attributes = nullptr;
if (FAILED(ffMFCreateAttributes(&attributes, 1)) || !attributes) {
return FF_CODEC_TYPE_NONE;
}
@@ -382,7 +382,7 @@ static FFCodecType ffCodecEncoderToType(D3D12_VIDEO_ENCODER_CODEC codec) {
template <typename Func>
static void ffEnumHardwareAdapters(IDXGIFactory1* factory, Func&& onAdapter) {
for (UINT adapterIndex = 0;; ++adapterIndex) {
IDXGIAdapter1* FF_AUTO_RELEASE_COM_OBJECT adapter = nullptr;
FF_AUTO_RELEASE_COM_OBJECT IDXGIAdapter1* adapter = nullptr;
HRESULT adapterStatus = factory->EnumAdapters1(adapterIndex, &adapter);
if (adapterStatus == DXGI_ERROR_NOT_FOUND) {
break;
@@ -468,7 +468,7 @@ const char* detectD3d12va(FFCodecOptions* options, FFlist* result /*list of FFCo
const uint32_t resultLengthBefore = result->length;
ffEnumHardwareAdapters(factory, [&](IDXGIAdapter1* adapter, const DXGI_ADAPTER_DESC1& desc) {
ID3D12Device* FF_AUTO_RELEASE_COM_OBJECT d3dDevice = nullptr;
FF_AUTO_RELEASE_COM_OBJECT ID3D12Device* d3dDevice = nullptr;
if (FAILED(ffD3D12CreateDevice(
adapter,
D3D_FEATURE_LEVEL_11_0,
@@ -478,7 +478,7 @@ const char* detectD3d12va(FFCodecOptions* options, FFlist* result /*list of FFCo
return;
}
ID3D12VideoDevice* FF_AUTO_RELEASE_COM_OBJECT videoDevice = nullptr;
FF_AUTO_RELEASE_COM_OBJECT ID3D12VideoDevice* videoDevice = nullptr;
if (FAILED(d3dDevice->QueryInterface(__uuidof(ID3D12VideoDevice), (void**) &videoDevice)) || !videoDevice) {
return;
}
@@ -538,7 +538,7 @@ const char* ffDetectCodecNative(FFCodecOptions* options, FFlist* result /*list o
return error;
}
IDXGIFactory1* FF_AUTO_RELEASE_COM_OBJECT factory = nullptr;
FF_AUTO_RELEASE_COM_OBJECT IDXGIFactory1* factory = nullptr;
if (FAILED(ffCreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**) &factory)) || !factory) {
return "CreateDXGIFactory1() failed";
}
+2 -2
View File
@@ -510,14 +510,14 @@ void ffCPUDetectByCpuid(FFCPUResult* cpu) {
}
}
#else
void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) {
void ffCPUDetectByCpuid([[maybe_unused]] FFCPUResult* cpu) {
// Unsupported system
}
#endif
#else
void ffCPUDetectByCpuid(FF_A_UNUSED FFCPUResult* cpu) {
void ffCPUDetectByCpuid([[maybe_unused]] FFCPUResult* cpu) {
// Unsupported architecture
}
+1 -1
View File
@@ -4,7 +4,7 @@
#include <OS.h>
#include <private/shared/cpu_type.h>
const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FFCPUResult* cpu) {
const char* ffDetectCPUImpl([[maybe_unused]] const FFCPUOptions* options, FFCPUResult* cpu) {
system_info sysInfo;
if (get_system_info(&sysInfo) != B_OK) {
return "get_system_info() failed";
+11 -11
View File
@@ -546,11 +546,11 @@ static void detectArmName(FFstrbuf* cpuinfo, FFCPUResult* cpu, uint32_t implId)
static const char* parseCpuInfo(
FFstrbuf* cpuinfo,
FFCPUResult* cpu,
FF_A_UNUSED FFstrbuf* physicalCoresBuffer,
FF_A_UNUSED FFstrbuf* cpuMHz,
FF_A_UNUSED FFstrbuf* cpuIsa,
FF_A_UNUSED FFstrbuf* cpuUarch,
FF_A_UNUSED FFstrbuf* cpuImplementer) {
[[maybe_unused]] FFstrbuf* physicalCoresBuffer,
[[maybe_unused]] FFstrbuf* cpuMHz,
[[maybe_unused]] FFstrbuf* cpuIsa,
[[maybe_unused]] FFstrbuf* cpuUarch,
[[maybe_unused]] FFstrbuf* cpuImplementer) {
char* line = nullptr;
size_t len = 0;
@@ -681,7 +681,7 @@ static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options) {
#if __i386__ || __x86_64__
FF_A_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) {
[[maybe_unused]] static uint16_t getPackageCount(FFstrbuf* cpuinfo) {
const char* p = cpuinfo->chars;
uint64_t low = 0, high = 0;
@@ -700,7 +700,7 @@ FF_A_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo) {
return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high));
}
FF_A_UNUSED static const char* detectCPUX86(const FFCPUOptions* options, FFCPUResult* cpu) {
[[maybe_unused]] static const char* detectCPUX86(const FFCPUOptions* options, FFCPUResult* cpu) {
FF_STRBUF_AUTO_DESTROY cpuinfo = ffStrbufCreateA(PROC_FILE_BUFFSIZ);
if (!ffReadFileBuffer(FF_CPUINFO_PATH, &cpuinfo) || cpuinfo.length == 0) {
return "ffReadFileBuffer(\"" FF_CPUINFO_PATH "\") failed";
@@ -813,7 +813,7 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) {
return nullptr;
}
FF_A_UNUSED static void parseIsa(FFstrbuf* cpuIsa) {
[[maybe_unused]] static void parseIsa(FFstrbuf* cpuIsa) {
// Always use the last part of the ISA string. Ref: #590 #1204
ffStrbufSubstrAfterLastC(cpuIsa, ' ');
@@ -833,7 +833,7 @@ FF_A_UNUSED static void parseIsa(FFstrbuf* cpuIsa) {
}
}
FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
[[maybe_unused]] static void detectSocName(FFCPUResult* cpu) {
if (cpu->name.length > 0) {
return;
}
@@ -953,7 +953,7 @@ FF_A_UNUSED static void detectSocName(FFCPUResult* cpu) {
}
#ifdef __loongarch__
FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) {
[[maybe_unused]] static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char* key) {
const char* p = cpuinfo->chars;
uint64_t low = 0, high = 0;
uint32_t keylen = (uint32_t) strlen(key);
@@ -974,7 +974,7 @@ FF_A_UNUSED static uint16_t getLoongarchPropCount(FFstrbuf* cpuinfo, const char*
}
#endif
FF_A_UNUSED static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) {
[[maybe_unused]] static const char* detectCPUOthers(const FFCPUOptions* options, FFCPUResult* cpu) {
cpu->coresLogical = (uint16_t) get_nprocs_conf();
cpu->coresOnline = (uint16_t) get_nprocs();
+1 -1
View File
@@ -23,7 +23,7 @@ static const char* detectCpuTemp(const FFCPUOptions* options, double* current) {
return "open(_PATH_SYSMON, O_RDONLY | O_CLOEXEC) failed";
}
FF_A_CLEANUP(freePropDict) prop_dictionary_t root = nullptr;
[[gnu::cleanup(freePropDict)]] prop_dictionary_t root = nullptr;
if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &root) < 0) {
return "prop_dictionary_recv_ioctl(ENVSYS_GETDICTIONARY) failed";
}
+1 -1
View File
@@ -1,5 +1,5 @@
#include "cpu.h"
const char* ffDetectCPUImpl(FF_A_UNUSED const FFCPUOptions* options, FF_A_UNUSED FFCPUResult* cpu) {
const char* ffDetectCPUImpl([[maybe_unused]] const FFCPUOptions* options, [[maybe_unused]] FFCPUResult* cpu) {
return "Not supported on this platform";
}
+1 -1
View File
@@ -99,7 +99,7 @@ static inline uint16_t countTypeId(kstat_ctl_t* kc, const char* type) {
}
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) {
FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open();
[[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open();
if (!kc) {
return "kstat_open() failed";
}
+4 -4
View File
@@ -77,7 +77,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
}
}
FF_A_CLEANUP(ffPerfCloseQueryHandle)
[[gnu::cleanup(ffPerfCloseQueryHandle)]]
HANDLE hQuery = nullptr;
if (PerfOpenQueryHandle(nullptr, &hQuery) != ERROR_SUCCESS) {
@@ -139,7 +139,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
}
// 7.5
typedef struct FFSmbiosProcessorInfo {
typedef struct [[gnu::packed]] FFSmbiosProcessorInfo {
FFSmbiosHeader Header;
uint8_t SocketDesignation; // string
@@ -181,7 +181,7 @@ typedef struct FFSmbiosProcessorInfo {
// 3.6+
uint16_t ThreadEnabled; // varies
} FF_A_PACKED FFSmbiosProcessorInfo;
} FFSmbiosProcessorInfo;
static_assert(offsetof(FFSmbiosProcessorInfo, ThreadEnabled) == 0x30,
"FFSmbiosProcessorInfo: Wrong struct alignment");
@@ -238,7 +238,7 @@ static const char* detectNCores(const FFCPUOptions* options, FFCPUResult* cpu) {
return "GetLogicalProcessorInformationEx(RelationAll, nullptr, &length) failed";
}
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
FF_AUTO_FREE SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*) malloc(length);
if (!NT_SUCCESS(NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), pProcessorInfo, length, &length))) {
+1 -1
View File
@@ -1,5 +1,5 @@
#include "cpucache.h"
const char* ffDetectCPUCache(FF_A_UNUSED FFCPUCacheResult* result) {
const char* ffDetectCPUCache([[maybe_unused]] FFCPUCacheResult* result) {
return "Not supported on this platform";
}
+2 -2
View File
@@ -2,7 +2,7 @@
#include "common/smbios.h"
#include "common/strutil.h"
typedef struct FFSmbiosCacheInfo {
typedef struct [[gnu::packed]] FFSmbiosCacheInfo {
FFSmbiosHeader Header;
uint8_t SocketDesignation; // string
@@ -21,7 +21,7 @@ typedef struct FFSmbiosCacheInfo {
// 3.1+
uint32_t MaximumCacheSize2; // bit field
uint32_t InstalledCacheSize2; // bit field
} FF_A_PACKED FFSmbiosCacheInfo;
} FFSmbiosCacheInfo;
static_assert(offsetof(FFSmbiosCacheInfo, InstalledCacheSize2) == 0x17,
"FFSmbiosCacheInfo: Wrong struct alignment");
+1 -1
View File
@@ -10,7 +10,7 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) {
return "GetLogicalProcessorInformationEx(RelationCache, nullptr, &length) failed";
}
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
FF_AUTO_FREE SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*) malloc(length);
if (!NT_SUCCESS(NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), pProcessorInfo, length, &length))) {
+1 -1
View File
@@ -1,6 +1,6 @@
#include "fastfetch.h"
#include "detection/cpuusage/cpuusage.h"
const char* ffGetCpuUsageInfo(FF_A_UNUSED FFlist* cpuTimes) {
const char* ffGetCpuUsageInfo([[maybe_unused]] FFlist* cpuTimes) {
return "Not support on this platform";
}
+1 -1
View File
@@ -12,7 +12,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
}
const char* ffGetCpuUsageInfo(FFlist* cpuTimes) {
FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open();
[[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open();
if (!kc) {
return "kstat_open() failed";
}
+1 -1
View File
@@ -14,7 +14,7 @@ static const char* getInfoByNqsi(FFlist* cpuTimes) {
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr) failed";
}
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* FF_AUTO_FREE pinfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*) malloc(size);
FF_AUTO_FREE SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* pinfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*) malloc(size);
if (!NT_SUCCESS(NtQuerySystemInformation(SystemProcessorPerformanceInformation, pinfo, size, &size))) {
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, size) failed";
}
+1 -1
View File
@@ -1,5 +1,5 @@
#include "cursor.h"
void ffDetectCursor(FF_A_UNUSED FFCursorResult* result) {
void ffDetectCursor([[maybe_unused]] FFCursorResult* result) {
ffStrbufInitS(&result->error, "Not supported on this platform");
}
+13 -13
View File
@@ -22,7 +22,7 @@
#define _PATH_LOCALBASE "/usr/pkg"
#endif
static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getKDE(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
#ifdef _PATH_LOCALBASE
ffParsePropFile(_PATH_LOCALBASE "/share/wayland-sessions/plasma.desktop", "X-KDE-PluginInfo-Version =", result);
if (result->length == 0) {
@@ -56,7 +56,7 @@ static void getKDE(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
}
}
static const char* getGnomeByDbus(FF_A_UNUSED FFstrbuf* result) {
static const char* getGnomeByDbus([[maybe_unused]] FFstrbuf* result) {
#ifdef FF_HAVE_DBUS
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) {
@@ -70,7 +70,7 @@ static const char* getGnomeByDbus(FF_A_UNUSED FFstrbuf* result) {
#endif // FF_HAVE_DBUS
}
static void getGnome(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getGnome(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
getGnomeByDbus(result);
if (result->length == 0) {
@@ -80,7 +80,7 @@ static void getGnome(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
}
}
static void getCinnamon(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getCinnamon(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
ffStrbufSetS(result, getenv("CINNAMON_VERSION"));
if (result->length == 0) {
@@ -94,7 +94,7 @@ static void getCinnamon(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
}
}
static void getMate(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getMate(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
FF_STRBUF_AUTO_DESTROY major = ffStrbufCreate();
FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate();
FF_STRBUF_AUTO_DESTROY micro = ffStrbufCreate();
@@ -124,7 +124,7 @@ static const char* getXfce4ByLib(FFstrbuf* result) {
#endif
}
static void getXFCE4(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getXFCE4(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
getXfce4ByLib(result);
if (result->length == 0) {
@@ -137,7 +137,7 @@ static void getXFCE4(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
}
}
static void getLXQt(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getLXQt(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
ffParsePropFileData("gconfig/lxqt.pc", "Version:", result);
if (result->length == 0) {
@@ -156,11 +156,11 @@ static void getLXQt(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
}
}
static void getBudgie(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getBudgie(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
ffParsePropFileData("budgie/budgie-version.xml", "<str>", result);
}
static void getUnity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getUnity(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
if (ffParsePropFile("/usr/bin/unity", "parser = OptionParser(version= \"%prog ", result)) {
ffStrbufSubstrBeforeFirstC(result, '"');
}
@@ -177,7 +177,7 @@ static bool extractTdeVersion(const char* line, uint32_t len, void* userdata) {
return false;
}
static const char* getTrinity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static const char* getTrinity(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
const char* error = ffFindExecutableInPath("tde-config", &path);
if (error) {
@@ -200,7 +200,7 @@ static const char* getTrinity(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options
return "All methods failed";
}
static const char* getCosmic(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static const char* getCosmic(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
if (ffProcessAppendStdOut(result, (char* const[]) { "cosmic-comp", "--version", nullptr }) == nullptr) {
// cosmic-comp 0.1.0 (git commit fa88002ba41d2edec25dd7ffdee9719fbb928fc0)
ffStrbufSubstrAfterFirstC(result, ' ');
@@ -211,7 +211,7 @@ static const char* getCosmic(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options)
return "All methods failed";
}
static const char* getEnlightenmentByDbus(FF_A_UNUSED FFstrbuf* result) {
static const char* getEnlightenmentByDbus([[maybe_unused]] FFstrbuf* result) {
#ifdef FF_HAVE_DBUS
FF_DBUS_AUTO_DESTROY_DATA FFDBusData dbus = {};
if (ffDBusLoadData(DBUS_BUS_SESSION, &dbus) != nullptr) {
@@ -240,7 +240,7 @@ static const char* getEnlightenmentByDbus(FF_A_UNUSED FFstrbuf* result) {
#endif // FF_HAVE_DBUS
}
static void getEnlightenment(FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
static void getEnlightenment(FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
getEnlightenmentByDbus(result);
if (result->length == 0) {
+1 -1
View File
@@ -1,5 +1,5 @@
#include "de.h"
const char* ffDetectDEVersion(FF_A_UNUSED const FFstrbuf* deName, FF_A_UNUSED FFstrbuf* result, FF_A_UNUSED FFDEOptions* options) {
const char* ffDetectDEVersion([[maybe_unused]] const FFstrbuf* deName, [[maybe_unused]] FFstrbuf* result, [[maybe_unused]] FFDEOptions* options) {
return "Not supported on this platform";
}
+3 -3
View File
@@ -54,7 +54,7 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) {
return nullptr;
}
#else
static const char* detectFsLabel(FF_A_UNUSED struct statfs* fs, FF_A_UNUSED FFDisk* disk) {
static const char* detectFsLabel([[maybe_unused]] struct statfs* fs, [[maybe_unused]] FFDisk* disk) {
return "Fastfetch was compiled without libgeom support";
}
#endif
@@ -84,11 +84,11 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) {
#define MNT_REMOVABLE 0x00000200
#endif
struct CmnAttrBuf {
struct [[gnu::packed]] CmnAttrBuf {
uint32_t length;
attrreference_t nameRef;
char nameSpace[NAME_MAX * 3 + 1];
} FF_A_PACKED;
};
void detectFsInfo(struct statfs* fs, FFDisk* disk) {
if (fs->f_flags & MNT_DONTBROWSE) {
+1 -1
View File
@@ -162,7 +162,7 @@ static void detectName(FFDisk* disk) {
#ifdef __ANDROID__
static void detectType(FF_A_UNUSED const FFlist* disks, FFDisk* currentDisk, FF_A_UNUSED struct mntent* device) {
static void detectType([[maybe_unused]] const FFlist* disks, FFDisk* currentDisk, [[maybe_unused]] struct mntent* device) {
if (ffStrbufEqualS(&currentDisk->mountpoint, "/") || ffStrbufEqualS(&currentDisk->mountpoint, "/storage/emulated")) {
currentDisk->type = FF_DISK_VOLUME_TYPE_REGULAR_BIT;
} else if (ffStrbufStartsWithS(&currentDisk->mountpoint, "/mnt/media_rw/")) {
+1 -1
View File
@@ -1,5 +1,5 @@
#include "disk.h"
const char* ffDetectDisksImpl(FF_A_UNUSED FFDiskOptions* options, FF_A_UNUSED FFlist* disks) {
const char* ffDetectDisksImpl([[maybe_unused]] FFDiskOptions* options, [[maybe_unused]] FFlist* disks) {
return "Not supported on this platform";
}
+1 -1
View File
@@ -12,7 +12,7 @@
#include <libgeom.h>
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
FF_A_CLEANUP(geom_deletetree) struct gmesh geomTree = {};
[[gnu::cleanup(geom_deletetree)]] struct gmesh geomTree = {};
if (geom_gettree(&geomTree) < 0) {
return "geom_gettree() failed";
}
+1 -1
View File
@@ -1,5 +1,5 @@
#include "diskio.h"
const char* ffDiskIOGetIoCounters(FF_A_UNUSED FFlist* result, FF_A_UNUSED FFDiskIOOptions* options) {
const char* ffDiskIOGetIoCounters([[maybe_unused]] FFlist* result, [[maybe_unused]] FFDiskIOOptions* options) {
return "Not supported on this platform";
}
+1 -1
View File
@@ -10,7 +10,7 @@ static inline void kstatFreeWrap(kstat_ctl_t** pkc) {
}
const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) {
FF_A_CLEANUP(kstatFreeWrap) kstat_ctl_t* kc = kstat_open();
[[gnu::cleanup(kstatFreeWrap)]] kstat_ctl_t* kc = kstat_open();
if (!kc) {
return "kstat_open() failed";
}
@@ -12,9 +12,9 @@
#include <IOKit/IOKitLib.h>
#ifdef MAC_OS_X_VERSION_10_15
extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display) FF_A_WEAK_IMPORT;
extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display) FF_A_WEAK_IMPORT;
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display) FF_A_WEAK_IMPORT;
[[clang::weak_import]] extern Boolean CoreDisplay_Display_SupportsHDRMode(CGDirectDisplayID display);
[[clang::weak_import]] extern Boolean CoreDisplay_Display_IsHDRModeEnabled(CGDirectDisplayID display);
[[clang::weak_import]] extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID display);
#else
#include <IOKit/graphics/IOGraphicsLib.h>
#endif
@@ -50,7 +50,7 @@ static void detectDisplays(FFDisplayServerResult* ds) {
}
ffStrbufClear(&buffer);
CFDictionaryRef FF_CFTYPE_AUTO_RELEASE displayInfo = nullptr;
FF_CFTYPE_AUTO_RELEASE CFDictionaryRef displayInfo = nullptr;
#ifdef MAC_OS_X_VERSION_10_15
if (CoreDisplay_DisplayCreateInfoDictionary) {
displayInfo = CoreDisplay_DisplayCreateInfoDictionary(screen);
@@ -12,8 +12,7 @@ static inline void freeArgBuffer(FFArgBuffer* buffer) {
}
buffer->data = nullptr;
buffer->length = 0;
}
#define FF_AUTO_FREE_ARG_BUFFER FF_A_CLEANUP(freeArgBuffer)
}\
// http://undoc.airesoft.co.uk/user32.dll/IsThreadDesktopComposited.php
BOOL WINAPI IsThreadDesktopComposited();
@@ -47,7 +46,7 @@ static void detectDisplays(FFDisplayServerResult* ds) {
.id = path->targetInfo.id,
},
};
FF_AUTO_FREE_ARG_BUFFER FFArgBuffer edid = {};
[[gnu::cleanup(freeArgBuffer)]] FFArgBuffer edid = {};
if (DisplayConfigGetDeviceInfo(&targetName.header) == ERROR_SUCCESS) {
wchar_t regPath[256] = L"SYSTEM\\CurrentControlSet\\Enum";
wchar_t* pRegPath = regPath + strlen("SYSTEM\\CurrentControlSet\\Enum");
+2 -2
View File
@@ -175,7 +175,7 @@ static inline const char* drmType2Name(uint32_t connector_type) {
}
}
FF_A_UNUSED static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edidData, ssize_t* edidLength) {
[[maybe_unused]] static const char* drmGetEdidByConnId(uint32_t connId, uint8_t* edidData, ssize_t* edidLength) {
const char* drmDirPath = "/sys/class/drm/";
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(drmDirPath);
@@ -434,7 +434,7 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result) {
#endif
const char* ffdsConnectDrm(FF_A_UNUSED FFDisplayServerResult* result) {
const char* ffdsConnectDrm([[maybe_unused]] FFDisplayServerResult* result) {
#if FF_HAVE_DRM
if (instance.config.general.dsForceDrm != FF_DS_FORCE_DRM_TYPE_SYSFS_ONLY) {
if (drmConnectLibdrm(result) == nullptr) {
@@ -5,7 +5,7 @@
#include "xdg-output-unstable-v1-client-protocol.h"
#include "wp-color-management-v1-client-protocol.h"
static void waylandOutputModeListener(void* data, FF_A_UNUSED struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) {
static void waylandOutputModeListener(void* data, [[maybe_unused]] struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate) {
WaylandDisplay* display = data;
if (flags & WL_OUTPUT_MODE_CURRENT) {
@@ -20,20 +20,20 @@ static void waylandOutputModeListener(void* data, FF_A_UNUSED struct wl_output*
}
}
static void waylandOutputScaleListener(void* data, FF_A_UNUSED struct wl_output* output, int32_t scale) {
static void waylandOutputScaleListener(void* data, [[maybe_unused]] struct wl_output* output, int32_t scale) {
WaylandDisplay* display = data;
display->dpi = 96 * (uint32_t) scale;
}
static void waylandOutputGeometryListener(void* data,
FF_A_UNUSED struct wl_output* output,
FF_A_UNUSED int32_t x,
FF_A_UNUSED int32_t y,
[[maybe_unused]] struct wl_output* output,
[[maybe_unused]] int32_t x,
[[maybe_unused]] int32_t y,
int32_t physical_width,
int32_t physical_height,
FF_A_UNUSED int32_t subpixel,
FF_A_UNUSED const char* make,
FF_A_UNUSED const char* model,
[[maybe_unused]] int32_t subpixel,
[[maybe_unused]] const char* make,
[[maybe_unused]] const char* model,
int32_t transform) {
WaylandDisplay* display = data;
display->physicalWidth = physical_width;
@@ -41,7 +41,7 @@ static void waylandOutputGeometryListener(void* data,
display->transform = (enum wl_output_transform) transform;
}
static void handleXdgLogicalSize(void* data, FF_A_UNUSED struct zxdg_output_v1* _, int32_t width, FF_A_UNUSED int32_t height) {
static void handleXdgLogicalSize(void* data, [[maybe_unused]] struct zxdg_output_v1* _, int32_t width, [[maybe_unused]] int32_t height) {
WaylandDisplay* display = data;
// Seems the values are only useful when ractional scale is enabled
if (width < display->width) {
@@ -71,7 +71,7 @@ static struct zxdg_output_v1_listener zxdgOutputListener = {
.description = (void*) ffWaylandOutputDescriptionListener,
};
static void handleWpTfNamed(void *data, FF_A_UNUSED struct wp_image_description_info_v1* wp_image_description_info_v1, uint32_t tf) {
static void handleWpTfNamed(void *data, [[maybe_unused]] struct wp_image_description_info_v1* wp_image_description_info_v1, uint32_t tf) {
// KDE reports `gamma 2.2` even in HDR mode, but it should be handled in KDE specific path
WaylandDisplay* display = data;
switch (tf) {
@@ -13,18 +13,18 @@ typedef struct WaylandKdeMode {
struct kde_output_device_mode_v2* pMode;
} WaylandKdeMode;
static void waylandKdeModeSizeListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _, int32_t width, int32_t height) {
static void waylandKdeModeSizeListener(void* data, [[maybe_unused]] struct kde_output_device_mode_v2* _, int32_t width, int32_t height) {
WaylandKdeMode* mode = (WaylandKdeMode*) data;
mode->width = width;
mode->height = height;
}
static void waylandKdeModeRefreshListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _, int32_t rate) {
static void waylandKdeModeRefreshListener(void* data, [[maybe_unused]] struct kde_output_device_mode_v2* _, int32_t rate) {
WaylandKdeMode* mode = (WaylandKdeMode*) data;
mode->refreshRate = rate;
}
static void waylandKdeModePreferredListener(void* data, FF_A_UNUSED struct kde_output_device_mode_v2* _) {
static void waylandKdeModePreferredListener(void* data, [[maybe_unused]] struct kde_output_device_mode_v2* _) {
WaylandKdeMode* mode = (WaylandKdeMode*) data;
mode->preferred = true;
}
@@ -37,7 +37,7 @@ static const struct kde_output_device_mode_v2_listener modeListener = {
.flags = (void*) stubListener,
};
static void waylandKdeModeListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) {
static void waylandKdeModeListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) {
WaylandDisplay* wldata = (WaylandDisplay*) data;
if (!wldata->internal) {
return;
@@ -50,7 +50,7 @@ static void waylandKdeModeListener(void* data, FF_A_UNUSED struct kde_output_dev
wldata->parent->ffwl_proxy_add_listener((struct wl_proxy*) mode, (void (**)(void)) &modeListener, newMode);
}
static void waylandKdeCurrentModeListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) {
static void waylandKdeCurrentModeListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, struct kde_output_device_mode_v2* mode) {
// waylandKdeModeListener is always run before this
WaylandDisplay* wldata = (WaylandDisplay*) data;
if (!wldata->internal) {
@@ -78,12 +78,12 @@ static void waylandKdeCurrentModeListener(void* data, FF_A_UNUSED struct kde_out
}
}
static void waylandKdeScaleListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, wl_fixed_t scale) {
static void waylandKdeScaleListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, wl_fixed_t scale) {
WaylandDisplay* wldata = (WaylandDisplay*) data;
wldata->dpi = (uint32_t) scale * 3 / 8; // wl_fixed_to_double(scale) * 96;
}
static void waylandKdeEdidListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, const char* raw) {
static void waylandKdeEdidListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, const char* raw) {
if (!*raw) {
return;
}
@@ -100,7 +100,7 @@ static void waylandKdeEdidListener(void* data, FF_A_UNUSED struct kde_output_dev
wldata->hdrInfoAvailable = true;
}
static void waylandKdeEnabledListener(void* data, FF_A_UNUSED struct kde_output_device_v2* _, int32_t enabled) {
static void waylandKdeEnabledListener(void* data, [[maybe_unused]] struct kde_output_device_v2* _, int32_t enabled) {
WaylandDisplay* wldata = (WaylandDisplay*) data;
if (!enabled) {
wldata->internal = nullptr;
@@ -108,14 +108,14 @@ static void waylandKdeEnabledListener(void* data, FF_A_UNUSED struct kde_output_
}
static void waylandKdeGeometryListener(void* data,
FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2,
FF_A_UNUSED int32_t x,
FF_A_UNUSED int32_t y,
[[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2,
[[maybe_unused]] int32_t x,
[[maybe_unused]] int32_t y,
int32_t physical_width,
int32_t physical_height,
FF_A_UNUSED int32_t subpixel,
FF_A_UNUSED const char* make,
FF_A_UNUSED const char* model,
[[maybe_unused]] int32_t subpixel,
[[maybe_unused]] const char* make,
[[maybe_unused]] const char* model,
int32_t transform) {
WaylandDisplay* display = data;
display->physicalWidth = physical_width;
@@ -123,7 +123,7 @@ static void waylandKdeGeometryListener(void* data,
display->transform = (enum wl_output_transform) transform;
}
static void waylandKdeNameListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, const char* name) {
static void waylandKdeNameListener(void* data, [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, const char* name) {
WaylandDisplay* display = data;
display->type = ffdsGetDisplayType(name);
// As display->id is used as an internal identifier, we don't need it to be NUL terminated
@@ -132,17 +132,17 @@ static void waylandKdeNameListener(void* data, FF_A_UNUSED struct kde_output_dev
ffStrbufAppendS(&display->name, name);
}
static void waylandKdeHdrListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t hdr_enabled) {
static void waylandKdeHdrListener(void* data, [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, uint32_t hdr_enabled) {
WaylandDisplay* display = data;
display->hdrEnabled = !!hdr_enabled;
}
static void waylandKdeMaxBitsPerColorListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t max_bpc) {
static void waylandKdeMaxBitsPerColorListener(void* data, [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, uint32_t max_bpc) {
WaylandDisplay* display = data;
display->bitDepth = (uint8_t) max_bpc;
}
static void waylandKdePriorityListener(void* data, FF_A_UNUSED struct kde_output_device_v2* kde_output_device_v2, uint32_t priority) {
static void waylandKdePriorityListener(void* data, [[maybe_unused]] struct kde_output_device_v2* kde_output_device_v2, uint32_t priority) {
WaylandDisplay* display = data;
display->primary = priority == 1;
}
@@ -282,7 +282,7 @@ const char* ffWaylandHandleKdeOutput(WaylandData* wldata, struct wl_registry* re
return waylandKdeHandleOutput(wldata, output);
}
static void waylandKdeOutputListener(void* data, FF_A_UNUSED struct kde_output_device_registry_v2* kde_output_device_registry_v2, struct kde_output_device_v2* output) {
static void waylandKdeOutputListener(void* data, [[maybe_unused]] struct kde_output_device_registry_v2* kde_output_device_registry_v2, struct kde_output_device_v2* output) {
waylandKdeHandleOutput((WaylandData*) data, (struct wl_proxy*) output);
}
@@ -102,7 +102,7 @@ static void waylandGlobalAddListener(void* data, struct wl_registry* registry, u
}
}
static FF_A_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) {
[[maybe_unused]] static bool matchDrmConnector(const char* connName, WaylandDisplay* wldata) {
// https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-event-name
// The doc says that "do not assume that the name is a reflection of an underlying DRM connector, X11 connection, etc."
// However I can't find a better method to get the edid data
@@ -149,7 +149,7 @@ static FF_A_UNUSED bool matchDrmConnector(const char* connName, WaylandDisplay*
return false;
}
void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const char* name) {
void ffWaylandOutputNameListener(void* data, [[maybe_unused]] void* output, const char* name) {
WaylandDisplay* display = data;
if (display->id) {
return;
@@ -165,7 +165,7 @@ void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const cha
ffStrbufAppendS(&display->name, name);
}
void ffWaylandOutputDescriptionListener(void* data, FF_A_UNUSED void* output, const char* description) {
void ffWaylandOutputDescriptionListener(void* data, [[maybe_unused]] void* output, const char* description) {
WaylandDisplay* display = data;
if (display->description.length) {
return;
@@ -341,7 +341,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result) {
#else
const char* ffdsConnectWayland(FF_A_UNUSED FFDisplayServerResult* result) {
const char* ffdsConnectWayland([[maybe_unused]] FFDisplayServerResult* result) {
return "Fastfetch was compiled without Wayland support";
}
@@ -75,8 +75,8 @@ inline static uint64_t ffWaylandGenerateIdFromName(const char* name) {
return id;
}
void ffWaylandOutputNameListener(void* data, FF_A_UNUSED void* output, const char* name);
void ffWaylandOutputDescriptionListener(void* data, FF_A_UNUSED void* output, const char* description);
void ffWaylandOutputNameListener(void* data, [[maybe_unused]] void* output, const char* name);
void ffWaylandOutputDescriptionListener(void* data, [[maybe_unused]] void* output, const char* description);
// Modifies content of display. Don't call this function when calling ffdsAppendDisplay
uint32_t ffWaylandHandleRotation(WaylandDisplay* display);
+1 -1
View File
@@ -6,7 +6,7 @@
#include <iphlpapi.h>
const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = nullptr;
FF_AUTO_FREE IP_ADAPTER_ADDRESSES* adapter_addresses = nullptr;
// Multiple attempts in case interfaces change while
// we are in the middle of querying them.
+3 -3
View File
@@ -7,7 +7,7 @@
#include <stdlib.h>
static bool extractNvimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) {
static bool extractNvimVersionFromBinary(const char* str, [[maybe_unused]] uint32_t len, void* userdata) {
if (!ffStrStartsWith(str, "NVIM v")) {
return true;
}
@@ -15,7 +15,7 @@ static bool extractNvimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t l
return false;
}
static bool extractVimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) {
static bool extractVimVersionFromBinary(const char* str, [[maybe_unused]] uint32_t len, void* userdata) {
if (!ffStrStartsWith(str, "VIM - Vi IMproved ")) {
return true;
}
@@ -24,7 +24,7 @@ static bool extractVimVersionFromBinary(const char* str, FF_A_UNUSED uint32_t le
return false;
}
static bool extractNanoVersionFromBinary(const char* str, FF_A_UNUSED uint32_t len, void* userdata) {
static bool extractNanoVersionFromBinary(const char* str, [[maybe_unused]] uint32_t len, void* userdata) {
if (!ffStrStartsWith(str, "GNU nano ")) {
return true;
}
+1 -1
View File
@@ -1,7 +1,7 @@
#include "fastfetch.h"
#include "font.h"
const char* ffDetectFontImpl(FF_A_UNUSED FFFontResult* result) {
const char* ffDetectFontImpl([[maybe_unused]] FFFontResult* result) {
FF_UNUSED(result);
return "Not supported on this platform";
}

Some files were not shown because too many files have changed in this diff Show More