From 9634c932f5d6a1649218f52cc1a9530d81d0d98e Mon Sep 17 00:00:00 2001 From: Iurii Egorov Date: Mon, 20 Nov 2023 22:53:21 +0300 Subject: [PATCH] Fix indents --- contrib/embeddable-wg-library/wireguard.c | 64 +++++++++++------------ src/ipc-linux.h | 54 +++++++++---------- src/uapi/linux/linux/wireguard.h | 2 +- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/contrib/embeddable-wg-library/wireguard.c b/contrib/embeddable-wg-library/wireguard.c index 196fa32..7e20af6 100644 --- a/contrib/embeddable-wg-library/wireguard.c +++ b/contrib/embeddable-wg-library/wireguard.c @@ -48,15 +48,15 @@ enum wgdevice_attribute { WGDEVICE_A_LISTEN_PORT, WGDEVICE_A_FWMARK, WGDEVICE_A_PEERS, - WGDEVICE_A_JC, - WGDEVICE_A_JMIN, - WGDEVICE_A_JMAX, - WGDEVICE_A_S1, - WGDEVICE_A_S2, - WGDEVICE_A_H1, - WGDEVICE_A_H2, - WGDEVICE_A_H3, - WGDEVICE_A_H4, + WGDEVICE_A_JC, + WGDEVICE_A_JMIN, + WGDEVICE_A_JMAX, + WGDEVICE_A_S1, + WGDEVICE_A_S2, + WGDEVICE_A_H1, + WGDEVICE_A_H2, + WGDEVICE_A_H3, + WGDEVICE_A_H4, __WGDEVICE_A_LAST }; @@ -113,18 +113,18 @@ enum mnl_attr_data_type { #define mnl_attr_for_each(attr, nlh, offset) \ for ((attr) = mnl_nlmsg_get_payload_offset((nlh), (offset)); \ - mnl_attr_ok((attr), (char *)mnl_nlmsg_get_payload_tail(nlh) - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) + mnl_attr_ok((attr), (char *)mnl_nlmsg_get_payload_tail(nlh) - (char *)(attr)); \ + (attr) = mnl_attr_next(attr)) #define mnl_attr_for_each_nested(attr, nest) \ for ((attr) = mnl_attr_get_payload(nest); \ - mnl_attr_ok((attr), (char *)mnl_attr_get_payload(nest) + mnl_attr_get_payload_len(nest) - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) + mnl_attr_ok((attr), (char *)mnl_attr_get_payload(nest) + mnl_attr_get_payload_len(nest) - (char *)(attr)); \ + (attr) = mnl_attr_next(attr)) #define mnl_attr_for_each_payload(payload, payload_size) \ for ((attr) = (payload); \ - mnl_attr_ok((attr), (char *)(payload) + payload_size - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) + mnl_attr_ok((attr), (char *)(payload) + payload_size - (char *)(attr)); \ + (attr) = mnl_attr_next(attr)) #define MNL_CB_ERROR -1 #define MNL_CB_STOP 0 @@ -186,8 +186,8 @@ static void *mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, size_t off static bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len) { return len >= (int)sizeof(struct nlmsghdr) && - nlh->nlmsg_len >= sizeof(struct nlmsghdr) && - (int)nlh->nlmsg_len <= len; + nlh->nlmsg_len >= sizeof(struct nlmsghdr) && + (int)nlh->nlmsg_len <= len; } static struct nlmsghdr *mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len) @@ -229,8 +229,8 @@ static void *mnl_attr_get_payload(const struct nlattr *attr) static bool mnl_attr_ok(const struct nlattr *attr, int len) { return len >= (int)sizeof(struct nlattr) && - attr->nla_len >= sizeof(struct nlattr) && - (int)attr->nla_len <= len; + attr->nla_len >= sizeof(struct nlattr) && + (int)attr->nla_len <= len; } static struct nlattr *mnl_attr_next(const struct nlattr *attr) @@ -248,7 +248,7 @@ static int mnl_attr_type_valid(const struct nlattr *attr, uint16_t max) } static int __mnl_attr_validate(const struct nlattr *attr, - enum mnl_attr_data_type type, size_t exp_len) + enum mnl_attr_data_type type, size_t exp_len) { uint16_t attr_len = mnl_attr_get_payload_len(attr); const char *attr_data = mnl_attr_get_payload(attr); @@ -413,7 +413,7 @@ static struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type) } static bool mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen, - uint16_t type, size_t len, const void *data) + uint16_t type, size_t len, const void *data) { if (nlh->nlmsg_len + MNL_ATTR_HDRLEN + MNL_ALIGN(len) > buflen) return false; @@ -541,15 +541,15 @@ static int __mnl_cb_run(const void *buf, size_t numbytes, } static int mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq, - unsigned int portid, mnl_cb_t cb_data, void *data, - const mnl_cb_t *cb_ctl_array, unsigned int cb_ctl_array_len) + unsigned int portid, mnl_cb_t cb_data, void *data, + const mnl_cb_t *cb_ctl_array, unsigned int cb_ctl_array_len) { return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data, - cb_ctl_array, cb_ctl_array_len); + cb_ctl_array, cb_ctl_array_len); } static int mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq, - unsigned int portid, mnl_cb_t cb_data, void *data) + unsigned int portid, mnl_cb_t cb_data, void *data) { return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data, NULL, 0); } @@ -622,7 +622,7 @@ static ssize_t mnl_socket_sendto(const struct mnl_socket *nl, const void *buf, .nl_family = AF_NETLINK }; return sendto(nl->fd, buf, len, 0, - (struct sockaddr *) &snl, sizeof(snl)); + (struct sockaddr *) &snl, sizeof(snl)); } static ssize_t mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, @@ -780,7 +780,7 @@ static int get_family_id_attr_cb(const struct nlattr *attr, void *data) return MNL_CB_ERROR; if (type == CTRL_ATTR_FAMILY_ID && - mnl_attr_validate(attr, MNL_TYPE_U16) < 0) + mnl_attr_validate(attr, MNL_TYPE_U16) < 0) return MNL_CB_ERROR; tb[type] = attr; return MNL_CB_OK; @@ -1531,11 +1531,11 @@ static int decode_base64(const char src[static 4]) for (i = 0; i < 4; ++i) val |= (-1 - + ((((('A' - 1) - src[i]) & (src[i] - ('Z' + 1))) >> 8) & (src[i] - 64)) - + ((((('a' - 1) - src[i]) & (src[i] - ('z' + 1))) >> 8) & (src[i] - 70)) - + ((((('0' - 1) - src[i]) & (src[i] - ('9' + 1))) >> 8) & (src[i] + 5)) - + ((((('+' - 1) - src[i]) & (src[i] - ('+' + 1))) >> 8) & 63) - + ((((('/' - 1) - src[i]) & (src[i] - ('/' + 1))) >> 8) & 64) + + ((((('A' - 1) - src[i]) & (src[i] - ('Z' + 1))) >> 8) & (src[i] - 64)) + + ((((('a' - 1) - src[i]) & (src[i] - ('z' + 1))) >> 8) & (src[i] - 70)) + + ((((('0' - 1) - src[i]) & (src[i] - ('9' + 1))) >> 8) & (src[i] + 5)) + + ((((('+' - 1) - src[i]) & (src[i] - ('+' + 1))) >> 8) & 63) + + ((((('/' - 1) - src[i]) & (src[i] - ('/' + 1))) >> 8) & 64) ) << (18 - 6 * i); return val; } diff --git a/src/ipc-linux.h b/src/ipc-linux.h index c6550db..8626e1d 100644 --- a/src/ipc-linux.h +++ b/src/ipc-linux.h @@ -461,57 +461,57 @@ static int parse_device(const struct nlattr *attr, void *data) return mnl_attr_parse_nested(attr, parse_peers, device); case WGDEVICE_A_JC: if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { - device->junk_packet_count = mnl_attr_get_u16(attr); - device->flags |= WGDEVICE_HAS_JC; - } + device->junk_packet_count = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_JC; + } break; case WGDEVICE_A_JMIN: if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { - device->junk_packet_min_size = mnl_attr_get_u16(attr); - device->flags |= WGDEVICE_HAS_JMIN; - } + device->junk_packet_min_size = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_JMIN; + } break; case WGDEVICE_A_JMAX: if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { - device->junk_packet_max_size = mnl_attr_get_u16(attr); - device->flags |= WGDEVICE_HAS_JMAX; - } + device->junk_packet_max_size = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_JMAX; + } break; case WGDEVICE_A_S1: if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { - device->init_packet_junk_size = mnl_attr_get_u16(attr); - device->flags |= WGDEVICE_HAS_S1; - } + device->init_packet_junk_size = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_S1; + } break; case WGDEVICE_A_S2: if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { - device->response_packet_junk_size = mnl_attr_get_u16(attr); - device->flags |= WGDEVICE_HAS_S2; - } + device->response_packet_junk_size = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_S2; + } break; case WGDEVICE_A_H1: if (!mnl_attr_validate(attr, MNL_TYPE_U32)) { - device->init_packet_magic_header = mnl_attr_get_u32(attr); - device->flags |= WGDEVICE_HAS_H1; - } + device->init_packet_magic_header = mnl_attr_get_u32(attr); + device->flags |= WGDEVICE_HAS_H1; + } break; case WGDEVICE_A_H2: if (!mnl_attr_validate(attr, MNL_TYPE_U32)) { - device->response_packet_magic_header = mnl_attr_get_u32(attr); - device->flags |= WGDEVICE_HAS_H2; - } + device->response_packet_magic_header = mnl_attr_get_u32(attr); + device->flags |= WGDEVICE_HAS_H2; + } break; case WGDEVICE_A_H3: if (!mnl_attr_validate(attr, MNL_TYPE_U32)) { - device->underload_packet_magic_header = mnl_attr_get_u32(attr); - device->flags |= WGDEVICE_HAS_H3; - } + device->underload_packet_magic_header = mnl_attr_get_u32(attr); + device->flags |= WGDEVICE_HAS_H3; + } break; case WGDEVICE_A_H4: if (!mnl_attr_validate(attr, MNL_TYPE_U32)) { - device->transport_packet_magic_header = mnl_attr_get_u32(attr); - device->flags |= WGDEVICE_HAS_H4; - } + device->transport_packet_magic_header = mnl_attr_get_u32(attr); + device->flags |= WGDEVICE_HAS_H4; + } break; } diff --git a/src/uapi/linux/linux/wireguard.h b/src/uapi/linux/linux/wireguard.h index 4c2eb25..5cba5a4 100644 --- a/src/uapi/linux/linux/wireguard.h +++ b/src/uapi/linux/linux/wireguard.h @@ -1,4 +1,4 @@ - /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ +/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ /* * Copyright (C) 2015-2020 Jason A. Donenfeld . All Rights Reserved. *