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

Fix Linux warnings #570

Merged
merged 1 commit into from
Jun 2, 2022
Merged

Conversation

Thomas1664
Copy link
Contributor

@Thomas1664 Thomas1664 commented Jun 2, 2022

Fixes these warnings when compiling with GCC 11:

[build] /vcpkg/commands.civerifyversions.cpp: In function ‘vcpkg::ExpectedS<std::__cxx11::basic_string<char> > vcpkg::Commands::CIVerifyVersions::verify_version_in_db(const vcpkg::VcpkgPaths&, std::map<std::__cxx11::basic_string<char>, vcpkg::Version, std::less<void> >, vcpkg::StringView, const vcpkg::Path&, const vcpkg::Path&, const string&, bool)’:
[build] /vcpkg/commands.civerifyversions.cpp:93:41: warning: loop variable ‘control_file’ of type ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
[build]    93 |                 for (const std::string& control_file : {"CONTROL", "vcpkg.json"})
[build]       |                                         ^~~~~~~~~~~~
[build] /vcpkg/commands.civerifyversions.cpp:93:41: note: use non-reference type ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} to make the copy explicit or ‘const char* const&’ to prevent copying
[build] /vcpkg/base/system.process.cpp: In function ‘vcpkg::Path vcpkg::get_exe_path_of_current_process()’:
[build] /vcpkg/base/system.process.cpp:223:32: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized]
[build]   223 |         auto written = readlink("/proc/self/exe", buf.data(), buf.size());
[build]       |                        ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from /usr/include/c++/11/tuple:39,
[build]                  from /usr/include/c++/11/functional:54,
[build]                  from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
[build]                  from /usr/include/c++/11/algorithm:74,
[build]                  from /vcpkg-tool/include/pch.h:25,
[build]                  from <command-line>:
[build] /usr/include/c++/11/array:176:7: note: by argument 1 of type ‘const std::array<char, 4096>*’ to ‘constexpr std::array<_Tp, _Nm>::size_type std::array<_Tp, _Nm>::size() const [with _Tp = char; long unsigned int _Nm = 4096]’ declared here
[build]   176 |       size() const noexcept { return _Nm; }
[build]       |       ^~~~
[build] /vcpkg/base/system.process.cpp:222:36: note: ‘buf’ declared here
[build]   222 |         std::array<char, 1024 * 4> buf;
[build]       |                                    ^~~

@Thomas1664 Thomas1664 marked this pull request as ready for review June 2, 2022 15:46
@ras0219-msft ras0219-msft merged commit 939c067 into microsoft:main Jun 2, 2022
@ras0219-msft
Copy link
Contributor

Thanks!

@Thomas1664 Thomas1664 deleted the fix-linux-warnings branch June 2, 2022 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants