Global: unifies GCC attributes usage

This commit is contained in:
Carter Li
2026-04-09 16:20:59 +08:00
committed by 李通洲
parent 3e69361196
commit f6a363f7ad
233 changed files with 516 additions and 545 deletions
+4 -4
View File
@@ -79,7 +79,7 @@ void ffPrepareCommandOption(FFdata* data) {
case 'D':
case 'd':
FF_IF_MODULE_MATCH(FF_DISKIO_MODULE_NAME) {
__attribute__((__cleanup__(ffDestroyDiskIOOptions))) FFDiskIOOptions options;
FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options;
ffInitDiskIOOptions(&options);
ffPrepareDiskIO(&options);
}
@@ -88,7 +88,7 @@ void ffPrepareCommandOption(FFdata* data) {
case 'N':
case 'n':
FF_IF_MODULE_MATCH(FF_NETIO_MODULE_NAME) {
__attribute__((__cleanup__(ffDestroyNetIOOptions))) FFNetIOOptions options;
FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options;
ffInitNetIOOptions(&options);
ffPrepareNetIO(&options);
}
@@ -97,7 +97,7 @@ void ffPrepareCommandOption(FFdata* data) {
case 'P':
case 'p':
FF_IF_MODULE_MATCH(FF_PUBLICIP_MODULE_NAME) {
__attribute__((__cleanup__(ffDestroyPublicIpOptions))) FFPublicIPOptions options;
FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options;
ffInitPublicIpOptions(&options);
ffPreparePublicIp(&options);
}
@@ -106,7 +106,7 @@ void ffPrepareCommandOption(FFdata* data) {
case 'W':
case 'w':
FF_IF_MODULE_MATCH(FF_WEATHER_MODULE_NAME) {
__attribute__((__cleanup__(ffDestroyWeatherOptions))) FFWeatherOptions options;
FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options;
ffInitWeatherOptions(&options);
ffPrepareWeather(&options);
}
+2 -2
View File
@@ -86,12 +86,12 @@ static void resetConsole(void) {
}
#ifdef _WIN32
BOOL WINAPI consoleHandler(FF_MAYBE_UNUSED DWORD signal) {
BOOL WINAPI consoleHandler(FF_A_UNUSED DWORD signal) {
resetConsole();
exit(0);
}
#else
static void exitSignalHandler(FF_MAYBE_UNUSED int signal) {
static void exitSignalHandler(FF_A_UNUSED int signal) {
resetConsole();
exit(0);
}
+5 -5
View File
@@ -143,7 +143,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'c':
case 'C': {
if (ffStrEqualsIgnCase(type, FF_COMMAND_MODULE_NAME)) {
__attribute__((__cleanup__(ffDestroyCommandOptions))) FFCommandOptions options;
FF_A_CLEANUP(ffDestroyCommandOptions) FFCommandOptions options;
ffInitCommandOptions(&options);
if (module) {
ffCommandModuleInfo.parseJsonObject(&options, module);
@@ -155,7 +155,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'd':
case 'D': {
if (ffStrEqualsIgnCase(type, FF_DISKIO_MODULE_NAME)) {
__attribute__((__cleanup__(ffDestroyDiskIOOptions))) FFDiskIOOptions options;
FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options;
ffInitDiskIOOptions(&options);
if (module) {
ffDiskIOModuleInfo.parseJsonObject(&options, module);
@@ -167,7 +167,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'n':
case 'N': {
if (ffStrEqualsIgnCase(type, FF_NETIO_MODULE_NAME)) {
__attribute__((__cleanup__(ffDestroyNetIOOptions))) FFNetIOOptions options;
FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options;
ffInitNetIOOptions(&options);
if (module) {
ffNetIOModuleInfo.parseJsonObject(&options, module);
@@ -179,7 +179,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'p':
case 'P': {
if (ffStrEqualsIgnCase(type, FF_PUBLICIP_MODULE_NAME)) {
__attribute__((__cleanup__(ffDestroyPublicIpOptions))) FFPublicIPOptions options;
FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options;
ffInitPublicIpOptions(&options);
if (module) {
ffPublicIPModuleInfo.parseJsonObject(&options, module);
@@ -191,7 +191,7 @@ static void prepareModuleJsonObject(const char* type, yyjson_val* module) {
case 'w':
case 'W': {
if (ffStrEqualsIgnCase(type, FF_WEATHER_MODULE_NAME)) {
__attribute__((__cleanup__(ffDestroyWeatherOptions))) FFWeatherOptions options;
FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options;
ffInitWeatherOptions(&options);
if (module) {
ffWeatherModuleInfo.parseJsonObject(&options, module);
+1 -1
View File
@@ -4,7 +4,7 @@
#include <sys/module.h>
#include <sys/param.h>
typedef struct __attribute__((__packed__)) FFNbsdModList {
typedef struct FF_A_PACKED FFNbsdModList {
int len;
modstat_t mods[];
} FFNbsdModList;
+1 -1
View File
@@ -1,5 +1,5 @@
#include "common/kmod.h"
bool ffKmodLoaded(FF_MAYBE_UNUSED const char* modName) {
bool ffKmodLoaded(FF_A_UNUSED const char* modName) {
return true; // Don't generate kernel module related errors
}
+1 -1
View File
@@ -102,7 +102,7 @@ void* ffLibraryLoad(const char* path, int maxVersion, ...) {
#if _WIN32
void* dlopen(const char* path, FF_MAYBE_UNUSED int mode) {
void* dlopen(const char* path, FF_A_UNUSED int mode) {
wchar_t pathW[MAX_PATH + 1];
ULONG pathWBytes = 0;
+6 -6
View File
@@ -44,7 +44,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
uint32_t pid = ffNetifGetNetlinkPortId(sock_fd);
struct __attribute__((__packed__)) {
struct FF_A_PACKED {
struct nlmsghdr nlh;
struct rtmsg rtm;
struct rtattr rta;
@@ -97,7 +97,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result) {
uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient
uint32_t minMetric = UINT32_MAX;
FF_MAYBE_UNUSED int routeCount = 0;
FF_A_UNUSED int routeCount = 0;
while (true) {
ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, (struct sockaddr*) &src_addr, &src_addr_len);
@@ -254,7 +254,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
uint32_t pid = ffNetifGetNetlinkPortId(sock_fd);
struct __attribute__((__packed__)) {
struct FF_A_PACKED {
struct nlmsghdr nlh;
struct rtmsg rtm;
struct rtattr rta;
@@ -307,7 +307,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
uint8_t buffer[1024 * 16]; // 16 KB buffer should be sufficient
uint32_t minMetric = UINT32_MAX;
FF_MAYBE_UNUSED int routeCount = 0;
FF_A_UNUSED int routeCount = 0;
while (true) {
ssize_t received = recvfrom(sock_fd, buffer, sizeof(buffer), 0, (struct sockaddr*) &src_addr, &src_addr_len);
@@ -382,7 +382,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
switch (rta->rta_type) {
case RTA_DST:
if (RTA_PAYLOAD(rta) >= sizeof(struct in6_addr)) {
FF_MAYBE_UNUSED char str[INET6_ADDRSTRLEN];
FF_A_UNUSED char str[INET6_ADDRSTRLEN];
FF_DEBUG("Unexpected RTA_DST: %s", inet_ntop(AF_INET6, RTA_DATA(rta), str, sizeof(str)));
goto next;
}
@@ -399,7 +399,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result) {
if (IN6_IS_ADDR_UNSPECIFIED(gw)) {
goto next;
}
FF_MAYBE_UNUSED char str[INET6_ADDRSTRLEN];
FF_A_UNUSED char str[INET6_ADDRSTRLEN];
FF_DEBUG("Found gateway: %s", inet_ntop(AF_INET6, gw, str, sizeof(str)));
}
break;
+2 -2
View File
@@ -254,7 +254,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos
if (state->timeout > 0) {
FF_DEBUG("Setting connection timeout: %u ms", state->timeout);
FF_MAYBE_UNUSED uint32_t sec = state->timeout / 1000;
FF_A_UNUSED uint32_t sec = state->timeout / 1000;
if (sec == 0) {
sec = 1;
}
@@ -410,7 +410,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
}
FF_DEBUG("Starting data reception");
FF_MAYBE_UNUSED int recvCount = 0;
FF_A_UNUSED int recvCount = 0;
uint32_t contentLength = 0;
uint32_t headerEnd = 0;
+1 -1
View File
@@ -275,7 +275,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
}
FF_DEBUG("Starting data reception");
FF_MAYBE_UNUSED int recvCount = 0;
FF_A_UNUSED int recvCount = 0;
uint32_t contentLength = 0;
uint32_t headerEnd = 0;
+3 -3
View File
@@ -67,7 +67,7 @@ static bool parseSmbiosTable(const uint8_t* data, uint32_t length) {
const FFSmbiosHeader* endOfTable = NULL;
FF_DEBUG("Parsing SMBIOS table structures with length %u bytes", length);
FF_MAYBE_UNUSED int structureCount = 0, totalCount = 0;
FF_A_UNUSED int structureCount = 0, totalCount = 0;
for (
const FFSmbiosHeader* header = (const FFSmbiosHeader*) data;
(const uint8_t*) header + sizeof(FFSmbiosHeader) < (const uint8_t*) data + length;
@@ -194,7 +194,7 @@ typedef struct FFSmbios20EntryPoint {
uint32_t StructureTableAddress;
uint16_t NumberOfSmbiosStructures;
uint8_t SmbiosBcdRevision;
} __attribute__((__packed__)) FFSmbios20EntryPoint;
} FF_A_PACKED FFSmbios20EntryPoint;
static_assert(offsetof(FFSmbios20EntryPoint, SmbiosBcdRevision) == 0x1E,
"FFSmbios20EntryPoint: Wrong struct alignment");
@@ -209,7 +209,7 @@ typedef struct FFSmbios30EntryPoint {
uint8_t Reversed;
uint32_t StructureTableMaximumSize;
uint64_t StructureTableAddress;
} __attribute__((__packed__)) FFSmbios30EntryPoint;
} FF_A_PACKED FFSmbios30EntryPoint;
static_assert(offsetof(FFSmbios30EntryPoint, StructureTableAddress) == 0x10,
"FFSmbios30EntryPoint: Wrong struct alignment");