Skip to content

Commit 7e3eaaa

Browse files
jukkarnashif
authored andcommitted
net: Use packed enums when applicable
Make several enums, that are used inside structs, to be packed so that they use only needed amount of memory. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 3c63d05 commit 7e3eaaa

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

include/net/dhcpv4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ enum net_dhcpv4_state {
3838
NET_DHCPV4_RENEWING,
3939
NET_DHCPV4_REBINDING,
4040
NET_DHCPV4_BOUND,
41-
};
41+
} __packed;
4242

4343
/**
4444
* @brief Start DHCPv4 client on an iface

include/net/http.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ enum http_state {
5353
HTTP_STATE_RECEIVING_HEADER,
5454
HTTP_STATE_HEADER_RECEIVED,
5555
HTTP_STATE_OPEN,
56-
};
56+
} __packed;
5757

5858
enum http_url_flags {
5959
HTTP_URL_STANDARD = 0,
6060
HTTP_URL_WEBSOCKET,
61-
};
61+
} __packed;
6262

6363
enum http_connection_type {
6464
HTTP_CONNECTION = 1,

include/net/net_app.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ enum net_app_type {
5959
NET_APP_UNSPEC = 0,
6060
NET_APP_SERVER,
6161
NET_APP_CLIENT,
62-
};
62+
} __packed;
6363

6464
struct net_app_ctx;
6565

include/net/net_ip.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ enum net_priority {
206206
NET_PRIORITY_VO = 5, /* Voice, < 10 ms latency and jitter */
207207
NET_PRIORITY_IC = 6, /* Internetwork control */
208208
NET_PRIORITY_NC = 7 /* Network control */
209-
};
209+
} __packed;
210210

211211
/** IPv6/IPv4 network connection tuple */
212212
struct net_tuple {
@@ -229,7 +229,7 @@ enum net_addr_type {
229229
NET_ADDR_DHCP,
230230
NET_ADDR_MANUAL,
231231
NET_ADDR_OVERRIDABLE,
232-
};
232+
} __packed;
233233

234234
#if NET_LOG_ENABLED > 0
235235
static inline char *net_addr_type2str(enum net_addr_type type)
@@ -265,7 +265,7 @@ enum net_addr_state {
265265
NET_ADDR_TENTATIVE = 0,
266266
NET_ADDR_PREFERRED,
267267
NET_ADDR_DEPRECATED,
268-
};
268+
} __packed;
269269

270270
struct net_ipv6_hdr {
271271
u8_t vtc;

include/net/net_l2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ enum net_l2_flags {
3636

3737
/** Is promiscuous mode supported */
3838
NET_L2_PROMISC_MODE = BIT(2),
39-
};
39+
} __packed;
4040

4141
struct net_l2 {
4242
/**

include/net/net_linkaddr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ enum net_link_type {
4545
NET_LINK_BLUETOOTH,
4646
NET_LINK_ETHERNET,
4747
NET_LINK_DUMMY,
48-
};
48+
} __packed;
4949

5050
/**
5151
* @brief Hardware link address structure

0 commit comments

Comments
 (0)