Add our own <netinet/in.h> and <net/if.h> headers and sort includes tree-wide with clang-format (#37278)

This commit is contained in:
Daan De Meyer
2025-04-30 10:42:57 +02:00
committed by GitHub
455 changed files with 669 additions and 722 deletions
+1 -1
View File
@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include <linux/if_infiniband.h>
#include <netinet/in.h>
#include <string.h>
#include "arphrd-util.h"
+1 -1
View File
@@ -5,8 +5,8 @@
#include "alloc-util.h"
#include "bitfield.h"
#include "capability-util.h"
#include "cap-list.h"
#include "capability-util.h"
#include "extract-word.h"
#include "log.h"
#include "macro.h"
+1 -1
View File
@@ -9,8 +9,8 @@
#include <threads.h>
#include <unistd.h>
#include "confidential-virt-fundamental.h"
#include "confidential-virt.h"
#include "confidential-virt-fundamental.h"
#include "errno-util.h"
#include "fd-util.h"
#include "fileio.h"
+2 -2
View File
@@ -1,11 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <linux/falloc.h>
#include <linux/magic.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/file.h>
#include <linux/falloc.h>
#include <linux/magic.h>
#include <unistd.h>
#include "alloc-util.h"
+1 -1
View File
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "dirent-util.h"
+11 -6
View File
@@ -13,6 +13,7 @@
#include "in-addr-util.h"
#include "logarithm.h"
#include "macro.h"
#include "memory-util.h"
#include "parse-util.h"
#include "random-util.h"
#include "stdio-util.h"
@@ -28,7 +29,7 @@ bool in4_addr_is_null(const struct in_addr *a) {
bool in6_addr_is_null(const struct in6_addr *a) {
assert(a);
return IN6_IS_ADDR_UNSPECIFIED(a);
return eqzero(a->in6_u.u6_addr32);
}
int in_addr_is_null(int family, const union in_addr_union *u) {
@@ -66,7 +67,7 @@ bool in4_addr_is_link_local_dynamic(const struct in_addr *a) {
bool in6_addr_is_link_local(const struct in6_addr *a) {
assert(a);
return IN6_IS_ADDR_LINKLOCAL(a);
return (a->in6_u.u6_addr32[0] & htobe32(0xffc00000)) == htobe32(0xfe800000);
}
int in_addr_is_link_local(int family, const union in_addr_union *u) {
@@ -100,7 +101,7 @@ bool in4_addr_is_multicast(const struct in_addr *a) {
bool in6_addr_is_multicast(const struct in6_addr *a) {
assert(a);
return IN6_IS_ADDR_MULTICAST(a);
return a->in6_u.u6_addr8[0] == 0xff;
}
int in_addr_is_multicast(int family, const union in_addr_union *u) {
@@ -136,6 +137,10 @@ bool in4_addr_is_non_local(const struct in_addr *a) {
!in4_addr_is_localhost(a);
}
static bool in6_addr_is_loopback(const struct in6_addr *a) {
return memcmp(a, &(struct in6_addr) IN6ADDR_LOOPBACK_INIT, sizeof(struct in6_addr)) == 0;
}
int in_addr_is_localhost(int family, const union in_addr_union *u) {
assert(u);
@@ -143,7 +148,7 @@ int in_addr_is_localhost(int family, const union in_addr_union *u) {
return in4_addr_is_localhost(&u->in);
if (family == AF_INET6)
return IN6_IS_ADDR_LOOPBACK(&u->in6);
return in6_addr_is_loopback(&u->in6);
return -EAFNOSUPPORT;
}
@@ -156,7 +161,7 @@ int in_addr_is_localhost_one(int family, const union in_addr_union *u) {
return be32toh(u->in.s_addr) == UINT32_C(0x7F000001);
if (family == AF_INET6)
return IN6_IS_ADDR_LOOPBACK(&u->in6);
return in6_addr_is_loopback(&u->in6);
return -EAFNOSUPPORT;
}
@@ -178,7 +183,7 @@ bool in6_addr_equal(const struct in6_addr *a, const struct in6_addr *b) {
assert(a);
assert(b);
return IN6_ARE_ADDR_EQUAL(a, b);
return memcmp(a, b, sizeof(struct in6_addr)) == 0;
}
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b) {
+2
View File
@@ -0,0 +1,2 @@
---
DisableFormat: true
+9
View File
@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/if.h>
#define IF_NAMESIZE 16
extern unsigned int if_nametoindex(const char *__ifname) __THROW;
extern char *if_indextoname(unsigned int __ifindex, char __ifname[IF_NAMESIZE]) __THROW;
+19
View File
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/in.h>
#include <linux/in6.h>
#include <linux/ipv6.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/socket.h>
#define INET_ADDRSTRLEN 16
#define INET6_ADDRSTRLEN 46
extern const struct in6_addr in6addr_any; /* :: */
extern const struct in6_addr in6addr_loopback; /* ::1 */
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
typedef uint32_t in_addr_t;
+1 -1
View File
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "alloc-util.h"
#include "keyring-util.h"
#include "log.h"
#include "alloc-util.h"
#include "memory-util.h"
#include "missing_syscall.h"
-42
View File
@@ -1,50 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* temporary undef definitions in bits/uio-ext.h, which is included by sys/uio.h */
#include <sys/uio.h>
#define __RWF_HIPRI_SAVED__ RWF_HIPRI
#undef RWF_HIPRI
#define __RWF_DSYNC_SAVED__ RWF_DSYNC
#undef RWF_DSYNC
#define __RWF_SYNC_SAVED__ RWF_SYNC
#undef RWF_SYNC
#define __RWF_NOWAIT_SAVED__ RWF_NOWAIT
#undef RWF_NOWAIT
#define __RWF_APPEND_SAVED__ RWF_APPEND
#undef RWF_APPEND
#define __RWF_NOAPPEND_SAVED__ RWF_NOAPPEND
#undef RWF_NOAPPEND
#if defined(RWF_ATOMIC)
#define __RWF_ATOMIC_SAVED__ RWF_ATOMIC
#undef RWF_ATOMIC
#else
#define __RWF_ATOMIC_SAVED__ 0x00000040
#endif
#if defined(RWF_DONTCACHE)
#define __RWF_DONTCACHE_SAVED__ RWF_DONTCACHE
#undef RWF_DONTCACHE
#else
#define __RWF_DONTCACHE_SAVED__ 0x00000080
#endif
#include <linux/btrfs.h>
#include <linux/btrfs_tree.h>
#include <linux/fs.h>
#include "macro.h"
/* check RWF_xyz are redefined by linux/fs.h */
assert_cc(RWF_HIPRI == __RWF_HIPRI_SAVED__);
assert_cc(RWF_DSYNC == __RWF_DSYNC_SAVED__);
assert_cc(RWF_SYNC == __RWF_SYNC_SAVED__);
assert_cc(RWF_NOWAIT == __RWF_NOWAIT_SAVED__);
assert_cc(RWF_APPEND == __RWF_APPEND_SAVED__);
assert_cc(RWF_NOAPPEND == __RWF_NOAPPEND_SAVED__);
assert_cc(RWF_ATOMIC == __RWF_ATOMIC_SAVED__);
assert_cc(RWF_DONTCACHE == __RWF_DONTCACHE_SAVED__);
/* Not exposed yet. Defined at fs/ext4/ext4.h */
#ifndef EXT4_IOC_RESIZE_FS
#define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64)
+2
View File
@@ -6,6 +6,8 @@
*/
#pragma once
#include "macro.h"
/* Note: if this code looks strange, this is because it is derived from the same
* template as the per-syscall blocks below. */
# if defined(__aarch64__)
+1 -1
View File
@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "parse-util.h"
#include "percent-util.h"
#include "string-util.h"
#include "parse-util.h"
static int parse_parts_value_whole(const char *p, const char *symbol) {
const char *pc, *n;
+1 -1
View File
@@ -11,8 +11,8 @@
#include "fileio.h"
#include "parse-util.h"
#include "psi-util.h"
#include "string-util.h"
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
int read_resource_pressure(const char *path, PressureType type, ResourcePressure *ret) {
+1 -1
View File
@@ -5,8 +5,8 @@
#include <limits.h>
#include "errno-list.h"
#include "stat-util.h"
#include "macro.h"
#include "stat-util.h"
typedef enum RecurseDirFlags {
/* Interpreted by readdir_all() */
+2 -3
View File
@@ -1,10 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/* Make sure the net/if.h header is included before any linux/ one */
#include <net/if.h>
#include <arpa/inet.h>
#include <errno.h>
#include <limits.h>
#include <linux/if.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/ip.h>
#include <poll.h>
@@ -14,7 +14,6 @@
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/if.h>
#include "alloc-util.h"
#include "errno-util.h"
+1 -1
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "sort-util.h"
#include "alloc-util.h"
#include "sort-util.h"
/* hey glibc, APIs with callbacks without a user pointer are so useless */
void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
+1 -1
View File
@@ -4,8 +4,8 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <syslog.h>
#include <sys/types.h>
#include <syslog.h>
#include <termios.h>
#include <unistd.h>