odhcp6c: properly guard attributes
authorÁlvaro Fernández Rojas <[email protected]>
Thu, 13 Nov 2025 10:46:51 +0000 (11:46 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 17 Nov 2025 07:28:40 +0000 (08:28 +0100)
Properly guard odhcp6c.h attributes with `#ifndef` to avoid redefining them
when including external headers.
Also convert the remaining __attribute__ usages to the custom declarations.

Signed-off-by: Álvaro Fernández Rojas <[email protected]>
Link: https://github.com/openwrt/odhcp6c/pull/120
src/odhcp6c.h
src/ra.c

index 6c669c0e5cf9b947313796a475abbf802129d0f9..02578ccb0b95bb036c39d4a93728d4dc2fa59352 100644 (file)
 #include <stdbool.h>
 #include <stdint.h>
 
-#define _o_unused __attribute__((unused))
-#define _o_packed __attribute__((packed))
+#ifndef _o_aligned
 #define _o_aligned(n) __attribute__((aligned(n)))
+#endif /* _o_aligned */
+
+#ifndef _o_packed
+#define _o_packed __attribute__((packed))
+#endif /* _o_packed */
+
+#ifndef _o_unused
+#define _o_unused __attribute__((unused))
+#endif /* _o_unused */
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
@@ -278,7 +286,7 @@ struct dhcpv6_retx {
 struct dhcpv6_header {
        uint8_t msg_type;
        uint8_t tr_id[3];
-} __attribute__((packed));
+} _o_packed;
 
 struct dhcpv6_ia_hdr {
        uint16_t type;
index ffff0aa8bb572823bac59ae76ccc97e8431c8d06..dcc5fd6c470cd4fb0ad3c9982a26a9b94833aeae 100644 (file)
--- a/src/ra.c
+++ b/src/ra.c
@@ -71,7 +71,7 @@ struct {
        .lladdr = {ND_OPT_SOURCE_LINKADDR, 1, {0}},
 };
 
-static void ra_send_rs(int signal __attribute__((unused)));
+static void ra_send_rs(_o_unused int signal);
 
 int ra_init(const char *ifname, const struct in6_addr *ifid,
                unsigned int options, unsigned int holdoff_interval)
@@ -189,7 +189,7 @@ failure:
        return -1;
 }
 
-static void ra_send_rs(int signal __attribute__((unused)))
+static void ra_send_rs(_o_unused int signal)
 {
        const struct sockaddr_in6 dest = {AF_INET6, 0, 0, ALL_IPV6_ROUTERS, if_index};
        const struct icmpv6_opt llnull = {ND_OPT_SOURCE_LINKADDR, 1, {0}};