Skip to content

Commit f6a363f

Browse files
committed
Global: unifies GCC attributes usage
1 parent 3e69361 commit f6a363f

233 files changed

Lines changed: 516 additions & 545 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/common/FFcheckmacros.h

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/common/FFlist.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "FFcheckmacros.h"
3+
#include "common/attributes.h"
44

55
#include <stdbool.h>
66
#include <stdint.h>
@@ -48,7 +48,7 @@ static inline void* ffListGet(const FFlist* list, uint32_t index) {
4848
return list->data + (index * list->elementSize);
4949
}
5050

51-
FF_C_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) {
51+
FF_A_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) {
5252
for (uint32_t i = 0; i < list->length; i++) {
5353
if (compFunc(ffListGet(list, i), compElement)) {
5454
return i;
@@ -109,7 +109,7 @@ static inline void ffListReserve(FFlist* list, uint32_t newCapacity) {
109109
itemVarName - (itemType*) (listVar).data < (intptr_t) (listVar).length; \
110110
++itemVarName)
111111

112-
#define FF_LIST_AUTO_DESTROY FFlist __attribute__((__cleanup__(ffListDestroy)))
112+
#define FF_LIST_AUTO_DESTROY FFlist FF_A_CLEANUP(ffListDestroy)
113113

114114
#define FF_LIST_GET(itemType, listVar, index) \
115115
({ \

src/common/FFstrbuf.h

Lines changed: 55 additions & 55 deletions
Large diffs are not rendered by default.

src/common/apple/cf_helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ static inline void cfReleaseWrapper(void* type) {
2828
}
2929
}
3030

31-
#define FF_CFTYPE_AUTO_RELEASE __attribute__((__cleanup__(cfReleaseWrapper)))
31+
#define FF_CFTYPE_AUTO_RELEASE FF_A_CLEANUP(cfReleaseWrapper)
3232

3333
static inline void wrapIoObjectRelease(io_object_t* service) {
3434
assert(service);
3535
if (*service) {
3636
IOObjectRelease(*service);
3737
}
3838
}
39-
#define FF_IOOBJECT_AUTO_RELEASE __attribute__((__cleanup__(wrapIoObjectRelease)))
39+
#define FF_IOOBJECT_AUTO_RELEASE FF_A_CLEANUP(wrapIoObjectRelease)

src/common/argType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ typedef struct FFArgBuffer {
1010
uint32_t length;
1111
} FFArgBuffer;
1212

13-
typedef enum __attribute__((__packed__)) FFArgType {
13+
typedef enum FF_A_PACKED FFArgType {
1414
FF_ARG_TYPE_NULL = 0,
1515
FF_ARG_TYPE_UINT,
1616
FF_ARG_TYPE_UINT64,

src/common/attributes.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#ifdef _MSC_VER
4+
# define __attribute__(x)
5+
#endif
6+
7+
#define FF_A_FALLTHROUGH __attribute__((__fallthrough__))
8+
#define FF_A_DEPRECATED __attribute__((__deprecated__))
9+
#define FF_A_CLEANUP(func) __attribute__((__cleanup__(func)))
10+
#define FF_A_NODISCARD __attribute__((__warn_unused_result__))
11+
#define FF_A_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__(printf, formatStrIndex, argsStartIndex)))
12+
#define FF_A_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__(scanf, formatStrIndex, argsStartIndex)))
13+
#define FF_A_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__)))
14+
#define FF_A_RETURNS_NONNULL __attribute__((__returns_nonnull__))
15+
#define FF_A_UNUSED __attribute__((__unused__))
16+
#define FF_A_PACKED __attribute__((__packed__))
17+
#define FF_A_WEAK_IMPORT __attribute__((__weak_import__))

src/common/dbus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ static inline DBusMessage* ffDBusGetAllProperties(FFDBusData* dbus, const char*
4141
return ffDBusGetMethodReply(dbus, busName, objectPath, "org.freedesktop.DBus.Properties", "GetAll", interface, NULL);
4242
}
4343

44-
# define FF_DBUS_AUTO_DESTROY_DATA __attribute__((__cleanup__(ffDBusDestroyData)))
44+
# define FF_DBUS_AUTO_DESTROY_DATA FF_A_CLEANUP(ffDBusDestroyData)
4545

4646
#endif // FF_HAVE_DBUS

src/common/ffdata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "common/FFstrbuf.h"
44

5-
typedef enum __attribute__((__packed__)) FFDataResultDocType {
5+
typedef enum FF_A_PACKED FFDataResultDocType {
66
FF_RESULT_DOC_TYPE_DEFAULT = 0,
77
FF_RESULT_DOC_TYPE_JSON,
88
FF_RESULT_DOC_TYPE_CONFIG,

src/common/impl/commandoption.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void ffPrepareCommandOption(FFdata* data) {
7979
case 'D':
8080
case 'd':
8181
FF_IF_MODULE_MATCH(FF_DISKIO_MODULE_NAME) {
82-
__attribute__((__cleanup__(ffDestroyDiskIOOptions))) FFDiskIOOptions options;
82+
FF_A_CLEANUP(ffDestroyDiskIOOptions) FFDiskIOOptions options;
8383
ffInitDiskIOOptions(&options);
8484
ffPrepareDiskIO(&options);
8585
}
@@ -88,7 +88,7 @@ void ffPrepareCommandOption(FFdata* data) {
8888
case 'N':
8989
case 'n':
9090
FF_IF_MODULE_MATCH(FF_NETIO_MODULE_NAME) {
91-
__attribute__((__cleanup__(ffDestroyNetIOOptions))) FFNetIOOptions options;
91+
FF_A_CLEANUP(ffDestroyNetIOOptions) FFNetIOOptions options;
9292
ffInitNetIOOptions(&options);
9393
ffPrepareNetIO(&options);
9494
}
@@ -97,7 +97,7 @@ void ffPrepareCommandOption(FFdata* data) {
9797
case 'P':
9898
case 'p':
9999
FF_IF_MODULE_MATCH(FF_PUBLICIP_MODULE_NAME) {
100-
__attribute__((__cleanup__(ffDestroyPublicIpOptions))) FFPublicIPOptions options;
100+
FF_A_CLEANUP(ffDestroyPublicIpOptions) FFPublicIPOptions options;
101101
ffInitPublicIpOptions(&options);
102102
ffPreparePublicIp(&options);
103103
}
@@ -106,7 +106,7 @@ void ffPrepareCommandOption(FFdata* data) {
106106
case 'W':
107107
case 'w':
108108
FF_IF_MODULE_MATCH(FF_WEATHER_MODULE_NAME) {
109-
__attribute__((__cleanup__(ffDestroyWeatherOptions))) FFWeatherOptions options;
109+
FF_A_CLEANUP(ffDestroyWeatherOptions) FFWeatherOptions options;
110110
ffInitWeatherOptions(&options);
111111
ffPrepareWeather(&options);
112112
}

src/common/impl/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ static void resetConsole(void) {
8686
}
8787

8888
#ifdef _WIN32
89-
BOOL WINAPI consoleHandler(FF_MAYBE_UNUSED DWORD signal) {
89+
BOOL WINAPI consoleHandler(FF_A_UNUSED DWORD signal) {
9090
resetConsole();
9191
exit(0);
9292
}
9393
#else
94-
static void exitSignalHandler(FF_MAYBE_UNUSED int signal) {
94+
static void exitSignalHandler(FF_A_UNUSED int signal) {
9595
resetConsole();
9696
exit(0);
9797
}

0 commit comments

Comments
 (0)