X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fkernel%2Fao_fec_tx.c;h=3feb1301fc05905582e5ff5936286531e52a5b26;hb=HEAD;hp=4941d74581254ec26402218b9ed952cdbc03138b;hpb=24167015705ae831692b95735968b04a876f935e;p=fw%2Faltos diff --git a/src/kernel/ao_fec_tx.c b/src/kernel/ao_fec_tx.c index 4941d745..209581b8 100644 --- a/src/kernel/ao_fec_tx.c +++ b/src/kernel/ao_fec_tx.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -53,7 +54,7 @@ uint8_t ao_fec_check_crc(const uint8_t *bytes, uint8_t len) { uint16_t computed_crc = ao_fec_crc(bytes, len); - uint16_t received_crc = (bytes[len] << 8) | (bytes[len+1]); + uint16_t received_crc = (uint16_t) ((bytes[len] << 8) | (bytes[len+1])); return computed_crc == received_crc; } @@ -69,11 +70,11 @@ ao_fec_prepare(const uint8_t *in, uint8_t len, uint8_t *extra) uint8_t num_fec; /* Append CRC */ - extra[i++] = crc >> 8; - extra[i++] = crc; + extra[i++] = (uint8_t) (crc >> 8); + extra[i++] = (uint8_t) crc; /* Append FEC -- 1 byte if odd, two bytes if even */ - num_fec = 2 - (i & 1); + num_fec = 2 - (len & 1); while (num_fec--) extra[i++] = AO_FEC_TRELLIS_TERMINATOR; return i; @@ -111,7 +112,7 @@ ao_fec_encode(const uint8_t *in, uint8_t len, uint8_t *out) for (byte = 0; byte < 2; byte++) { if (pair + byte == len) in = extra; - fec |= *in++ ^ *whiten++; + fec |= (uint16_t) (*in++ ^ *whiten++); for (bit = 0; bit < 8; bit++) { encode = encode << 2 | ao_fec_encode_table[fec >> 7]; fec = (fec << 1) & 0x7ff; @@ -125,10 +126,10 @@ ao_fec_encode(const uint8_t *in, uint8_t len, uint8_t *out) interleave = (interleave << 2) | ((encode >> (byte_shift + bit_shift)) & 0x3); } - *out++ = interleave >> 24; - *out++ = interleave >> 16; - *out++ = interleave >> 8; - *out++ = interleave >> 0; + *out++ = (uint8_t) (interleave >> 24); + *out++ = (uint8_t) (interleave >> 16); + *out++ = (uint8_t) (interleave >> 8); + *out++ = (uint8_t) (interleave >> 0); } - return (len + extra_len) * 2; + return (uint8_t) ((len + extra_len) * 2); }