Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove compiler warnings (incl from third party headers) #2072

Merged

Conversation

wezrule
Copy link
Contributor

@wezrule wezrule commented Jun 10, 2019

We deprecated all the functions inside interface.c/.h in v18 (or maybe v17), so I've now removed them to remove the warnings associated.

Some warnings are from third party headers so it's not possible to fix them directly ourselves, instead we can suppress the particular warnings we want. Rather than do this around all header files (becomes tedious), I've created some wrapper files which do this and those can be included.

I've now set the -Werror compiler flag so any warnings will turn into errors (on gcc/clang at least). This can be contentious as different compiler versions can generate different warnings other than what travis reports so could be annoying. But it will prevent any further warnings being introduced at least.

The following warnings are removed from MSVC builds:
c:\users\wesley\documents\nano-node\crypto\blake2\blake2.h(142): warning C4804: '/': unsafe use of type 'bool' in operation

c:\boost\include\boost-1_69\boost\asio\detail\impl\win_iocp_socket_service_base.ipp(253): warning C4191: 'type cast': unsafe conversion from 'FARPROC' to 'cancel_io_ex_t'
c:\boost\include\boost-1_69\boost\asio\detail\impl\win_iocp_socket_service_base.ipp(609): warning C4242: '=': conversion from 'int' to 'ADDRESS_FAMILY', possible loss of data
c:\users\wesley\documents\nano-node\nano\node\daemonconfig.cpp(103): warning C4018: '<': signed/unsigned mismatch
c:\users\wesley\documents\nano-node\nano\node\bootstrap.cpp(1288): warning C4244: 'argument': conversion from 'uint64_t' to 'nano::pull_info::count_t', possible loss of data
c:\users\wesley\documents\nano-node\nano\lib\numbers.cpp(823): warning C4146: unary minus operator applied to unsigned type, result still unsigned
c:\users\wesley\documents\nano-node\nano\lib\blockbuilders.cpp(189): warning C4242: 'argument': conversion from 'int' to 'const unsigned char', possible loss of data
ipc.cpp
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\memory(1801): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<nano::ipc::ipc_server&,boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>,nano::ipc::ipc_config_tcp_socket&,size_t&>(nano::ipc::ipc_server &,boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> &&,nano::ipc::ipc_config_tcp_socket &,size_t &)' being compiled
        with
        [
            _Ty=`anonymous-namespace'::socket_transport<boost::asio::ip::tcp::acceptor,boost::asio::ip::tcp::socket,boost::asio::ip::tcp::endpoint>
        ]
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<nano::ipc::ipc_server&,boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>,nano::ipc::ipc_config_tcp_socket&,size_t&>(nano::ipc::ipc_server &,boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> &&,nano::ipc::ipc_config_tcp_socket &,size_t &)' being compiled
        with
        [
            _Ty=`anonymous-namespace'::socket_transport<boost::asio::ip::tcp::acceptor,boost::asio::ip::tcp::socket,boost::asio::ip::tcp::endpoint>
        ]
