From 9c853b962d73565f2980789a32f347309bcc605f Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 25 Oct 2011 14:50:14 -0400 Subject: reed-solomon: fixed the signed/unsigned warnings in the RS code. Some of these had to be done through type-casting since changing the actual data type would cause the tests to fail. make test still passes. --- gnuradio-core/src/lib/reed-solomon/char.h | 2 +- gnuradio-core/src/lib/reed-solomon/decode_rs.c | 26 +++++++++++++------------- gnuradio-core/src/lib/reed-solomon/encode_rs.c | 2 +- gnuradio-core/src/lib/reed-solomon/exercise.c | 10 +++++----- gnuradio-core/src/lib/reed-solomon/init_rs.c | 9 +++++---- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/gnuradio-core/src/lib/reed-solomon/char.h b/gnuradio-core/src/lib/reed-solomon/char.h index 8010fb0b9..762e9e295 100644 --- a/gnuradio-core/src/lib/reed-solomon/char.h +++ b/gnuradio-core/src/lib/reed-solomon/char.h @@ -21,7 +21,7 @@ struct rs { unsigned char iprim; /* prim-th root of 1, index form */ }; -static inline int modnn(struct rs *rs,int x){ +static inline unsigned int modnn(struct rs *rs, unsigned int x){ while (x >= rs->nn) { x -= rs->nn; x = (x >> rs->mm) + (x & rs->nn); diff --git a/gnuradio-core/src/lib/reed-solomon/decode_rs.c b/gnuradio-core/src/lib/reed-solomon/decode_rs.c index ba60b89ee..4b7d27cec 100644 --- a/gnuradio-core/src/lib/reed-solomon/decode_rs.c +++ b/gnuradio-core/src/lib/reed-solomon/decode_rs.c @@ -30,7 +30,7 @@ DTYPE *data, int *eras_pos, int no_eras){ struct rs *rs = (struct rs *)p; #endif int deg_lambda, el, deg_omega; - int i, j, r,k; + int i, j, r, k; #ifdef MAX_ARRAY DTYPE u,q,tmp,num1,num2,den,discr_r; DTYPE lambda[MAX_ARRAY], s[MAX_ARRAY]; /* Err+Eras Locator poly @@ -47,11 +47,11 @@ DTYPE *data, int *eras_pos, int no_eras){ int syn_error, count; /* form the syndromes; i.e., evaluate data(x) at roots of g(x) */ - for(i=0;i 0; j--){ if (reg[j] != A0) { @@ -218,7 +218,7 @@ DTYPE *data, int *eras_pos, int no_eras){ * x**NROOTS). in index form. Also find deg(omega). */ deg_omega = 0; - for (i = 0; i < NROOTS;i++){ + for (i = 0; (unsigned int)i < NROOTS;i++){ tmp = 0; j = (deg_lambda < i) ? deg_lambda : i; for(;j >= 0; j--){ @@ -245,7 +245,7 @@ DTYPE *data, int *eras_pos, int no_eras){ den = 0; /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */ - for (i = min(deg_lambda,NROOTS-1) & ~1; i >= 0; i -=2) { + for (i = (int)min((unsigned int)deg_lambda,NROOTS-1) & ~1; i >= 0; i -=2) { if(lambda[i+1] != A0) den ^= ALPHA_TO[MODNN(lambda[i+1] + i * root[j])]; } diff --git a/gnuradio-core/src/lib/reed-solomon/encode_rs.c b/gnuradio-core/src/lib/reed-solomon/encode_rs.c index 9d56d0bf1..cd31f32c6 100644 --- a/gnuradio-core/src/lib/reed-solomon/encode_rs.c +++ b/gnuradio-core/src/lib/reed-solomon/encode_rs.c @@ -20,7 +20,7 @@ DTYPE *data, DTYPE *bb){ #ifndef FIXED struct rs *rs = (struct rs *)p; #endif - int i, j; + unsigned int i, j; DTYPE feedback; memset(bb,0,NROOTS*sizeof(DTYPE)); diff --git a/gnuradio-core/src/lib/reed-solomon/exercise.c b/gnuradio-core/src/lib/reed-solomon/exercise.c index 987fe1aeb..be3d3bd13 100644 --- a/gnuradio-core/src/lib/reed-solomon/exercise.c +++ b/gnuradio-core/src/lib/reed-solomon/exercise.c @@ -48,13 +48,13 @@ int trials){ #endif #if MAX_ARRAY DTYPE block[MAX_ARRAY],tblock[MAX_ARRAY]; - int i; + unsigned int i; int errors; int errlocs[MAX_ARRAY]; int derrlocs[MAX_ARRAY]; #else DTYPE block[NN],tblock[NN]; - int i; + unsigned int i; int errors; int errlocs[NN]; int derrlocs[NROOTS]; @@ -66,7 +66,7 @@ int trials){ while(trials-- != 0){ /* Test up to the error correction capacity of the code */ - for(errors=0;errors <= NROOTS/2;errors++){ + for(errors=0;(unsigned int)errors <= NROOTS/2;errors++){ /* Load block with random data and encode */ for(i=0;i 8*sizeof(DTYPE)) return NULL; /* Need version with ints rather than chars */ - if(fcr >= (1<= (1u<= (1<= (1u<= (1<= (1u<