Skip to content

Commit

Permalink
follow GCC suggestions to add parenthesis
Browse files Browse the repository at this point in the history
"if (a=b)"    -> "if ((a=b))"
"a && b || c" -> "(a && b) || c"
"a >> b - c"  -> "a >> (b - c)"
"for (,a=b,)" -> "for (,(a=b),)"
  • Loading branch information
barak committed Feb 23, 2018
1 parent 4f916ee commit fe95e73
Show file tree
Hide file tree
Showing 30 changed files with 315 additions and 313 deletions.
4 changes: 2 additions & 2 deletions lib/dfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ integer s_rdfe(cilist *a)
int n;
if(!f__init) f_init();
f__reading=1;
if(n=c_dfe(a))return(n);
if((n=c_dfe(a)))return(n);
if(f__curunit->uwrt && f__nowreading(f__curunit))
err(a->cierr,errno,"read start");
f__getn = y_getc;
Expand All @@ -110,7 +110,7 @@ integer s_wdfe(cilist *a)
int n;
if(!f__init) f_init();
f__reading=0;
if(n=c_dfe(a)) return(n);
if((n=c_dfe(a))) return(n);
if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
err(a->cierr,errno,"startwrt");
f__putn = x_putc;
Expand Down
4 changes: 2 additions & 2 deletions lib/due.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ integer s_rdue(cilist *a)
{
int n;
f__reading=1;
if(n=c_due(a)) return(n);
if((n=c_due(a))) return(n);
if(f__curunit->uwrt && f__nowreading(f__curunit))
err(a->cierr,errno,"read start");
return(0);
Expand All @@ -37,7 +37,7 @@ integer s_wdue(cilist *a)
{
int n;
f__reading=0;
if(n=c_due(a)) return(n);
if((n=c_due(a))) return(n);
if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
err(a->cierr,errno,"write start");
return(0);
Expand Down
2 changes: 1 addition & 1 deletion lib/endfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ integer f_end(alist *a)
if(b->ufd==NULL) {
char nbuf[10];
sprintf(nbuf,"fort.%ld",(long)a->aunit);
if (tf = fopen(nbuf, f__w_mode[0]))
if ((tf = fopen(nbuf, f__w_mode[0])))
fclose(tf);
return(0);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/iio.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int iw_rev(void)

integer s_rsfi(icilist *a)
{ int n;
if(n=c_si(a)) return(n);
if((n=c_si(a))) return(n);
f__reading=1;
f__doed=rd_ed;
f__doned=rd_ned;
Expand Down Expand Up @@ -99,7 +99,7 @@ z_wnew(void)

integer s_wsfi(icilist *a)
{ int n;
if(n=c_si(a)) return(n);
if((n=c_si(a))) return(n);
f__reading=0;
f__doed=w_ed;
f__doned=w_ned;
Expand Down
4 changes: 2 additions & 2 deletions lib/inquire.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ integer f_inqu(inlist *a)
}
}
if(a->inex!=NULL)
if(byfile && x != -1 || !byfile && p!=NULL)
if((byfile && x != -1) || (!byfile && p!=NULL))
*a->inex=1;
else *a->inex=0;
if(a->inopen!=NULL)
if(byfile) *a->inopen=(p!=NULL);
else *a->inopen=(p!=NULL && p->ufd!=NULL);
if(a->innum!=NULL) *a->innum= p-f__units;
if(a->innamed!=NULL)
if(byfile || p!=NULL && p->ufnm!=NULL)
if(byfile || (p!=NULL && p->ufnm!=NULL))
*a->innamed=1;
else *a->innamed=0;
if(a->inname!=NULL)
Expand Down
8 changes: 4 additions & 4 deletions lib/lbitbits.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ integer lbit_cshift(integer a, integer b, integer len)
full_len:
if (b >= 0) {
b %= F2C_LONG_BITS;
return (integer)(x << b | x >> F2C_LONG_BITS -b );
return (integer)(x << b | x >> (F2C_LONG_BITS - b) );
}
b = -b;
b %= F2C_LONG_BITS;
return (integer)(x << F2C_LONG_BITS - b | x >> b);
return (integer)(x << (F2C_LONG_BITS - b) | x >> b);
}
y = z = (unsigned long)-1;
y <<= len;
Expand All @@ -43,9 +43,9 @@ integer lbit_cshift(integer a, integer b, integer len)
x &= z;
if (b >= 0) {
b %= len;
return (integer)(y | z & (x << b | x >> len - b));
return (integer)(y | (z & (x << b | x >> (len - b))));
}
b = -b;
b %= len;
return (integer)(y | z & (x >> b | x << len - b));
return (integer)(y | (z & (x >> b | x << (len - b))));
}
10 changes: 5 additions & 5 deletions lib/lread.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ flag f__lquit;
int f__lcount,f__ltype,nml_read;
char *f__lchar;
double f__lx,f__ly;
#define ERR(x) if(n=(x)) return(n)
#define ERR(x) if((n=(x))) return(n)
#define GETC(x) (x=(*l_getc)())
#define Ungetc(x,y) (*l_ungetc)(x,y)

Expand Down Expand Up @@ -284,7 +284,7 @@ static int l_C(void)
Ungetc(ch,f__cf);
nml_save = nml_read;
nml_read = 0;
if (ch = l_R(1,0))
if ((ch = l_R(1,0)))
return ch;
if (!f__ltype)
errfl(f__elist->cierr,112,"no real part");
Expand All @@ -296,7 +296,7 @@ static int l_C(void)
}
while(iswhit(GETC(ch)));
(void) Ungetc(ch,f__cf);
if (ch = l_R(1,0))
if ((ch = l_R(1,0)))
return ch;
if (!f__ltype)
errfl(f__elist->cierr,112,"no imaginary part");
Expand All @@ -318,7 +318,7 @@ static int (*nmL_ungetc_save)(int, FILE*);
static int nmL_getc(void)
{
int rv;
if (rv = *nmL_next++)
if ((rv = *nmL_next++))
return rv;
l_getc = nmL_getc_save;
l_ungetc = nmL_ungetc_save;
Expand Down Expand Up @@ -727,7 +727,7 @@ integer s_rsle(cilist *a)
f__reading=1;
f__external=1;
f__formatted=1;
if(n=c_le(a)) return(n);
if((n=c_le(a))) return(n);
f__lioproc = l_read;
f__lquit = 0;
f__lcount = 0;
Expand Down
6 changes: 3 additions & 3 deletions lib/lwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static int l_g(char *buf, double n)
switch(*b) {
#ifndef WANT_LEAD_0
case '0':
while(b[0] = b[1])
while((b[0] = b[1]))
b++;
break;
#endif
Expand All @@ -128,7 +128,7 @@ static int l_g(char *buf, double n)
while(*++b);
goto f__ret;
case 'E':
for(c1 = '.', c = 'E'; *b = c1;
for(c1 = '.', c = 'E'; (*b = c1);
c1 = c, c = *++b);
goto f__ret;
}
Expand All @@ -146,7 +146,7 @@ static void l_put(register char *s)
#endif
register int c;

while(c = *s++)
while((c = *s++))
(*pn)(c);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ integer f_open(olist *a)
#ifndef HAVE_TMPFILE
replace:
#endif
if (tf = fopen(buf,f__w_mode[0]))
if ((tf = fopen(buf,f__w_mode[0])))
fclose(tf);
}

Expand All @@ -192,9 +192,9 @@ integer f_open(olist *a)
if ((s = a->oacc) && b->url)
ufmt = 0;
if(!(tf = fopen(buf, f__w_mode[ufmt|2]))) {
if (tf = fopen(buf, f__r_mode[ufmt]))
if ((tf = fopen(buf, f__r_mode[ufmt])))
b->urw = 1;
else if (tf = fopen(buf, f__w_mode[ufmt])) {
else if ((tf = fopen(buf, f__w_mode[ufmt]))) {
b->uwrt = 1;
b->urw = 2;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/qbitbits.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ longint qbit_cshift(longint a, integer b, integer len)
full_len:
if (b >= 0) {
b %= F2C_LONG_LONG_BITS;
return (longint)(x << b | x >> F2C_LONG_LONG_BITS - b );
return (longint)(x << b | x >> (F2C_LONG_LONG_BITS - b) );
}
b = -b;
b %= F2C_LONG_LONG_BITS;
return (longint)(x << F2C_LONG_LONG_BITS - b | x >> b);
return (longint)(x << (F2C_LONG_LONG_BITS - b) | x >> b);
}
y = z = (unsigned long)-1;
y <<= len;
Expand All @@ -44,11 +44,11 @@ longint qbit_cshift(longint a, integer b, integer len)
x &= z;
if (b >= 0) {
b %= len;
return (longint)(y | z & (x << b | x >> len - b));
return (longint)(y | (z & (x << b | x >> (len - b))));
}
b = -b;
b %= len;
return (longint)(y | z & (x >> b | x << len - b));
return (longint)(y | (z & (x >> b | x << (len - b))));
}

#endif /* INTEGER_STAR_8 */
8 changes: 4 additions & 4 deletions lib/rdfmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ static int rd_Z(Uint *n, int w, ftnlen len)

if (!hex['0']) {
sc = "0123456789";
while(ch = *sc++)
while((ch = *sc++))
hex[ch] = ch - '0' + 1;
sc = "ABCDEF";
while(ch = *sc++)
while((ch = *sc++))
hex[ch] = hex[ch + 'a' - 'A'] = ch - 'A' + 11;
}
s = s0 = (char *)x;
Expand Down Expand Up @@ -51,7 +51,7 @@ static int rd_Z(Uint *n, int w, ftnlen len)
return errno = 115;
w = (int)len;
w1 = s - s0;
w2 = w1+1 >> 1;
w2 = (w1+1) >> 1;
t = (char *)n;
if (*(char *)&one) {
/* little endian */
Expand All @@ -73,7 +73,7 @@ static int rd_Z(Uint *n, int w, ftnlen len)
t += i;
}
do {
*t = hex[*s0 & 0xff]-1 << 4 | hex[s0[1] & 0xff]-1;
*t = (hex[*s0 & 0xff]-1) << 4 | (hex[s0[1] & 0xff]-1);
t += i;
s0 += 2;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rsfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ integer s_rsfe(cilist *a) /* start */
f__sequential=1;
f__formatted=1;
f__external=1;
if(n=c_sfe(a)) return n;
if((n=c_sfe(a))) return n;
f__elist=a;
f__cursor=f__recpos=0;
f__scale=0;
Expand Down
Loading

0 comments on commit fe95e73

Please sign in to comment.