c:\users\wesley\documents\nano-node\nano\node\ipc.cpp(316): note: see reference to function template instantiation 'std::shared_ptr<`anonymous-namespace'::socket_transport<boost::asio::ip::tcp::acceptor,boost::asio::ip::tcp::socket,boost::asio::ip::tcp::endpoint>> std::make_shared<`anonymous-namespace'::socket_transport<boost::asio::ip::tcp::acceptor,boost::asio::ip::tcp::socket,boost::asio::ip::tcp::endpoint>,nano::ipc::ipc_server&,boost::asio::ip::tcp::endpoint,nano::ipc::ipc_config_tcp_socket&,size_t&>(nano::ipc::ipc_server &,boost::asio::ip::tcp::endpoint &&,nano::ipc::ipc_config_tcp_socket &,size_t &)' being compiled
c:\boost\include\boost-1_69\boost\beast\core\string.hpp(103): note: see reference to class template instantiation 'boost::basic_string_view<char,std::char_traits<char>>' being compiled
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\chrono(861): note: see reference to class template instantiation 'std::chrono::duration<__int64,std::ratio<1,1>>' being compiled
signatures.cpp
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\memory(1801): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<nano::signature_check_set&,size_t&>(nano::signature_check_set &,size_t &)' being compiled
        with
        [
            _Ty=nano::signature_checker::Task
        ]
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\memory(1866): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<nano::signature_check_set&,size_t&>(nano::signature_check_set &,size_t &)' being compiled
        with
        [
            _Ty=nano::signature_checker::Task
        ]
c:\users\wesley\documents\nano-node\nano\node\signatures.cpp(105): note: see reference to function template instantiation 'std::shared_ptr<nano::signature_checker::Task> std::make_shared<nano::signature_checker::Task,nano::signature_check_set&,size_t&>(nano::signature_check_set &,size_t &)' being compiled

c:\users\wesley\documents\nano-node\nano\core_test\block_store.cpp(1485): warning C4242: 'argument': conversion from 'int' to 'uint16_t', possible loss of data
c:\users\wesley\documents\nano-node\nano\qt_system\entry.cpp(19): warning C4242: 'argument': conversion from 'int' to 'uint16_t', possible loss of data
c:\users\wesley\documents\nano-node\nano\node\portmapping.cpp(85): warning C4242: '=': conversion from 'int' to 'uint16_t', possible loss of data
c:\users\wesley\documents\nano-node\nano\core_test\peer_container.cpp(93): warning C4242: 'argument': conversion from 'int' to 'unsigned short', possible loss of data

LINK : C:\Users\Wesley\Documents\nano-node\build\Debug\nano_wallet.com not found or not built by the last incremental link; performing full link
c:\boost\include\boost-1_69\boost\process\detail\windows\job_workaround.hpp(219): warning C4191: 'reinterpret_cast': unsafe conversion from 'boost::winapi::FARPROC_' to 'boost::process::detail::windows::workaround::query_information_job_object_p'
c:\boost\include\boost-1_69\boost\process\detail\windows\job_workaround.hpp(219): warning C4191: 'reinterpret_cast': unsafe conversion from 'boost::winapi::FARPROC_' to 'boost::process::detail::windows::workaround::query_information_job_object_p'
        Calling this function through the result pointer may cause your program to fail
c:\boost\include\boost-1_69\boost\process\detail\windows\wait_group.hpp(55): warning C4242: '-=': conversion from '_Rep' to 'int', possible loss of data
        with
        [
            _Rep=__int64
        ]
        Calling this function through the result pointer may cause your program to fail
c:\boost\include\boost-1_69\boost\process\detail\windows\wait_group.hpp(55): warning C4242: '-=': nversion from '_Rep' to 'int', possible loss of data
        with
        [
            _Rep=__int64
        ]
   Creating library C:/Users/Wesley/Documents/nano-node/build/Debug/nano_wallet.lib and object C:/Users/Wesley/Documents/nano-node/build/Debug/nano_wallet.exp

c:\qt_new\5.9\msvc2017_64\include\qttest\qtestkeyboard.h(77): warning C4242: 'argument': conversion from 'int' to 'ushort', possible loss of data

Issues on MAC:
floodyberry/ed25519-donna#29 We have modified the ed25519 library source before as it hasn't been updated in a number of years. Used the same solution as found here: floodyberry/ed25519-donna#29

@wezrule wezrule self-assigned this Jun 10, 2019
@zhyatt zhyatt added this to the V20.0 milestone Jun 10, 2019
Copy link
Contributor

@cryptocode cryptocode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, compiles locally with NANO_SECURE_RPC etc.

Removal of the deprecated C interface probably warrants a prominent note in v19 release notes.

@wezrule wezrule closed this Jul 1, 2019
@wezrule wezrule deleted the remove_third_party_header_warnings branch July 1, 2019 19:39
@wezrule wezrule restored the remove_third_party_header_warnings branch July 3, 2019 17:09
@wezrule wezrule reopened this Jul 3, 2019
@wezrule wezrule merged commit f8158fc into nanocurrency:master Jul 12, 2019
@wezrule wezrule deleted the remove_third_party_header_warnings branch July 12, 2019 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants