Skip to content

Commit

Permalink
Silence pedantic GCC6 code formatting warnings
Browse files Browse the repository at this point in the history
Apparently it's "misleading" to put two self-contained if statements
on a single line.  Who knew?
  • Loading branch information
dcommander committed Jul 14, 2016
1 parent 7723d7f commit db04435
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
21 changes: 14 additions & 7 deletions bmp.c
Expand Up @@ -108,10 +108,14 @@ static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup,
m=(m-k)/(1.0-k);
y=(y-k)/(1.0-k);
}
if(c>1.0) c=1.0; if(c<0.) c=0.;
if(m>1.0) m=1.0; if(m<0.) m=0.;
if(y>1.0) y=1.0; if(y<0.) y=0.;
if(k>1.0) k=1.0; if(k<0.) k=0.;
if(c>1.0) c=1.0;
if(c<0.) c=0.;
if(m>1.0) m=1.0;
if(m<0.) m=0.;
if(y>1.0) y=1.0;
if(y<0.) y=0.;
if(k>1.0) k=1.0;
if(k<0.) k=0.;
*dstcolptr++=(unsigned char)(255.0-c*255.0+0.5);
*dstcolptr++=(unsigned char)(255.0-m*255.0+0.5);
*dstcolptr++=(unsigned char)(255.0-y*255.0+0.5);
Expand All @@ -133,9 +137,12 @@ static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup,
double r=c*k/255.;
double g=m*k/255.;
double b=y*k/255.;
if(r>255.0) r=255.0; if(r<0.) r=0.;
if(g>255.0) g=255.0; if(g<0.) g=0.;
if(b>255.0) b=255.0; if(b<0.) b=0.;
if(r>255.0) r=255.0;
if(r<0.) r=0.;
if(g>255.0) g=255.0;
if(g<0.) g=0.;
if(b>255.0) b=255.0;
if(b<0.) b=0.;
dstcolptr[tjRedOffset[dstpf]]=(unsigned char)(r+0.5);
dstcolptr[tjGreenOffset[dstpf]]=(unsigned char)(g+0.5);
dstcolptr[tjBlueOffset[dstpf]]=(unsigned char)(b+0.5);
Expand Down
18 changes: 12 additions & 6 deletions tjbench.c
Expand Up @@ -248,7 +248,8 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
int y=(int)((double)srcbuf[rindex]*0.299
+ (double)srcbuf[gindex]*0.587
+ (double)srcbuf[bindex]*0.114 + 0.5);
if(y>255) y=255; if(y<0) y=0;
if(y>255) y=255;
if(y<0) y=0;
dstbuf[rindex]=abs(dstbuf[rindex]-y);
dstbuf[gindex]=abs(dstbuf[gindex]-y);
dstbuf[bindex]=abs(dstbuf[bindex]-y);
Expand Down Expand Up @@ -300,7 +301,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,

for(tilew=dotile? 8:w, tileh=dotile? 8:h; ; tilew*=2, tileh*=2)
{
if(tilew>w) tilew=w; if(tileh>h) tileh=h;
if(tilew>w) tilew=w;
if(tileh>h) tileh=h;
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;

if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
Expand Down Expand Up @@ -447,7 +449,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,

for(i=0; i<ntilesw*ntilesh; i++)
{
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
if(jpegbuf[i]) tjFree(jpegbuf[i]);
jpegbuf[i]=NULL;
}
free(jpegbuf); jpegbuf=NULL;
free(jpegsize); jpegsize=NULL;
Expand All @@ -465,7 +468,8 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
{
for(i=0; i<ntilesw*ntilesh; i++)
{
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
if(jpegbuf[i]) tjFree(jpegbuf[i]);
jpegbuf[i]=NULL;
}
free(jpegbuf); jpegbuf=NULL;
}
Expand Down Expand Up @@ -532,7 +536,8 @@ int decompTest(char *filename)

for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2)
{
if(tilew>w) tilew=w; if(tileh>h) tileh=h;
if(tilew>w) tilew=w;
if(tileh>h) tileh=h;
ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh;

if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)
Expand Down Expand Up @@ -692,7 +697,8 @@ int decompTest(char *filename)
{
for(i=0; i<ntilesw*ntilesh; i++)
{
if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL;
if(jpegbuf[i]) tjFree(jpegbuf[i]);
jpegbuf[i]=NULL;
}
free(jpegbuf); jpegbuf=NULL;
}
Expand Down
6 changes: 4 additions & 2 deletions turbojpeg.c
Expand Up @@ -570,7 +570,8 @@ static tjhandle _tjInitCompress(tjinstance *this)
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
if(this) free(this); return NULL;
if(this) free(this);
return NULL;
}

jpeg_create_compress(&this->cinfo);
Expand Down Expand Up @@ -1231,7 +1232,8 @@ static tjhandle _tjInitDecompress(tjinstance *this)
if(setjmp(this->jerr.setjmp_buffer))
{
/* If we get here, the JPEG code has signaled an error. */
if(this) free(this); return NULL;
if(this) free(this);
return NULL;
}

jpeg_create_decompress(&this->dinfo);
Expand Down

0 comments on commit db04435

Please sign in to comment.