Skip to content

Commit 664f683

Browse files
committed
Prefer #pragma once
1 parent 8a2e4d1 commit 664f683

18 files changed

+18
-73
lines changed

config.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
* @{
44
*/
55

6-
#ifndef CONFIG_H
7-
#define CONFIG_H
6+
#pragma once
87

98
#define NSTACK_DATAGRAM_SIZE_MAX 4096
109

@@ -74,8 +73,6 @@
7473
* @}
7574
*/
7675

77-
#endif /* CONFIG_H */
78-
7976
/**
8077
* @}
8178
*/

include/linker_set.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
* SUCH DAMAGE.
2626
*/
2727

28-
#ifndef _SYS_LINKER_SET_H_
29-
#define _SYS_LINKER_SET_H_
28+
#pragma once
3029

3130
#include "nstack_util.h"
3231

@@ -80,5 +79,3 @@
8079
* Provide a count of the items in a set.
8180
*/
8281
#define SET_COUNT(set) (SET_LIMIT(set) - SET_BEGIN(set))
83-
84-
#endif /* _SYS_LINKER_SET_H_ */

include/nstack_in.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef NSTACK_IN_H
2-
#define NSTACK_IN_H
1+
#pragma once
32

43
#include <arpa/inet.h> /* TODO Maybe we want to define our own version */
54
#include <stdint.h>
@@ -23,5 +22,3 @@ static inline void ip2str(in_addr_t ip, char *buf)
2322
bytes[3] = (ip >> 24) & 0xFF;
2423
sprintf(buf, "%d.%d.%d.%d", bytes[3], bytes[2], bytes[1], bytes[0]);
2524
}
26-
27-
#endif /* NSTACK_IN_H */

include/nstack_link.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
#ifndef NSTACK_LINK_H
2-
#define NSTACK_LINK_H
1+
#pragma once
32

43
#include <stdint.h>
54

65
#define LINK_MAC_ALEN 6
76

87
typedef uint8_t mac_addr_t[LINK_MAC_ALEN];
9-
10-
#endif /* NSTACK_LINK_H */

include/nstack_socket.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
#pragma once
2+
13
/**
24
* nstack sockets.
35
* @addtogroup Socket
46
* @{
57
*/
68

7-
#ifndef NSTACK_SOCKET_H
8-
#define NSTACK_SOCKET_H
9-
109
#include <stdint.h>
1110
#include <sys/types.h>
1211

@@ -111,8 +110,6 @@ ssize_t nstack_sendto(void *socket,
111110
int flags,
112111
const struct nstack_sockaddr *dest_addr);
113112

114-
#endif /* NSTACK_SOCKET_H */
115-
116113
/**
117114
* @}
118115
*/

include/nstack_util.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef NSTACK_UTIL_H
2-
#define NSTACK_UTIL_H
1+
#pragma once
32

43
#ifndef __GLOBL1
54
#define __GLOBL1(sym) __asm__(".globl " #sym)
@@ -82,5 +81,3 @@ static inline unsigned int uround_up(unsigned n, unsigned s)
8281
{
8382
return ((n + s - 1) / s) * s;
8483
}
85-
86-
#endif /* NSTACK_UTIL */

include/queue_r.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
*/
99

1010
#pragma once
11-
#ifndef QUEUE_R_H
12-
#define QUEUE_R_H
1311

1412
#include <stdbool.h>
1513
#include <stddef.h>
@@ -155,8 +153,6 @@ static inline bool queue_isfull(queue_cb_t *cb)
155153
return ((cb->m_write + 1) % cb->a_len) == cb->m_read;
156154
}
157155

158-
#endif /* QUEUE_R_H */
159-
160156
/**
161157
* @}
162158
*/

src/collection.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
* SUCH DAMAGE.
2525
*/
2626

27-
#ifndef _SYS_QUEUE_H_
28-
#define _SYS_QUEUE_H_
27+
#pragma once
2928

3029
#include <err.h>
3130

@@ -694,5 +693,3 @@ struct qm_trace {
694693
else \
695694
(head2)->tqh_last = &(head2)->tqh_first; \
696695
} while (0)
697-
698-
#endif /* !_SYS_QUEUE_H_ */

