Adds many syntactically unnecessary parentheses to silence GCC -Wparentheses.

The object code is unchanged (except ectest). Also reenables -Wparentheses, -Wsign-compare,
and the MSVC warnings.
This commit is contained in:
Gregory Maxwell 2011-08-30 19:50:41 -04:00 committed by Jean-Marc Valin
parent 17a29c2567
commit d6335abedc
10 changed files with 40 additions and 46 deletions

View file

@ -161,7 +161,7 @@ AC_SUBST(SYMBOL_VISIBILITY)
fi
if test $ac_cv_c_compiler_gnu = yes ; then
CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-parentheses -Wno-unused-parameter -Wno-sign-compare"
CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-unused-parameter"
fi
AC_CHECK_FUNCS([lrintf])

View file

@ -758,7 +758,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
split = 1;
LM -= 1;
if (B==1)
fill = fill&1|fill<<1;
fill = (fill&1)|(fill<<1);
B = (B+1)>>1;
}
}
@ -1020,13 +1020,13 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
folding will be done to the side. */
cm |= quant_band(encode, m, i, Y, NULL, N, sbits, spread, B, intensity, tf_change,
next_lowband2, ec, remaining_bits, LM, NULL,
NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1);
NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<((B0>>1)&(stereo-1));
} else {
/* For a stereo split, the high bits of fill are always zero, so no
folding will be done to the side. */
cm = quant_band(encode, m, i, Y, NULL, N, sbits, spread, B, intensity, tf_change,
next_lowband2, ec, remaining_bits, LM, NULL,
NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1);
NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<((B0>>1)&(stereo-1));
rebalance = sbits - (rebalance-*remaining_bits);
if (rebalance > 3<<BITRES && itheta!=16384)
mbits += rebalance - (3<<BITRES);

View file

@ -46,27 +46,27 @@ int log2_frac(opus_uint32 val, int frac)
{
int l;
l=EC_ILOG(val);
if(val&val-1){
if(val&(val-1)){
/*This is (val>>l-16), but guaranteed to round up, even if adding a bias
before the shift would cause overflow (e.g., for 0xFFFFxxxx).*/
if(l>16)val=(val>>l-16)+((val&(1<<l-16)-1)+(1<<l-16)-1>>l-16);
if(l>16)val=(val>>(l-16))+(((val&((1<<(l-16))-1))+(1<<(l-16))-1)>>(l-16));
else val<<=16-l;
l=l-1<<frac;
l=(l-1)<<frac;
/*Note that we always need one iteration, since the rounding up above means
that we might need to adjust the integer part of the logarithm.*/
do{
int b;
b=(int)(val>>16);
l+=b<<frac;
val=val+b>>b;
val=val*val+0x7FFF>>15;
val=(val+b)>>b;
val=(val*val+0x7FFF)>>15;
}
while(frac-->0);
/*If val is not exactly 0x8000, then we have to round up the remainder.*/
return l+(val>0x8000);
}
/*Exact powers of two require no rounding.*/
else return l-1<<frac;
else return (l-1)<<frac;
}
#endif
@ -117,7 +117,7 @@ static inline opus_uint32 imusdiv32even(opus_uint32 _a,opus_uint32 _b,
int one;
celt_assert(_d>0);
celt_assert(_d<=54);
shift=EC_ILOG(_d^_d-1);
shift=EC_ILOG(_d^(_d-1));
inv=INV_TABLE[(_d-1)>>shift];
shift--;
one=1<<shift;
@ -371,7 +371,7 @@ static opus_uint32 ncwrs_urow(unsigned _n,unsigned _k,opus_uint32 *_u){
static inline void cwrsi1(int _k,opus_uint32 _i,int *_y){
int s;
s=-(int)_i;
_y[0]=_k+s^s;
_y[0]=(_k+s)^s;
}
/*Returns the _i'th combination of _k elements (at most 32767) chosen from a
@ -389,7 +389,7 @@ static inline void cwrsi2(int _k,opus_uint32 _i,int *_y){
p=_k?ucwrs2(_k):0;
_i-=p;
yj-=_k;
_y[0]=yj+s^s;
_y[0]=(yj+s)^s;
cwrsi1(_k,_i,_y+1);
}
@ -410,7 +410,7 @@ static void cwrsi3(int _k,opus_uint32 _i,int *_y){
p=_k?ucwrs3(_k):0;
_i-=p;
yj-=_k;
_y[0]=yj+s^s;
_y[0]=(yj+s)^s;
cwrsi2(_k,_i,_y+1);
}
@ -444,7 +444,7 @@ static void cwrsi4(int _k,opus_uint32 _i,int *_y){
}
_i-=p;
yj-=_k;
_y[0]=yj+s^s;
_y[0]=(yj+s)^s;
cwrsi3(_k,_i,_y+1);
}
@ -471,7 +471,7 @@ static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){
while(p>_i)p=_u[--_k];
_i-=p;
yj-=_k;
_y[j]=yj+s^s;
_y[j]=(yj+s)^s;
uprev(_u,_k+2,0);
}
while(++j<_n);

View file

@ -57,7 +57,7 @@
are just as fast, and do not require any special target architecture.
Earlier gcc versions (3.x) compiled both code to the same assembly
instructions, because of the way they represented ((_b)>(_a)) internally.*/
# define EC_MINI(_a,_b) ((_a)+((_b)-(_a)&-((_b)<(_a))))
# define EC_MINI(_a,_b) ((_a)+(((_b)-(_a))&-((_b)<(_a))))
/*Count leading zeros.
This macro should only be used for implementing ec_ilog(), if it is defined.

View file

@ -116,7 +116,7 @@ static void ec_dec_normalize(ec_dec *_this){
/*Take the rest of the bits we need from this new symbol.*/
sym=(sym<<EC_SYM_BITS|_this->rem)>>(EC_SYM_BITS-EC_CODE_EXTRA);
/*And subtract them from val, capped to be less than EC_CODE_TOP.*/
_this->val=(_this->val<<EC_SYM_BITS)+(EC_SYM_MAX&~sym)&EC_CODE_TOP-1;
_this->val=((_this->val<<EC_SYM_BITS)+(EC_SYM_MAX&~sym))&(EC_CODE_TOP-1);
}
}
@ -238,7 +238,7 @@ opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){
}
while(available<=EC_WINDOW_SIZE-EC_SYM_BITS);
}
ret=(opus_uint32)window&((opus_uint32)1<<_bits)-1U;
ret=(opus_uint32)window&(((opus_uint32)1<<_bits)-1U);
window>>=_bits;
available-=_bits;
_this->end_window=window;

