1
0
Fork 0

Clang-format and clang-tidy fixes

This commit is contained in:
Shawn Nock 2016-09-29 12:50:08 -04:00
parent 2e2e4951c5
commit f6da1e90b1
8 changed files with 45 additions and 47 deletions

3
aes.c
View File

@ -29,8 +29,9 @@ void aes128_ecb(uint8_t *dest, uint8_t const *const in) {
#else #else
memmove(g_ecbdata.in, in, 16); memmove(g_ecbdata.in, in, 16);
NRF_ECB->TASKS_STARTECB = 1; NRF_ECB->TASKS_STARTECB = 1;
while (!NRF_ECB->EVENTS_ENDECB) while (!NRF_ECB->EVENTS_ENDECB) {
; ;
}
NRF_ECB->EVENTS_ENDECB = 0; NRF_ECB->EVENTS_ENDECB = 0;
#endif /* HOST_BUILD */ #endif /* HOST_BUILD */
memmove(dest, g_ecbdata.out, 16); memmove(dest, g_ecbdata.out, 16);

View File

@ -1,8 +1,6 @@
/* Utility functions for manipulating block_t structures; 128bit /* Utility functions for manipulating block_t structures; 128bit
blocks of data for AES & CMAC */ blocks of data for AES & CMAC */
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>

4
ckdf.c
View File

@ -23,8 +23,8 @@ void ckdf_extract(uint8_t *prk, const uint8_t *salt, const uint8_t *ikm,
cmac_aes128(prk, (uint8_t *)ikm, ikm_len, 16); cmac_aes128(prk, (uint8_t *)ikm, ikm_len, 16);
} }
void ckdf_expand(uint8_t *okm, uint8_t *prk, uint8_t *info, void ckdf_expand(uint8_t *okm, uint8_t *prk, uint8_t *info, uint32_t info_len,
uint32_t info_len, uint32_t okm_len) { uint32_t okm_len) {
uint32_t num_blocks = okm_len / 16; uint32_t num_blocks = okm_len / 16;
/* Simulate ceiling division instead of C std floor */ /* Simulate ceiling division instead of C std floor */
uint8_t remainder = okm_len % 16; uint8_t remainder = okm_len % 16;

1
ckdf.h
View File

@ -9,4 +9,3 @@
void ckdf_extract(uint8_t *, const uint8_t *, const uint8_t *, uint32_t); void ckdf_extract(uint8_t *, const uint8_t *, const uint8_t *, uint32_t);
void ckdf_expand(uint8_t *, uint8_t *, uint8_t *, uint32_t, uint32_t); void ckdf_expand(uint8_t *, uint8_t *, uint8_t *, uint32_t, uint32_t);

3
rng.c
View File

@ -16,8 +16,9 @@ uint8_t rng_byte(void) {
void rng_bytes(uint8_t *out, uint32_t num_bytes) { void rng_bytes(uint8_t *out, uint32_t num_bytes) {
NRF_RNG->TASKS_START = 1; NRF_RNG->TASKS_START = 1;
for (uint32_t i = 0; i < num_bytes; i++) { for (uint32_t i = 0; i < num_bytes; i++) {
while (!NRF_RNG->EVENTS_VALRDY) while (!NRF_RNG->EVENTS_VALRDY) {
; ;
}
out[i] = (uint8_t)NRF_RNG->VALUE; out[i] = (uint8_t)NRF_RNG->VALUE;
NRF_RNG->EVENTS_VALRDY = 0; NRF_RNG->EVENTS_VALRDY = 0;
} }

View File

@ -5,6 +5,5 @@ clang-tidy \
-header-filter=.* \ -header-filter=.* \
--checks=readability-braces-around-statements,misc-macro-parentheses \ --checks=readability-braces-around-statements,misc-macro-parentheses \
*.c \ *.c \
-- -I. -- -DNRF51 -I. -I ../../../nrf-sdk/6.1/nrf51822/Include -I ../../../nrf-sdk/6.1/nrf51822/Include/gcc
clang-format -style="{BasedOnStyle: llvm, IndentWidth: 4, AllowShortFunctionsOnASingleLine: None, KeepEmptyLinesAtTheStartOfBlocks: false}" -i *.{h,c} clang-format -style="{BasedOnStyle: llvm, IndentWidth: 4, AllowShortFunctionsOnASingleLine: None, KeepEmptyLinesAtTheStartOfBlocks: false}" -i *.{h,c}