From c17752dbf0d4642e8567f36a2188e5979e5ec904 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 22 Sep 2021 04:09:21 +0100 Subject: [PATCH] Fix C89. --- adler32.c | 3 ++- crc16.c | 3 ++- crc16_ccitt.c | 3 ++- fletcher16.c | 3 ++- fletcher32.c | 3 ++- spamsum.c | 4 +++- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/adler32.c b/adler32.c index 0e4e5f9..a061ee6 100644 --- a/adler32.c +++ b/adler32.c @@ -38,9 +38,10 @@ AARU_EXPORT adler32_ctx* AARU_CALL adler32_init() AARU_EXPORT int AARU_CALL adler32_update(adler32_ctx* ctx, const uint8_t* data, uint32_t len) { + uint32_t i; if(!ctx || !data) return -1; - for(uint32_t i = 0; i < len; i++) + for(i = 0; i < len; i++) { ctx->sum1 = (ctx->sum1 + data[i]) % ADLER_MODULE; ctx->sum2 = (ctx->sum2 + ctx->sum1) % ADLER_MODULE; diff --git a/crc16.c b/crc16.c index 7a6f42d..86f9144 100644 --- a/crc16.c +++ b/crc16.c @@ -35,9 +35,10 @@ AARU_EXPORT crc16_ctx* AARU_CALL crc16_init(void) AARU_EXPORT int AARU_CALL crc16_update(crc16_ctx* ctx, const uint8_t* data, uint32_t len) { + uint32_t i; if(!ctx || !data) return -1; - for(uint32_t i = 0; i < len; i++) ctx->crc = (ctx->crc >> 8) ^ crc16_table[data[i] ^ (ctx->crc & 0xFF)]; + for(i = 0; i < len; i++) ctx->crc = (ctx->crc >> 8) ^ crc16_table[data[i] ^ (ctx->crc & 0xFF)]; return 0; } diff --git a/crc16_ccitt.c b/crc16_ccitt.c index f7f10eb..9880a01 100644 --- a/crc16_ccitt.c +++ b/crc16_ccitt.c @@ -35,9 +35,10 @@ AARU_EXPORT crc16_ccitt_ctx* AARU_CALL crc16_ccitt_init(void) AARU_EXPORT int AARU_CALL crc16_ccitt_update(crc16_ccitt_ctx* ctx, const uint8_t* data, uint32_t len) { + uint32_t i; if(!ctx || !data) return -1; - for(uint32_t i = 0; i < len; i++) ctx->crc = crc16_ccitt_table[(ctx->crc >> 8) ^ data[i]] ^ (ctx->crc << 8); + for(i = 0; i < len; i++) ctx->crc = crc16_ccitt_table[(ctx->crc >> 8) ^ data[i]] ^ (ctx->crc << 8); return 0; } diff --git a/fletcher16.c b/fletcher16.c index a7b4d03..d675699 100644 --- a/fletcher16.c +++ b/fletcher16.c @@ -38,9 +38,10 @@ AARU_EXPORT fletcher16_ctx* AARU_CALL fletcher16_init() AARU_EXPORT int AARU_CALL fletcher16_update(fletcher16_ctx* ctx, const uint8_t* data, uint32_t len) { + uint32_t i; if(!ctx || !data) return -1; - for(uint32_t i = 0; i < len; i++) + for(i = 0; i < len; i++) { ctx->sum1 = (ctx->sum1 + data[i]) % FLETCHER16_MODULE; ctx->sum2 = (ctx->sum2 + ctx->sum1) % FLETCHER16_MODULE; diff --git a/fletcher32.c b/fletcher32.c index 81186bc..246bb6d 100644 --- a/fletcher32.c +++ b/fletcher32.c @@ -38,9 +38,10 @@ AARU_EXPORT fletcher32_ctx* AARU_CALL fletcher32_init() AARU_EXPORT int AARU_CALL fletcher32_update(fletcher32_ctx* ctx, const uint8_t* data, uint32_t len) { + uint32_t i; if(!ctx || !data) return -1; - for(uint32_t i = 0; i < len; i++) + for(i = 0; i < len; i++) { ctx->sum1 = (ctx->sum1 + data[i]) % FLETCHER32_MODULE; ctx->sum2 = (ctx->sum2 + ctx->sum1) % FLETCHER32_MODULE; diff --git a/spamsum.c b/spamsum.c index 3073fdf..aced371 100644 --- a/spamsum.c +++ b/spamsum.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "library.h" #include "spamsum.h" @@ -45,9 +46,10 @@ AARU_EXPORT spamsum_ctx* AARU_CALL spamsum_init(void) AARU_EXPORT int AARU_CALL spamsum_update(spamsum_ctx* ctx, const uint8_t* data, uint32_t len) { + int i; if(!ctx || !data) return -1; - for(int i = 0; i < len; i++) fuzzy_engine_step(ctx, data[i]); + for( i = 0; i < len; i++) fuzzy_engine_step(ctx, data[i]); ctx->total_size += len;