View file

@ -89,7 +89,7 @@ static void ec_enc_carry_out(ec_enc *_this,int _c){
if(_this->rem>=0)_this->error|=ec_write_byte(_this,_this->rem+carry);
if(_this->ext>0){
unsigned sym;
sym=EC_SYM_MAX+carry&EC_SYM_MAX;
sym=(EC_SYM_MAX+carry)&EC_SYM_MAX;
do _this->error|=ec_write_byte(_this,sym);
while(--(_this->ext)>0);
}
@ -103,7 +103,7 @@ static void ec_enc_normalize(ec_enc *_this){
while(_this->rng<=EC_CODE_BOT){
ec_enc_carry_out(_this,(int)(_this->val>>EC_CODE_SHIFT));
/*Move the next-to-high-order symbol into the high-order position.*/
_this->val=(_this->val<<EC_SYM_BITS)&EC_CODE_TOP-1;
_this->val=(_this->val<<EC_SYM_BITS)&(EC_CODE_TOP-1);
_this->rng<<=EC_SYM_BITS;
_this->nbits_total+=EC_SYM_BITS;
}
@ -185,7 +185,7 @@ void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft){
ft=(_ft>>ftb)+1;
fl=(unsigned)(_fl>>ftb);
ec_encode(_this,fl,fl+1,ft);
ec_enc_bits(_this,_fl&((opus_uint32)1<<ftb)-1,ftb);
ec_enc_bits(_this,_fl&(((opus_uint32)1<<ftb)-1U),ftb);
}
else ec_encode(_this,_fl,_fl+1,_ft+1);
}
@ -218,15 +218,15 @@ void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){
mask=((1<<_nbits)-1)<<shift;
if(_this->offs>0){
/*The first byte has been finalized.*/
_this->buf[0]=(unsigned char)(_this->buf[0]&~mask|_val<<shift);
_this->buf[0]=(unsigned char)((_this->buf[0]&~mask)|_val<<shift);
}
else if(_this->rem>=0){
/*The first byte is still awaiting carry propagation.*/
_this->rem=_this->rem&~mask|_val<<shift;
_this->rem=(_this->rem&~mask)|_val<<shift;
}
else if(_this->rng<=(EC_CODE_TOP>>shift)){
/*The renormalization loop has never been run.*/
_this->val=_this->val&~((opus_uint32)mask<<EC_CODE_SHIFT)|
_this->val=(_this->val&~((opus_uint32)mask<<EC_CODE_SHIFT))|
(opus_uint32)_val<<(EC_CODE_SHIFT+shift);
}
/*The encoder hasn't even encoded _nbits of data yet.*/
@ -250,15 +250,15 @@ void ec_enc_done(ec_enc *_this){
thus far will be decoded correctly regardless of the bits that follow.*/
l=EC_CODE_BITS-EC_ILOG(_this->rng);
msk=(EC_CODE_TOP-1)>>l;
end=_this->val+msk&~msk;
end=(_this->val+msk)&~msk;
if((end|msk)>=_this->val+_this->rng){
l++;
msk>>=1;
end=_this->val+msk&~msk;
end=(_this->val+msk)&~msk;
}
while(l>0){
ec_enc_carry_out(_this,(int)(end>>EC_CODE_SHIFT));
end=(end<<EC_SYM_BITS)&EC_CODE_TOP-1;
end=(end<<EC_SYM_BITS)&(EC_CODE_TOP-1);
l-=EC_SYM_BITS;
}
/*If we have a buffered byte flush it into the output buffer.*/

View file

@ -189,7 +189,7 @@ void compute_pulse_cache(CELTMode *m, int LM)
/* Offset the number of qtheta bits by log2(N)/2
+ QTHETA_OFFSET compared to their "fair share" of
total/N */
offset = (m->logN[j]+(LM0+k<<BITRES)>>1)-QTHETA_OFFSET;
offset = ((m->logN[j]+((LM0+k)<<BITRES))>>1)-QTHETA_OFFSET;
/* The number of qtheta bits we'll allocate if the remainder
is to be max_bits.
The average measured cost for theta is 0.89701 times qb,
@ -205,7 +205,7 @@ void compute_pulse_cache(CELTMode *m, int LM)
if (C==2)
{
max_bits <<= 1;
offset = (m->logN[j]+(i<<BITRES)>>1)-(N==2?QTHETA_OFFSET_TWOPHASE:QTHETA_OFFSET);
offset = ((m->logN[j]+(i<<BITRES))>>1)-(N==2?QTHETA_OFFSET_TWOPHASE:QTHETA_OFFSET);
ndof = 2*N-1-(N==2);
/* The average measured cost for theta with the step PDF is
0.95164 times qb, approximated here as 487/512. */
@ -220,19 +220,19 @@ void compute_pulse_cache(CELTMode *m, int LM)
ndof = C*N + ((C==2 && N>2) ? 1 : 0);
/* Offset the number of fine bits by log2(N)/2 + FINE_OFFSET
compared to their "fair share" of total/N */
offset = (m->logN[j] + (i<<BITRES)>>1)-FINE_OFFSET;
offset = ((m->logN[j] + (i<<BITRES))>>1)-FINE_OFFSET;
/* N=2 is the only point that doesn't match the curve */
if (N==2)
offset += 1<<BITRES>>2;
/* The number of fine bits we'll allocate if the remainder is
to be max_bits. */
num = max_bits+ndof*offset;
den = ndof-1<<BITRES;
den = (ndof-1)<<BITRES;
qb = IMIN((num+(den>>1))/den, MAX_FINE_BITS);
celt_assert(qb >= 0);
max_bits += C*qb<<BITRES;
}
max_bits = (4*max_bits/(C*(m->eBands[j+1]-m->eBands[j]<<i)))-64;
max_bits = (4*max_bits/(C*((m->eBands[j+1]-m->eBands[j])<<i)))-64;
celt_assert(max_bits >= 0);
celt_assert(max_bits < 256);
*cap++ = (unsigned char)max_bits;

View file

@ -29,10 +29,10 @@ int main(int _argc,char **_argv){
double entropy;
int ft;
int ftb;
int sym;
int sz;
int i;
int ret;
unsigned int sym;
unsigned int seed;
unsigned char *ptr;
ret=0;
@ -78,7 +78,7 @@ int main(int _argc,char **_argv){
for(ft=2;ft<1024;ft++){
for(i=0;i<ft;i++){
sym=ec_dec_uint(&dec,ft);
if(sym!=i){
if(sym!=(unsigned)i){
fprintf(stderr,"Decoded %i instead of %i with ft of %i.\n",sym,i,ft);
ret=-1;
}
@ -87,7 +87,7 @@ int main(int _argc,char **_argv){
for(ftb=0;ftb<16;ftb++){
for(i=0;i<(1<<ftb);i++){
sym=ec_dec_bits(&dec,ftb);
if(sym!=i){
if(sym!=(unsigned)i){
fprintf(stderr,"Decoded %i instead of %i with ftb of %i.\n",sym,i,ftb);
ret=-1;
}
@ -105,8 +105,8 @@ int main(int _argc,char **_argv){
for(i=0;i<409600;i++){
unsigned *data;
unsigned *tell;
unsigned tell_bits;
int j;
int tell_bits;
int zeros;
ft=rand()/((RAND_MAX>>(rand()%11))+1)+10;
sz=rand()/((RAND_MAX>>(rand()%9))+1);
@ -128,7 +128,7 @@ int main(int _argc,char **_argv){
ec_enc_uint(&enc, rand()%2, 2);
tell_bits = ec_tell(&enc);
ec_enc_done(&enc);
if(tell_bits!=ec_tell(&enc)){
if(tell_bits!=(unsigned)ec_tell(&enc)){
fprintf(stderr,"ec_tell() changed after ec_enc_done(): %i instead of %i (Random seed: %u)\n",
ec_tell(&enc),tell_bits,seed);
ret=-1;
@ -203,7 +203,7 @@ int main(int _argc,char **_argv){
tell[j+1]=ec_tell_frac(&enc);
}
ec_enc_done(&enc);
if((ec_tell(&enc)+7)/8<ec_range_bytes(&enc)){
if((ec_tell(&enc)+7U)/8U<ec_range_bytes(&enc)){
fprintf(stderr,"tell() lied, there's %i bytes instead of %d (Random seed: %u)\n",
ec_range_bytes(&enc),(ec_tell(&enc)+7)/8,seed);
ret=-1;

View file

@ -73,7 +73,7 @@ int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, int l
{
rp->toc = data[0];
rp->framesize = opus_packet_get_samples_per_frame(data, 48000);
} else if (rp->toc&0xFC != data[0]&0xFC)
} else if ((rp->toc&0xFC) != (data[0]&0xFC))
{
/*fprintf(stderr, "toc mismatch: 0x%x vs 0x%x\n", rp->toc, data[0]);*/
return OPUS_CORRUPTED_DATA;

View file

@ -15,12 +15,6 @@
/* Get rid of the CELT VS compile warnings */
#if 1
#pragma warning(disable : 4018)/* signed/unsigned mismatch */
#pragma warning(disable : 4244)/* conversion from 'double' to 'opus_val16', possible loss of data */
#pragma warning(disable : 4267)/* conversion from 'size_t' to 'int', possible loss of data */
#pragma warning(disable : 4305)/* truncation from 'double' to 'const float' */
#pragma warning(disable : 4311)/* pointer truncation from 'char *' to 'long' */
#pragma warning(disable : 4554)/* check operator precedence for possible error; use parentheses to clarify precedence */
#pragma warning(disable : 4996)/* This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. */
#endif