src/ip_defer.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* @{
66
*/
77

8-
#ifndef IP_DEFER_H
9-
#define IP_DEFER_H
8+
#pragma once
109

1110
#include "nstack_in.h"
1211

@@ -17,8 +16,6 @@ int ip_defer_push(in_addr_t dst,
1716

1817
void ip_defer_handler(int delta_time);
1918

20-
#endif /* IP_DEFER_H */
21-
2219
/**
2320
* @}
2421
*/

src/logger.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef LOGGER_H
2-
#define LOGGER_H
1+
#pragma once
32

43
#include <stdio.h>
54

@@ -17,5 +16,3 @@ enum log_level {
1716
"\n", \
1817
_level_, __func__, ##__VA_ARGS__); \
1918
} while (0)
20-
21-
#endif /* LOGGER_H */

src/nstack_arp.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
* @{
44
*/
55

6-
#ifndef NSTACK_ARP_H
7-
#define NSTACK_ARP_H
6+
#pragma once
87

98
#include "nstack_in.h"
109
#include "nstack_link.h"
@@ -71,8 +70,6 @@ int arp_cache_get_haddr(in_addr_t iface, in_addr_t ip_addr, mac_addr_t haddr);
7170
*/
7271
int arp_gratuitous(int ether_handle, in_addr_t spa);
7372

74-
#endif /* NSTACK_ARP_H */
75-
7673
/**
7774
* @}
7875
*/

src/nstack_ether.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
* @{
44
*/
55

6-
#ifndef NSTACK_ETHER_H
7-
#define NSTACK_ETHER_H
6+
#pragma once
87

98
#include <stddef.h>
109
#include <stdint.h>
@@ -147,8 +146,6 @@ int ether_output_reply(int ether_handle,
147146
* @}
148147
*/
149148

150-
#endif /* NSTACK_ETHER_H */
151-
152149
/**
153150
* @}
154151
*/

src/nstack_icmp.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
* @{
44
*/
55

6-
#ifndef NSTACK_ICMP_H
7-
#define NSTACK_ICMP_H
6+
#pragma once
87

98
#include <stdint.h>
109

@@ -71,8 +70,6 @@ int icmp_generate_dest_unreachable(struct ip_hdr *hdr,
7170
uint8_t *buf,
7271
size_t bsize);
7372

74-
#endif /* NSTACK_ICMP_H */
75-
7673
/**
7774
* @}
7875
*/

src/nstack_internal.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef NSTACK_INTERNAL_H
2-
#define NSTACK_INTERNAL_H
1+
#pragma once
32

43
#include <stdatomic.h>
54
#include <sys/time.h>
@@ -62,5 +61,3 @@ typedef int nstack_send_fn(struct nstack_sock *sock,
6261
/**
6362
* @}
6463
*/
65-
66-
#endif /* NSTACK_INTERNAL_H */

src/nstack_ip.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* @{
55
*/
66

7-
#ifndef NSTACK_IP_H
8-
#define NSTACK_IP_H
7+
#pragma once
98

109
#include "linker_set.h"
1110
#include "nstack_ether.h"
@@ -215,8 +214,6 @@ int ip_fragment_input(struct ip_hdr *ip_hdr, uint8_t *rx_packet);
215214
* @}
216215
*/
217216

218-
#endif /* NSTACK_IP_H */
219-
220217
/**
221218
* @}
222219
*/

src/tcp.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* @{
55
*/
66

7-
#ifndef NSTACK_TCP_H
8-
#define NSTACK_TCP_H
7+
#pragma once
98

109
#include <stdint.h>
1110

@@ -86,8 +85,6 @@ struct nstack_sock *nstack_udp_alloc_sock(void);
8685
int nstack_tcp_bind(struct nstack_sock *sock);
8786
int nstack_tcp_send(struct nstack_sock *sock, const struct nstack_dgram *dgram);
8887

89-
#endif /* NSTACK_UDP_H */
90-
9188
/**
9289
* @}
9390
*/

src/tree.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525

26-
#ifndef _SYS_TREE_H_
27-
#define _SYS_TREE_H_
26+
#pragma once
2827

2928
#include "nstack_util.h"
3029

@@ -753,5 +752,3 @@
753752
#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \
754753
for ((x) = RB_MAX(name, head); \
755754
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); (x) = (y))
756-
757-
#endif /* _SYS_TREE_H_ */

src/udp.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* @{
55
*/
66

7-
#ifndef NSTACK_UDP_H
8-
#define NSTACK_UDP_H
7+
#pragma once
98

109
#include <stdint.h>
1110

@@ -36,8 +35,6 @@ struct nstack_dgram;
3635
int nstack_udp_bind(struct nstack_sock *sock);
3736
int nstack_udp_send(struct nstack_sock *sock, const struct nstack_dgram *dgram);
3837

39-
#endif /* NSTACK_UDP_H */
40-
4138
/**
4239
* @}
4340
*/

0 commit comments

Comments
 (0)