dyne / frei0r

A large collection of free and portable video plugins
https://frei0r.dyne.org/
GNU General Public License v2.0
427 stars 89 forks source link

sprintf src and dest the same not allowed #22

Closed dcb314 closed 5 years ago

dcb314 commented 6 years ago

filter/measure/pr0file.c:327:5: warning: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Wrestrict]

Source code is

sprintf(str,"%s %s",str,"Mk1= -----");

man sprintf says:

   Some programs imprudently rely on code such as the following

       sprintf(buf, "%s some further text", buf);

   to append text to buf.  However, the standards explicitly note that the
   results are undefined if source and destination  buffers  overlap  when
   calling  sprintf(), snprintf(), vsprintf(), and vsnprintf().  Depending
   on the version of gcc(1) used, and the compiler options employed, calls
   such as the above will not produce the expected results.

Many more examples in the same file. Suggest compile with -Wrestrict.

jaromil commented 6 years ago

Well spotted. I agree with the adoption of this flag. Thanks!

jaromil commented 5 years ago

For now I've limited the usage of -Wrestrict on clang builds since most distros ship gcc compilers that are too old to support it. OSX builds use clang and one is ran at every commit, logs visible here https://travis-ci.org/dyne/frei0r

ddennedy commented 5 years ago

That's great re additional option on clang and that Travis can run macOS, but the macOS build is showing usage of gcc instead and complaining about an unknown warning option in the build log. :-/