diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-07-27 11:30:05 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-08-02 02:55:42 +0200 |
commit | 598f4c8542b3152f7cfb873532724e5db1eb1092 (patch) | |
tree | ec63ea440a02b21711d6c481311cb09f28523398 /src/cookie.c | |
parent | cc605ab76a8dd926a28a8e9b857fd09606a524f6 (diff) |
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.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/cookie.c')
-rw-r--r-- | src/cookie.c | 6 |
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; |