vtil-project / VTIL-Core

Virtual-machine Translation Intermediate Language
BSD 3-Clause "New" or "Revised" License
1.31k stars 165 forks source link

Fix compiler warnings on GNUC #22

Closed L33T closed 4 years ago

L33T commented 4 years ago

Proposed fixes to warnings generated by the GNU compiler. (gcc-10, g++-10) Feel free to challenge any of the patches.

-Wno-attributes

In file included from VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/utility:3,
                 from VTIL-x64/external/VTIL-Core/VTIL-SymEx/expressions/expression.hpp:30,
                 from VTIL-x64/external/VTIL-Core/VTIL-SymEx/expressions/expression.cpp:28:
VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../util/copy_on_write.hpp:233:43: warning: ‘always_inline’ function might not be inlinable [-Wattributes]
  233 |  __forceinline static shared_reference<T> make_local_reference( T* variable_pointer )
      |                                           ^~~~~~~~~~~~~~~~~~~~

-Wno-multichar

VTIL-x64/external/VTIL-Core/VTIL-Architecture/routine/serialization.cpp:36:40: warning: multi-character character constant [-Wmultichar]
36 |  static constexpr magic_t vtil_magic = 'LITV' | ( 0xDEAD0000ull << 32 );
|                                        ^~~~~~

-Wno-format-security

In file included from VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/../util/hashable.hpp:34,
from VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/../util/reducable.hpp:30,
from VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/bitwise.hpp:33,
from VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/math:2,
from VTIL-x64/external/VTIL-Core/VTIL-SymEx/directives/directive.hpp:29,
from VTIL-x64/external/VTIL-Core/VTIL-SymEx/directives/transformer.hpp:30,
from VTIL-x64/external/VTIL-Core/VTIL-SymEx/directives/transformer.cpp:28:
VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/../util/../io/formatting.hpp: In instantiation of ‘std::string vtil::format::str(const char*, params&& ...) [with params = {}; std::string = std::__cxx11::basic_string<char>]’:
VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/../io/logger.hpp:282:36:   required from ‘void vtil::logger::error(const char*, params&& ...) [with params = {}]’
VTIL-x64/external/VTIL-Core/VTIL-SymEx/directives/transformer.cpp:238:52:   required from here
VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/../util/../io/formatting.hpp:222:26: warning: format not a string literal and no format arguments [-Wformat-security]
222 |   buffer.resize( snprintf( nullptr, 0, fmt, fix_parameter( ps )... ) );
|                  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/../util/../io/formatting.hpp:223:11: warning: format not a string literal and no format arguments [-Wformat-security]
223 |   snprintf( buffer.data(), buffer.size() + 1, fmt, fix_parameter<params>( std::forward<params>( ps ) )... );
|   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pragma GCC diagnostic ignored "-Wformat-security"

(Due to this being included in personal projects by default, I've decided to add it as a pragma disable instead of a CXX option which doesn't get included while compiling said personal projects)

VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/../io/logger.hpp:233:13:   required from ‘int vtil::logger::log(const char*, params&& ...) [with vtil::logger::console_color color = vtil::logger::CON_YLW; params = {}]’
VTIL-x64/external/VTIL-Core/VTIL-SymEx/directives/transformer.cpp:244:48:   required from here
VTIL-x64/external/VTIL-Core/VTIL-Common/includes/vtil/../../math/../io/logger.hpp:228:28: warning: format not a string literal and no format arguments [-Wformat-security]
  228 |    return out_cnt + fprintf( VTIL_LOGGER_DST, fmt, format::fix_parameter<params>( std::forward<params>( ps ) )... );
      |                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
can1357 commented 4 years ago

I'll also fix some narrowing issues with a narrow_cast implementation soon on top of this PR.