tjko / jpegoptim

jpegoptim - utility to optimize/compress JPEG files
http://www.iki.fi/tjko/projects.html
GNU General Public License v3.0
1.57k stars 116 forks source link

Get rid of some clang warnings. #4

Closed Niduroki closed 11 years ago

Niduroki commented 11 years ago

Namely:

if statement has empty body [-Wempty-body]
  if (rcsid); /* so compiler won't complain about "unused" rcsid string */
the value of the size argument in 'strncat' is too large, might lead to a buffer overflow [-Wstrncat-size]
         strncat(tmpdir,"/",sizeof(tmpdir)-strlen(tmpdir));

Just followed clangs suggestions on how to fix these warnings:

jpegoptim.c:333:13: note: put the semicolon on a separate line to silence this warning
jpegoptim.c:485:22: note: change the argument to be the free space in the destination buffer minus the terminating null byte
         strncat(tmpdir,"/",sizeof(tmpdir)-strlen(tmpdir));
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            sizeof(tmpdir) - strlen(tmpdir) - 1

gcc doesn't care about these changes/still compiles without warnings. Compiles in gcc 4.7.2 and clang 3.2 Did a small test (on optimizing many pictures) and works as it should.