mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-19 04:52:12 +01:00
uncrustify
This commit is contained in:
parent
b9bfcd18d2
commit
aa55b1523d
@ -53,12 +53,14 @@ __RCSID("$NetBSD: sha1.c,v 1.6 2009/11/06 20:31:18 joerg Exp $");
|
|||||||
* I got the idea of expanding during the round function from SSLeay
|
* I got the idea of expanding during the round function from SSLeay
|
||||||
*/
|
*/
|
||||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||||
# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|
# define blk0(i) \
|
||||||
|
(block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) \
|
||||||
| (rol(block->l[i], 8) & 0x00FF00FF))
|
| (rol(block->l[i], 8) & 0x00FF00FF))
|
||||||
#else
|
#else
|
||||||
# define blk0(i) block->l[i]
|
# define blk0(i) block->l[i]
|
||||||
#endif
|
#endif
|
||||||
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
|
#define blk(i) \
|
||||||
|
(block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ block->l[(i + 8) & 15] \
|
||||||
^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1))
|
^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -103,8 +105,7 @@ void do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR
|
|||||||
#define nR3(v, w, x, y, z, i) R3(*v, *w, *x, *y, *z, i)
|
#define nR3(v, w, x, y, z, i) R3(*v, *w, *x, *y, *z, i)
|
||||||
#define nR4(v, w, x, y, z, i) R4(*v, *w, *x, *y, *z, i)
|
#define nR4(v, w, x, y, z, i) R4(*v, *w, *x, *y, *z, i)
|
||||||
|
|
||||||
void
|
void do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
|
||||||
do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
|
|
||||||
{
|
{
|
||||||
nR0(a, b, c, d, e, 0); nR0(e, a, b, c, d, 1); nR0(d, e, a, b, c, 2); nR0(c, d, e, a, b, 3);
|
nR0(a, b, c, d, e, 0); nR0(e, a, b, c, d, 1); nR0(d, e, a, b, c, 2); nR0(c, d, e, a, b, 3);
|
||||||
nR0(b, c, d, e, a, 4); nR0(a, b, c, d, e, 5); nR0(e, a, b, c, d, 6); nR0(d, e, a, b, c, 7);
|
nR0(b, c, d, e, a, 4); nR0(a, b, c, d, e, 5); nR0(e, a, b, c, d, 6); nR0(d, e, a, b, c, 7);
|
||||||
@ -113,8 +114,7 @@ do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LO
|
|||||||
nR1(e, a, b, c, d, 16); nR1(d, e, a, b, c, 17); nR1(c, d, e, a, b, 18); nR1(b, c, d, e, a, 19);
|
nR1(e, a, b, c, d, 16); nR1(d, e, a, b, c, 17); nR1(c, d, e, a, b, 18); nR1(b, c, d, e, a, 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
|
||||||
do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
|
|
||||||
{
|
{
|
||||||
nR2(a, b, c, d, e, 20); nR2(e, a, b, c, d, 21); nR2(d, e, a, b, c, 22); nR2(c, d, e, a, b, 23);
|
nR2(a, b, c, d, e, 20); nR2(e, a, b, c, d, 21); nR2(d, e, a, b, c, 22); nR2(c, d, e, a, b, 23);
|
||||||
nR2(b, c, d, e, a, 24); nR2(a, b, c, d, e, 25); nR2(e, a, b, c, d, 26); nR2(d, e, a, b, c, 27);
|
nR2(b, c, d, e, a, 24); nR2(a, b, c, d, e, 25); nR2(e, a, b, c, d, 26); nR2(d, e, a, b, c, 27);
|
||||||
@ -123,8 +123,7 @@ do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LON
|
|||||||
nR2(e, a, b, c, d, 36); nR2(d, e, a, b, c, 37); nR2(c, d, e, a, b, 38); nR2(b, c, d, e, a, 39);
|
nR2(e, a, b, c, d, 36); nR2(d, e, a, b, c, 37); nR2(c, d, e, a, b, 38); nR2(b, c, d, e, a, 39);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
|
||||||
do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
|
|
||||||
{
|
{
|
||||||
nR3(a, b, c, d, e, 40); nR3(e, a, b, c, d, 41); nR3(d, e, a, b, c, 42); nR3(c, d, e, a, b, 43);
|
nR3(a, b, c, d, e, 40); nR3(e, a, b, c, d, 41); nR3(d, e, a, b, c, 42); nR3(c, d, e, a, b, 43);
|
||||||
nR3(b, c, d, e, a, 44); nR3(a, b, c, d, e, 45); nR3(e, a, b, c, d, 46); nR3(d, e, a, b, c, 47);
|
nR3(b, c, d, e, a, 44); nR3(a, b, c, d, e, 45); nR3(e, a, b, c, d, 46); nR3(d, e, a, b, c, 47);
|
||||||
@ -133,8 +132,7 @@ do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LON
|
|||||||
nR3(e, a, b, c, d, 56); nR3(d, e, a, b, c, 57); nR3(c, d, e, a, b, 58); nR3(b, c, d, e, a, 59);
|
nR3(e, a, b, c, d, 56); nR3(d, e, a, b, c, 57); nR3(c, d, e, a, b, 58); nR3(b, c, d, e, a, 59);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
|
||||||
do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
|
|
||||||
{
|
{
|
||||||
nR4(a, b, c, d, e, 60); nR4(e, a, b, c, d, 61); nR4(d, e, a, b, c, 62); nR4(c, d, e, a, b, 63);
|
nR4(a, b, c, d, e, 60); nR4(e, a, b, c, d, 61); nR4(d, e, a, b, c, 62); nR4(c, d, e, a, b, 63);
|
||||||
nR4(b, c, d, e, a, 64); nR4(a, b, c, d, e, 65); nR4(e, a, b, c, d, 66); nR4(d, e, a, b, c, 67);
|
nR4(b, c, d, e, a, 64); nR4(a, b, c, d, e, 65); nR4(e, a, b, c, d, 66); nR4(d, e, a, b, c, 67);
|
||||||
@ -142,7 +140,7 @@ do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LON
|
|||||||
nR4(d, e, a, b, c, 72); nR4(c, d, e, a, b, 73); nR4(b, c, d, e, a, 74); nR4(a, b, c, d, e, 75);
|
nR4(d, e, a, b, c, 72); nR4(c, d, e, a, b, 73); nR4(b, c, d, e, a, 74); nR4(a, b, c, d, e, 75);
|
||||||
nR4(e, a, b, c, d, 76); nR4(d, e, a, b, c, 77); nR4(c, d, e, a, b, 78); nR4(b, c, d, e, a, 79);
|
nR4(e, a, b, c, d, 76); nR4(d, e, a, b, c, 77); nR4(c, d, e, a, b, 78); nR4(b, c, d, e, a, 79);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ifdef SPARC64_GCC_WORKAROUND */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hash a single 512-bit block. This is the core of the algorithm.
|
* Hash a single 512-bit block. This is the core of the algorithm.
|
||||||
@ -197,7 +195,7 @@ void SHA1Transform(uint32_t state[5], const uint8_t buffer[64])
|
|||||||
R4(c, d, e, a, b, 68); R4(b, c, d, e, a, 69); R4(a, b, c, d, e, 70); R4(e, a, b, c, d, 71);
|
R4(c, d, e, a, b, 68); R4(b, c, d, e, a, 69); R4(a, b, c, d, e, 70); R4(e, a, b, c, d, 71);
|
||||||
R4(d, e, a, b, c, 72); R4(c, d, e, a, b, 73); R4(b, c, d, e, a, 74); R4(a, b, c, d, e, 75);
|
R4(d, e, a, b, c, 72); R4(c, d, e, a, b, 73); R4(b, c, d, e, a, 74); R4(a, b, c, d, e, 75);
|
||||||
R4(e, a, b, c, d, 76); R4(d, e, a, b, c, 77); R4(c, d, e, a, b, 78); R4(b, c, d, e, a, 79);
|
R4(e, a, b, c, d, 76); R4(d, e, a, b, c, 77); R4(c, d, e, a, b, 78); R4(b, c, d, e, a, 79);
|
||||||
#endif
|
#endif /* ifdef SPARC64_GCC_WORKAROUND */
|
||||||
|
|
||||||
/* Add the working vars back into context.state[] */
|
/* Add the working vars back into context.state[] */
|
||||||
state[0] += a;
|
state[0] += a;
|
||||||
@ -216,7 +214,6 @@ void SHA1Transform(uint32_t state[5], const uint8_t buffer[64])
|
|||||||
*/
|
*/
|
||||||
void SHA1Init(SHA1_CTX *context)
|
void SHA1Init(SHA1_CTX *context)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* SHA1 initialization constants */
|
/* SHA1 initialization constants */
|
||||||
context->state[0] = 0x67452301;
|
context->state[0] = 0x67452301;
|
||||||
context->state[1] = 0xEFCDAB89;
|
context->state[1] = 0xEFCDAB89;
|
||||||
@ -235,14 +232,16 @@ void SHA1Update(SHA1_CTX *context, const uint8_t *data, unsigned int len)
|
|||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
j = context->count[0];
|
j = context->count[0];
|
||||||
if ((context->count[0] += len << 3) < j)
|
if ((context->count[0] += len << 3) < j) {
|
||||||
context->count[1] += (len >> 29) + 1;
|
context->count[1] += (len >> 29) + 1;
|
||||||
|
}
|
||||||
j = (j >> 3) & 63;
|
j = (j >> 3) & 63;
|
||||||
if ((j + len) > 63) {
|
if ((j + len) > 63) {
|
||||||
(void)memcpy(&context->buffer[j], data, (i = 64 - j));
|
(void)memcpy(&context->buffer[j], data, (i = 64 - j));
|
||||||
SHA1Transform(context->state, context->buffer);
|
SHA1Transform(context->state, context->buffer);
|
||||||
for ( ; i + 63 < len; i += 64)
|
for (; i + 63 < len; i += 64) {
|
||||||
SHA1Transform(context->state, &data[i]);
|
SHA1Transform(context->state, &data[i]);
|
||||||
|
}
|
||||||
j = 0;
|
j = 0;
|
||||||
} else {
|
} else {
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -264,15 +263,17 @@ void SHA1Final(uint8_t digest[20], SHA1_CTX *context)
|
|||||||
>> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */
|
>> ((3 - (i & 3)) * 8)) & 255); /* Endian independent */
|
||||||
}
|
}
|
||||||
SHA1Update(context, (const uint8_t *)"\200", 1);
|
SHA1Update(context, (const uint8_t *)"\200", 1);
|
||||||
while ((context->count[0] & 504) != 448)
|
while ((context->count[0] & 504) != 448) {
|
||||||
SHA1Update(context, (const uint8_t *)"\0", 1);
|
SHA1Update(context, (const uint8_t *)"\0", 1);
|
||||||
|
}
|
||||||
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
|
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
|
||||||
|
|
||||||
if (digest) {
|
if (digest) {
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++) {
|
||||||
digest[i] = (uint8_t)
|
digest[i] = (uint8_t)
|
||||||
((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
|
((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_SHA1_H */
|
#endif /* HAVE_SHA1_H */
|
||||||
|
@ -2254,7 +2254,6 @@ static uint8_t rfm22_calcChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t ind
|
|||||||
if (!rfm22_isCoordinator(rfm22b_dev) &&
|
if (!rfm22_isCoordinator(rfm22b_dev) &&
|
||||||
pios_rfm22_time_difference_ms(rfm22b_dev->last_contact, xTaskGetTickCount()) >=
|
pios_rfm22_time_difference_ms(rfm22b_dev->last_contact, xTaskGetTickCount()) >=
|
||||||
CONNECTED_TIMEOUT) {
|
CONNECTED_TIMEOUT) {
|
||||||
|
|
||||||
// Set the link state to disconnected.
|
// Set the link state to disconnected.
|
||||||
if (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED) {
|
if (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED) {
|
||||||
rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_DISCONNECTED;
|
rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_DISCONNECTED;
|
||||||
@ -2574,8 +2573,7 @@ static uint8_t rfm22_read(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void rfm22_hmac_sha1(const uint8_t *data, size_t len,
|
||||||
rfm22_hmac_sha1(const uint8_t *data, size_t len,
|
|
||||||
uint8_t key[SHA1_DIGEST_LENGTH],
|
uint8_t key[SHA1_DIGEST_LENGTH],
|
||||||
uint8_t digest[SHA1_DIGEST_LENGTH])
|
uint8_t digest[SHA1_DIGEST_LENGTH])
|
||||||
{
|
{
|
||||||
@ -2606,8 +2604,7 @@ rfm22_hmac_sha1(const uint8_t *data, size_t len,
|
|||||||
pios_free(ctx);
|
pios_free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool rfm22_gen_channels(uint32_t coordid, enum rfm22b_datarate rate, uint8_t min,
|
||||||
rfm22_gen_channels(uint32_t coordid, enum rfm22b_datarate rate, uint8_t min,
|
|
||||||
uint8_t max, uint8_t channels[MAX_CHANNELS], uint8_t *clen)
|
uint8_t max, uint8_t channels[MAX_CHANNELS], uint8_t *clen)
|
||||||
{
|
{
|
||||||
uint32_t data = 0;
|
uint32_t data = 0;
|
||||||
@ -2652,7 +2649,7 @@ rfm22_gen_channels(uint32_t coordid, enum rfm22b_datarate rate, uint8_t min,
|
|||||||
|
|
||||||
pios_free(all_channels);
|
pios_free(all_channels);
|
||||||
|
|
||||||
return (*clen > 0);
|
return *clen > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PIOS_INCLUDE_RFM22B */
|
#endif /* PIOS_INCLUDE_RFM22B */
|
||||||
|
@ -489,7 +489,8 @@ void PIOS_Board_Init(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PIOS_Board_PPM_callback(const int16_t * channels) {
|
static void PIOS_Board_PPM_callback(const int16_t *channels)
|
||||||
|
{
|
||||||
#if defined(PIOS_INCLUDE_PPM) && defined(PIOS_INCLUDE_PPM_OUT)
|
#if defined(PIOS_INCLUDE_PPM) && defined(PIOS_INCLUDE_PPM_OUT)
|
||||||
if (pios_ppm_out_id) {
|
if (pios_ppm_out_id) {
|
||||||
for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) {
|
for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user