Skip to content

Commit f770f44

Browse files
aloisklinkmereacre
andcommitted
refactor: move STRUCT_PACKED into attributes
Move the `#define STRUCT_PACKED __attribute__((packed))` from `src/utils/os.h` into `src/utils/attributes.h`. Co-authored-by: Alexandru Mereacre <[email protected]>
1 parent 0be7a2b commit f770f44

File tree

8 files changed

+12
-9
lines changed

8 files changed

+12
-9
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ set_target_properties(edgesec PROPERTIES
6767

6868
if (USE_CAPTURE_SERVICE)
6969
add_executable(edgesec-recap edgesec-recap.c)
70-
target_link_libraries(edgesec-recap PRIVATE capture_service protobuf_middleware packet_queue packet_decoder sqlite_header os log SQLite::SQLite3 eloop::eloop)
70+
target_link_libraries(edgesec-recap PRIVATE capture_service protobuf_middleware packet_queue packet_decoder sqlite_header attributes os log SQLite::SQLite3 eloop::eloop)
7171
target_include_directories(edgesec-recap PRIVATE ${PROJECT_BINARY_DIR})
7272
endif()

src/capture/middlewares/header_middleware/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ target_link_libraries(dns_decoder PUBLIC PCAP::pcap SQLite::SQLite3 PRIVATE log
1212

1313
# packet_decoder.h has an #include <pcap.h>, so need to make it PUBLIC include
1414
add_library(packet_decoder packet_decoder.c)
15-
target_link_libraries(packet_decoder PUBLIC PCAP::pcap LibUTHash::LibUTHash PRIVATE mdns_decoder dns_decoder hash net log os hashmap)
15+
target_link_libraries(packet_decoder PUBLIC PCAP::pcap LibUTHash::LibUTHash attributes PRIVATE mdns_decoder dns_decoder hash net log os hashmap)
1616

1717
add_library(packet_queue packet_queue.c)
1818
target_link_libraries(packet_queue PUBLIC packet_decoder eloop::list PRIVATE log os)

src/capture/middlewares/header_middleware/packet_decoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <utarray.h>
1818
#include "../../../utils/allocs.h"
19+
#include "../../../utils/attributes.h"
1920
#include "../../../utils/net.h"
2021
#include "../../../utils/os.h"
2122

src/edgesec-recap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "capture/middlewares/header_middleware/packet_queue.h"
3131
#include "capture/middlewares/header_middleware/sqlite_header.h"
3232
#include "capture/middlewares/protobuf_middleware/protobuf_middleware.h"
33+
#include "utils/attributes.h"
3334
#include "utils/os.h"
3435
#include "utils/sqliteu.h"
3536
#include "version.h"

src/radius/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ target_compile_definitions(wpabuf PUBLIC _DEFAULT_SOURCE _BSD_SOURCE)
1919

2020
add_library(radius radius.c)
2121
target_link_libraries(radius
22-
PUBLIC common
22+
PUBLIC common attributes
2323
PRIVATE wpabuf md5 md5_internal log os)
2424

2525
add_library(radius_server radius_server.c)

src/radius/radius.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "common.h"
1818

19+
#include "../utils/attributes.h"
1920
#include "utils/os.h"
2021

2122
/* RFC 2865 - RADIUS */

src/utils/attributes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@
3232
#endif /* defined __has_attribute */
3333
#endif /* __maybe_unused */
3434

35+
#ifdef __GNUC__
36+
#define STRUCT_PACKED __attribute__((packed))
37+
#else
38+
#define STRUCT_PACKED
39+
#endif
40+
3541
#endif /* ATTRIBUTES_H */

src/utils/os.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@
3232

3333
#define OS_HOST_NAME_MAX 64
3434

35-
#ifdef __GNUC__
36-
#define STRUCT_PACKED __attribute__((packed))
37-
#else
38-
#define STRUCT_PACKED
39-
#endif
40-
4135
#ifndef BIT
4236
#define BIT(x) (1U << (x))
4337
#endif

0 commit comments

Comments
 (0)