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
43#include <linux/tipc.h>43#include <linux/tipc.h>
44#include <asm/byteorder.h>44#include <asm/byteorder.h>
45 45
46#ifndef __KERNEL__
47#include <arpa/inet.h> /* for ntohs etc. */
48#endif
49
50/*46/*
51 * Configuration47 * Configuration
52 *48 *
@@ -269,33 +265,33 @@ static inline int TLV_OK(const void *tlv, __u16 space) · 216 unmodified lines
269 */265 */
270 266
271 return (space >= TLV_SPACE(0)) &&267 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);
273}269}
274 270
275static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)271static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)
276{272{
277 return TLV_OK(tlv, space) &&273 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);
279}275}
280 276
281static inline int TLV_GET_LEN(struct tlv_desc *tlv)277static inline int TLV_GET_LEN(struct tlv_desc *tlv)
282{278{
283 return ntohs(tlv->tlv_len);279 return __be16_to_cpu(tlv->tlv_len);
284}280}
285 281
286static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len)282static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len)
287{283{
288 tlv->tlv_len = htons(len);284 tlv->tlv_len = __cpu_to_be16(len);
289}285}
290 286
291static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv, __u16 type)287static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv, __u16 type)
292{288{
293 return (ntohs(tlv->tlv_type) == type);289 return (__be16_to_cpu(tlv->tlv_type) == type);
294}290}
295 291
296static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type)292static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type)
297{293{
298 tlv->tlv_type = htons(type);294 tlv->tlv_type = __cpu_to_be16(type);
299}295}
300 296
301static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)297static 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
305 301
306 tlv_len = TLV_LENGTH(len);302 tlv_len = TLV_LENGTH(len);
307 tlv_ptr = (struct tlv_desc *)tlv;303 tlv_ptr = (struct tlv_desc *)tlv;
308 tlv_ptr->tlv_type = htons(type);304 tlv_ptr->tlv_type = __cpu_to_be16(type);
309 tlv_ptr->tlv_len = htons(tlv_len);305 tlv_ptr->tlv_len = __cpu_to_be16(tlv_len);
310 if (len && data) {306 if (len && data) {
311 memcpy(TLV_DATA(tlv_ptr), data, len);307 memcpy(TLV_DATA(tlv_ptr), data, len);
312 memset((char *)TLV_DATA(tlv_ptr) + len, 0, TLV_SPACE(len) - tlv_len);308 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
348 344
349static inline void TLV_LIST_STEP(struct tlv_list_desc *list)345static inline void TLV_LIST_STEP(struct tlv_list_desc *list)
350{346{
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));
352 348
353 list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);349 list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);
354 list->tlv_space -= tlv_space;350 list->tlv_space -= tlv_space;
@@ -404,9 +400,9 @@ static inline int TCM_SET(void *msg, __u16 cmd, __u16 flags, · 49 unmodified lines
404 400
405 msg_len = TCM_LENGTH(data_len);401 msg_len = TCM_LENGTH(data_len);
406 tcm_hdr = (struct tipc_cfg_msg_hdr *)msg;402 tcm_hdr = (struct tipc_cfg_msg_hdr *)msg;
407 tcm_hdr->tcm_len = htonl(msg_len);403 tcm_hdr->tcm_len = __cpu_to_be32(msg_len);
408 tcm_hdr->tcm_type = htons(cmd);404 tcm_hdr->tcm_type = __cpu_to_be16(cmd);
409 tcm_hdr->tcm_flags = htons(flags);405 tcm_hdr->tcm_flags = __cpu_to_be16(flags);
410 if (data_len && data) {406 if (data_len && data) {
411 memcpy(TCM_DATA(msg), data, data_len);407 memcpy(TCM_DATA(msg), data, data_len);
412 memset((char *)TCM_DATA(msg) + data_len, 0, TCM_SPACE(data_len) - msg_len);408 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