History

net, uapi: remove inclusion of arpa/inet.h

In include/uapi/linux/tipc_config.h, there's a comment that it includes arpa/inet.h for ntohs; but ntohs is not defined in any UAPI header. For now, reuse the definitions from include/linux/byteorder/generic.h, since the various conversion functions do exist in UAPI headers: include/uapi/linux/byteorder/big_endian.h include/uapi/linux/byteorder/little_endian.h We would like to get to the point where we can build UAPI header tests with -nostdinc, meaning that kernel UAPI headers should not have a circular dependency on libc headers.

Nick Desaulniers committed 4 years ago

Commit 1ee375d1 parent f4b41f01 file · +12 −16Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/tipc_config.h+12−16
@@ -43,10 +43,6 @@ · 42 unmodified lines
4343 #include <linux/tipc.h>
4444 #include <asm/byteorder.h>
4545
46−#ifndef __KERNEL__
47−#include <arpa/inet.h> /* for ntohs etc. */
48−#endif
49−
5046 /*
5147 * Configuration
5248 *
@@ -269,33 +265,33 @@ static inline int TLV_OK(const void *tlv, __u16 space) · 216 unmodified lines
269265 */
270266
271267 return (space >= TLV_SPACE(0)) &&
272− (ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
268+ (__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_len) <= space);
273269 }
274270
275271 static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)
276272 {
277273 return TLV_OK(tlv, space) &&
278− (ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
274+ (__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
279275 }
280276
281277 static inline int TLV_GET_LEN(struct tlv_desc *tlv)
282278 {
283− return ntohs(tlv->tlv_len);
279+ return __be16_to_cpu(tlv->tlv_len);
284280 }
285281
286282 static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len)
287283 {
288− tlv->tlv_len = htons(len);
284+ tlv->tlv_len = __cpu_to_be16(len);
289285 }
290286
291287 static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv, __u16 type)
292288 {
293− return (ntohs(tlv->tlv_type) == type);
289+ return (__be16_to_cpu(tlv->tlv_type) == type);
294290 }
295291
296292 static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type)
297293 {
298− tlv->tlv_type = htons(type);
294+ tlv->tlv_type = __cpu_to_be16(type);
299295 }
300296
301297 static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
@@ -305,8 +301,8 @@ static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len) · 3 unmodified lines
305301
306302 tlv_len = TLV_LENGTH(len);
307303 tlv_ptr = (struct tlv_desc *)tlv;
308− tlv_ptr->tlv_type = htons(type);
309− tlv_ptr->tlv_len = htons(tlv_len);
304+ tlv_ptr->tlv_type = __cpu_to_be16(type);
305+ tlv_ptr->tlv_len = __cpu_to_be16(tlv_len);
310306 if (len && data) {
311307 memcpy(TLV_DATA(tlv_ptr), data, len);
312308 memset((char *)TLV_DATA(tlv_ptr) + len, 0, TLV_SPACE(len) - tlv_len);
@@ -348,7 +344,7 @@ static inline void *TLV_LIST_DATA(struct tlv_list_desc *list) · 35 unmodified lines
348344
349345 static inline void TLV_LIST_STEP(struct tlv_list_desc *list)
350346 {
351− __u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len));
347+ __u16 tlv_space = TLV_ALIGN(__be16_to_cpu(list->tlv_ptr->tlv_len));
352348
353349 list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);
354350 list->tlv_space -= tlv_space;
@@ -404,9 +400,9 @@ static inline int TCM_SET(void *msg, __u16 cmd, __u16 flags, · 49 unmodified lines
404400
405401 msg_len = TCM_LENGTH(data_len);
406402 tcm_hdr = (struct tipc_cfg_msg_hdr *)msg;
407− tcm_hdr->tcm_len = htonl(msg_len);
408− tcm_hdr->tcm_type = htons(cmd);
409− tcm_hdr->tcm_flags = htons(flags);
403+ tcm_hdr->tcm_len = __cpu_to_be32(msg_len);
404+ tcm_hdr->tcm_type = __cpu_to_be16(cmd);
405+ tcm_hdr->tcm_flags = __cpu_to_be16(flags);
410406 if (data_len && data) {
411407 memcpy(TCM_DATA(msg), data, data_len);
412408 memset((char *)TCM_DATA(msg) + data_len, 0, TCM_SPACE(data_len) - msg_len);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t