aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/cookie.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-07-27 11:30:05 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-08-02 02:55:42 +0200
commit2b8dd0d6ee4309d74efb7d4f28086e91381fd72a (patch)
tree88b4323468ad47112bdbea30532f7fe11f590d03 /src/cookie.c
parenttimers: use more clear pow macro (diff)
downloadwireguard-monolithic-historical-2b8dd0d6ee4309d74efb7d4f28086e91381fd72a.tar.xz
wireguard-monolithic-historical-2b8dd0d6ee4309d74efb7d4f28086e91381fd72a.zip
c: specify static array size in function params
The C standard states: A declaration of a parameter as ``array of type'' shall be adjusted to ``qualified pointer to type'', where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size expression. By changing void func(int array[4]) to void func(int array[static 4]), we automatically get the compiler checking argument sizes for us, which is quite nice.
Diffstat (limited to 'src/cookie.c')
-rw-r--r--src/cookie.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cookie.c b/src/cookie.c
index 0409b56..614393e 100644
--- a/src/cookie.c
+++ b/src/cookie.c
@@ -32,7 +32,7 @@ void cookie_init(struct cookie *cookie)
init_rwsem(&cookie->lock);
}
-static void compute_mac1(u8 mac1[COOKIE_LEN], const void *message, size_t len, const u8 pubkey[NOISE_PUBLIC_KEY_LEN], const u8 psk[NOISE_SYMMETRIC_KEY_LEN])
+static void compute_mac1(u8 mac1[static COOKIE_LEN], const void *message, size_t len, const u8 pubkey[static NOISE_PUBLIC_KEY_LEN], const u8 psk[static NOISE_SYMMETRIC_KEY_LEN])
{
struct blake2s_state state;
len = len - sizeof(struct message_macs) + offsetof(struct message_macs, mac1);
@@ -46,7 +46,7 @@ static void compute_mac1(u8 mac1[COOKIE_LEN], const void *message, size_t len, c
blake2s_final(&state, mac1, COOKIE_LEN);
}
-static void compute_mac2(u8 mac2[COOKIE_LEN], const void *message, size_t len, const u8 cookie[COOKIE_LEN])
+static void compute_mac2(u8 mac2[static COOKIE_LEN], const void *message, size_t len, const u8 cookie[static COOKIE_LEN])
{
len = len - sizeof(struct message_macs) + offsetof(struct message_macs, mac2);
blake2s(mac2, message, cookie, COOKIE_LEN, len, COOKIE_LEN);
@@ -69,7 +69,7 @@ static inline void put_secret(struct cookie_checker *checker)
up_read(&checker->secret_lock);
}
-static void make_cookie(u8 cookie[COOKIE_LEN], struct sk_buff *skb, struct cookie_checker *checker)
+static void make_cookie(u8 cookie[static COOKIE_LEN], struct sk_buff *skb, struct cookie_checker *checker)
{
struct blake2s_state state;
const u8 *secret;