cmangos / issues

This repository is used as a centralized point for all issues regarding CMaNGOS.
179 stars 47 forks source link

Zero-length gnu_printf format string [-Wformat-zero-length] #1357

Closed dvdvideo1234 closed 7 years ago

dvdvideo1234 commented 7 years ago

Current behavior: outstring_log(""); [100%] Building CXX object src/scriptdev2/CMakeFiles/mangosscript.dir/ScriptMgr.cpp.o mangos/src/scriptdev2/ScriptMgr.cpp:38:25 mangos/src/scriptdev2/ScriptMgr.cpp:93:21 mangos/src/scriptdev2/ScriptMgr.cpp:101:21 mangos/src/scriptdev2/ScriptMgr.cpp:117:20 mangos/src/scriptdev2/ScriptMgr.cpp:125:21 [100%] Building CXX object src/scriptdev2/CMakeFiles/mangosscript.dir/system/system.cpp.o mangos/src/scriptdev2/system/system.cpp:48:21 mangos/src/scriptdev2/system/system.cpp:117:25 mangos/src/scriptdev2/system/system.cpp:124:25

Expected behavior: http://stackoverflow.com/questions/9926674/why-does-gcc-wall-give-warning-about-zero-length-format-string

Steps to reproduce:

  1. cmake ../mangos -DCMAKE_INSTALL_PREFIX=$PWD/mangos/run -DPCH=1 -DDEBUG=0

Client version: N/A

Commit hash: 623a244bf60920d1a4534eb1553f44d657f4b251

Database version: https://github.com/cmangos/wotlk-db ( 03b53c3b958fe68525cffa1dd0ec79dff683f366 )

Operating system: Linux mangos-VB 4.4.0-72-lowlatency #_93-Ubuntu SMP PREEMPT Fri Mar 31 15:25:21 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

dvdvideo1234 commented 7 years ago

This seems to be a better option when calling it outstring_log("%s",""); because this warning will allso be generated when a normal printf() is called like this:

printf("");

Also I took my time to track some of these here: https://github.com/cmangos/mangos-wotlk/search?utf8=%E2%9C%93&q=outstring_log&type=

It seems that the coder wanted to insert a new line, but I wander why in such a way because he can use

outstring_log("\n"); // Place the new line here to fix the warning for empty format

But whatever option chosen is up to you guys I guess

cyberium commented 7 years ago

This should be fixed