* Enable -Wall, -Wextra, -Weverything and -Werror on Unix
This enables *all* native code warnings on gcc/clang.
To avoid breaking the build, this commit also explicitly disables all
warnings that currently cause the build to fail.
* Remove -Wno-zero-as-null-pointer-constant
Fix all the code that was causing the warnings.
* Fix newline-eof warnings
* Fix 'deprecated' warnings
Use `noexcept` instead of `throw()`.
Use explicit copy-constructors where the compiler complains.
* Fix non-virtual-destructor warnings
Add a virtual destructor
* Fix extra-semi warnings
* Fix some sign-compare warnings
But leave sign-compare warnings disabled: some shared API essentially
forces some code do this comparison.
* Fix ignored-qualifiers warnings
It doesn't matter when functions that return value types use const or
not: value types are returned by copying and the caller can't mutate the
the version that the callee had. So remove those const flags.
* Fix undef warnings
Use defined() for preprocessor flags that can be undefined.
* Fix range-loop-analysis warnings
* Enable shorten-64-to-32 warnings
Previous commits have fixed all code that produced this warning.
* Fix used-but-marked-unused warnings
* Fix missing-braces warnings
* Disable vla-extension warnings
* Fix missing-variable-declarations warnings
Fix the warnings by explicitly declaring the global variables that are
only meant to be used locally in the file as static.
* Enable sign-conversion warnings
The code seems to have been fixed by previous commits.
* Fix old-style-cast warnings
* Fix unused-variable warnings
* Fix sign-compare warnings
* Fix documentation-unknown-command warnings
Clang thinks these comment blocks enclosed by /** and **/ are
doxygen-style comments. And doxygen doesn't know of a \Program tag. Use
\\ to "escape" a single slash and make doxygen/clang happy.
* Disable -Weverything
And remove various -Wno- flags that are not required anymore.
* Update global locations that comments refer to
The original locations are basically wrong.
* Fix bad cast in mockcoreclr.cpp
We should set the left hand value (a host_handle_t) to a right hand
value of the same type (a host_handle_t). Casting `0xdeadbeef` to a
host_handle_t* - only to assign it to a host_handle_t - does't make too
much sense.
Commit migrated from https://github.com/dotnet/core-setup/commit/
0dd08fe1414c690d3243739f3be4cd35f84f7dde
uint8_t *buffer = new uint8_t[size + 1];
read(buffer, size, stream);
buffer[size] = 0; // null-terminator
- pal::clr_palstring((const char*)buffer, &str);
+ pal::clr_palstring(reinterpret_cast<const char*>(buffer), &str);
}
static bool has_dirs_in_path(const pal::string_t& path)
void bundle_runner_t::extract_file(file_entry_t *entry)
{
FILE* file = create_extraction_file(entry->relative_path());
- const size_t buffer_size = 8 * 1024; // Copy the file in 8KB chunks
+ const int64_t buffer_size = 8 * 1024; // Copy the file in 8KB chunks
uint8_t buffer[buffer_size];
int64_t file_size = entry->size();
bool file_entry_t::is_valid()
{
return m_data.offset > 0 && m_data.size > 0 &&
- (file_type_t)m_data.type < file_type_t::__last;
+ static_cast<file_type_t>(m_data.type) < file_type_t::__last;
}
file_entry_t* file_entry_t::read(FILE* stream)
}
return to_rel_path(new_base, str);
-}
\ No newline at end of file
+}
#include <cassert>
#include <functional>
-const std::array<const pal::char_t*, deps_entry_t::asset_types::count> deps_entry_t::s_known_asset_types = {
+const std::array<const pal::char_t*, deps_entry_t::asset_types::count> deps_entry_t::s_known_asset_types = {{
_X("runtime"), _X("resources"), _X("native")
-};
+}};
const deps_entry_t& deps_json_t::try_ni(const deps_entry_t& entry) const
{
pal::string_t library_hash_path = get_optional_path(properties, _X("hashPath"));
pal::string_t runtime_store_manifest_list = get_optional_path(properties, _X("runtimeStoreManifestName"));
- for (int i = 0; i < deps_entry_t::s_known_asset_types.size(); ++i)
+ for (size_t i = 0; i < deps_entry_t::s_known_asset_types.size(); ++i)
{
bool rid_specific = false;
for (const auto& asset : get_assets_fn(library.first, i, &rid_specific))
entry.library_path = library_path;
entry.library_hash_path = library_hash_path;
entry.runtime_store_manifest_list = runtime_store_manifest_list;
- entry.asset_type = (deps_entry_t::asset_types) i;
+ entry.asset_type = static_cast<deps_entry_t::asset_types>(i);
entry.is_serviceable = serviceable;
entry.is_rid_specific = rid_specific;
entry.deps_file = deps_file;
for (const auto& file : files)
{
const auto& type = file.second.at(_X("assetType")).as_string();
- for (int i = 0; i < deps_entry_t::s_known_asset_types.size(); ++i)
+ for (size_t i = 0; i < deps_entry_t::s_known_asset_types.size(); ++i)
{
if (pal::strcasecmp(type.c_str(), deps_entry_t::s_known_asset_types[i]) == 0)
{
for (const auto& package : json.at(_X("targets")).at(target_name).as_object())
{
const auto& asset_types = package.second.as_object();
- for (int i = 0; i < deps_entry_t::s_known_asset_types.size(); ++i)
+ for (size_t i = 0; i < deps_entry_t::s_known_asset_types.size(); ++i)
{
auto iter = asset_types.find(deps_entry_t::s_known_asset_types[i]);
if (iter != asset_types.end())
return fx_version_number;
}
- const bool get_apply_patches() const
+ bool get_apply_patches() const
{
return apply_patches;
}
apply_patches = value;
}
- const roll_forward_option get_roll_forward() const
+ roll_forward_option get_roll_forward() const
{
return roll_forward;
}
roll_forward = value;
}
- const bool get_prefer_release() const
+ bool get_prefer_release() const
{
return prefer_release;
}
const host_interface_t& get_host_init_data();
};
-#endif // __COREHOST_INIT_H__
\ No newline at end of file
+#endif // __COREHOST_INIT_H__
}
// Obtain entrypoint symbol
- *main_fn = (T)pal::get_symbol(*h_host, main_entry_symbol);
+ *main_fn = reinterpret_cast<T>(pal::get_symbol(*h_host, main_entry_symbol));
if (*main_fn == nullptr)
return StatusCode::CoreHostEntryPointFailure;
{
result = parse_args(host_info, 1, argc, argv, false, mode, &new_argoff, app_candidate, opts); // arg offset 1 for dotnet
- if (result == AppArgNotRunnable)
+ if (static_cast<StatusCode>(result) == AppArgNotRunnable)
{
return handle_cli(host_info, argc, argv);
}
const pal::string_t & oldest_requested_version,
const pal::string_t & dotnet_dir)
{
-#if DEBUG
+#if defined(DEBUG)
assert(!fx_ref.get_fx_name().empty());
assert(!fx_ref.get_fx_version().empty());
fx_ver_t _debug_ver;
assert(fx_ver_t::parse(fx_ref.get_fx_version(), &_debug_ver, false));
assert(_debug_ver == fx_ref.get_fx_version_number());
-#endif // DEBUG
+#endif // defined(DEBUG)
trace::verbose(_X("--- Resolving FX directory, name '%s' version '%s'"),
fx_ref.get_fx_name().c_str(), fx_ref.get_fx_version().c_str());
fx_name_to_fx_reference_map_t m_oldest_fx_references;
};
-#endif // __FX_RESOLVER_H__
\ No newline at end of file
+#endif // __FX_RESOLVER_H__
return 0;
}
- if (cli_sdk.size() < buffer_size)
+ unsigned long non_negative_buffer_size = static_cast<unsigned long>(buffer_size);
+ if (cli_sdk.size() < non_negative_buffer_size)
{
- size_t length = cli_sdk.copy(buffer, buffer_size - 1);
+ size_t length = cli_sdk.copy(buffer, non_negative_buffer_size - 1);
assert(length == cli_sdk.size());
- assert(length < buffer_size);
+ assert(length < non_negative_buffer_size);
buffer[length] = 0;
}
else
}
// Obtain entrypoint symbols
- g_hostpolicy_contract.load = (corehost_load_fn)pal::get_symbol(g_hostpolicy, "corehost_load");
- g_hostpolicy_contract.unload = (corehost_unload_fn)pal::get_symbol(g_hostpolicy, "corehost_unload");
+ g_hostpolicy_contract.load = reinterpret_cast<corehost_load_fn>(pal::get_symbol(g_hostpolicy, "corehost_load"));
+ g_hostpolicy_contract.unload = reinterpret_cast<corehost_unload_fn>(pal::get_symbol(g_hostpolicy, "corehost_unload"));
if ((g_hostpolicy_contract.load == nullptr) || (g_hostpolicy_contract.unload == nullptr))
return StatusCode::CoreHostEntryPointFailure;
- g_hostpolicy_contract.set_error_writer = (corehost_set_error_writer_fn)pal::get_symbol(g_hostpolicy, "corehost_set_error_writer");
+ g_hostpolicy_contract.set_error_writer = reinterpret_cast<corehost_set_error_writer_fn>(pal::get_symbol(g_hostpolicy, "corehost_set_error_writer"));
// It's possible to not have corehost_set_error_writer, since this was only introduced in 3.0
// so 2.0 hostpolicy would not have the export. In this case we will not propagate the error writer
}
}
return false;
-}
\ No newline at end of file
+}
bool fxr_resolver::try_get_path(const pal::string_t& root_path, pal::string_t* out_dotnet_root, pal::string_t* out_fxr_path)
{
pal::string_t fxr_dir;
-#if FEATURE_APPHOST || FEATURE_LIBHOST
+#if defined(FEATURE_APPHOST) || defined(FEATURE_LIBHOST)
// If a hostfxr exists in root_path, then assume self-contained.
if (root_path.length() > 0 && library_exists_in_dir(root_path, LIBFXR_NAME, out_fxr_path))
{
bool fxr_resolver::try_get_existing_fxr(pal::dll_t *out_fxr, pal::string_t *out_fxr_path)
{
- pal::dll_t fxr;
if (!pal::get_loaded_library(LIBFXR_NAME, "hostfxr_main", out_fxr, out_fxr_path))
return false;
// Path to hostfxr is: <dotnet_root>/host/fxr/<version>/<hostfxr_file>
pal::string_t fxr_root = get_directory(get_directory(fxr_path));
return get_directory(get_directory(fxr_root));
-}
\ No newline at end of file
+}
// Leak fxr
- auto get_delegate_from_hostfxr = (hostfxr_get_delegate_fn)pal::get_symbol(fxr, "hostfxr_get_runtime_delegate");
+ auto get_delegate_from_hostfxr = reinterpret_cast<hostfxr_get_delegate_fn>(pal::get_symbol(fxr, "hostfxr_get_runtime_delegate"));
if (get_delegate_from_hostfxr == nullptr)
return StatusCode::CoreHostEntryPointFailure;
return status;
}
- return get_delegate_from_hostfxr(host_path.c_str(), dotnet_root.c_str(), app_path_to_use->c_str(), type, (void**)delegate);
+ return get_delegate_from_hostfxr(host_path.c_str(), dotnet_root.c_str(), app_path_to_use->c_str(), type, reinterpret_cast<void**>(delegate));
}
#endif //_COREHOST_CLI_FXR_RESOLVER_H_
return 0;
}
-const bool host_startup_info_t::is_valid(host_mode_t mode) const
+bool host_startup_info_t::is_valid(host_mode_t mode) const
{
if (mode == host_mode_t::libhost)
{
int argc,
const pal::char_t* argv[]);
- const bool is_valid(host_mode_t mode) const;
+ bool is_valid(host_mode_t mode) const;
const pal::string_t get_app_name() const;
* o %DOTNET_SHARED_STORE% -- multiple delimited paths
* o dotnet.exe relative shared store\<arch>\<tfm>
* o Global location
- * Windows: C:\Program Files (x86) or
- * Unix: directory of dotnet on the path.\<arch>\<tfm>
+ * Windows: global default location (Program Files) or globally registered location (registry) + store\<arch>\<tfm>
+ * Linux/macOS: none (no global locations are considered)
*/
void setup_shared_store_paths(const pal::string_t& tfm, host_mode_t host_mode,const pal::string_t& own_dir, arguments_t* args)
{
return false;
}
- coreclr_initialize = (coreclr_initialize_fn)pal::get_symbol(g_coreclr, "coreclr_initialize");
- coreclr_shutdown = (coreclr_shutdown_fn)pal::get_symbol(g_coreclr, "coreclr_shutdown_2");
- coreclr_execute_assembly = (coreclr_execute_assembly_fn)pal::get_symbol(g_coreclr, "coreclr_execute_assembly");
- coreclr_create_delegate = (coreclr_create_delegate_fn)pal::get_symbol(g_coreclr, "coreclr_create_delegate");
+ coreclr_initialize = reinterpret_cast<coreclr_initialize_fn>(pal::get_symbol(g_coreclr, "coreclr_initialize"));
+ coreclr_shutdown = reinterpret_cast<coreclr_shutdown_fn>(pal::get_symbol(g_coreclr, "coreclr_shutdown_2"));
+ coreclr_execute_assembly = reinterpret_cast<coreclr_execute_assembly_fn>(pal::get_symbol(g_coreclr, "coreclr_execute_assembly"));
+ coreclr_create_delegate = reinterpret_cast<coreclr_create_delegate_fn>(pal::get_symbol(g_coreclr, "coreclr_create_delegate"));
assert(coreclr_initialize != nullptr
&& coreclr_shutdown != nullptr
{
for (auto &kv : _properties)
callback(kv.first, kv.second);
-}
\ No newline at end of file
+}
m_probes.push_back(probe_config_t::published_deps_dir());
// The framework locations, starting with highest level framework.
- for (int i = 1; i < m_fx_definitions.size(); ++i)
+ for (size_t i = 1; i < m_fx_definitions.size(); ++i)
{
if (pal::directory_exists(m_fx_definitions[i]->get_dir()))
{
}
// Probe FX deps entries after app assemblies are added.
- for (int i = 1; i < m_fx_definitions.size(); ++i)
+ for (size_t i = 1; i < m_fx_definitions.size(); ++i)
{
const auto& deps_entries = m_is_framework_dependent ? m_fx_definitions[i]->get_deps().get_entries(deps_entry_t::asset_types::runtime) : empty;
for (const auto& entry : deps_entries)
}
else
{
- for (int i = 1; i < m_fx_definitions.size(); ++i)
+ for (size_t i = 1; i < m_fx_definitions.size(); ++i)
{
fx_ver_t most_compatible_deps_folder_version;
fx_ver_t framework_found_version;
for (const auto& additional_deps : m_additional_deps)
{
const auto additional_deps_entries = additional_deps->get_entries(asset_type);
- for (const auto entry : additional_deps_entries)
+ for (const auto& entry : additional_deps_entries)
{
if (!add_package_cache_entry(entry, m_app_dir, 0))
{
}
// Add fx package locations to fx_dir
- for (int i = 1; i < m_fx_definitions.size(); ++i)
+ for (size_t i = 1; i < m_fx_definitions.size(); ++i)
{
const auto& fx_entries = m_fx_definitions[i]->get_deps().get_entries(asset_type);
bool valid(pal::string_t* errors)
{
- for (int i = 0; i < m_fx_definitions.size(); ++i)
+ for (size_t i = 0; i < m_fx_definitions.size(); ++i)
{
// Verify the deps file exists. The app deps file does not need to exist
if (i != 0)
if (trace::is_enabled())
{
pal::string_t arg_str;
- for (int i = 0; i < argv_local.size(); i++)
+ for (size_t i = 0; i < argv_local.size(); i++)
{
pal::string_t cur;
pal::clr_palstring(argv_local[i], &cur);
trace::info(_X("Execute managed assembly exit code: 0x%X"), exit_code);
// Shut down the CoreCLR
- hr = g_coreclr->shutdown((int*)&exit_code);
+ hr = g_coreclr->shutdown(reinterpret_cast<int*>(&exit_code));
if (!SUCCEEDED(hr))
{
trace::warning(_X("Failed to shut down CoreCLR, HRESULT: 0x%X"), hr);
bool set_app_paths = false;
// Runtime options config properties.
- for (int i = 0; i < hostpolicy_init.cfg_keys.size(); ++i)
+ for (size_t i = 0; i < hostpolicy_init.cfg_keys.size(); ++i)
{
// Provide opt-in compatible behavior by using the switch to set APP_PATHS
const pal::char_t *key = hostpolicy_init.cfg_keys[i].c_str();
}
return StatusCode::Success;
-}
\ No newline at end of file
+}
init->patch_roll_forward = input->patch_roll_forward;
init->prerelease_roll_forward = input->prerelease_roll_forward;
- init->host_mode = (host_mode_t)input->host_mode;
+ init->host_mode = static_cast<host_mode_t>(input->host_mode);
}
else
{
fx_requested_ver = input->fx_ver;
}
- int fx_count = 0;
if (input->version_lo >= offsetof(host_interface_t, fx_names) + sizeof(input->fx_names))
{
- int fx_count = input->fx_names.len;
+ size_t fx_count = input->fx_names.len;
assert(fx_count > 0);
assert(fx_count == input->fx_dirs.len);
assert(fx_count == input->fx_requested_versions.len);
make_palstr_arr(input->fx_found_versions.len, input->fx_found_versions.arr, &fx_found_versions);
init->fx_definitions.reserve(fx_count);
- for (int i = 0; i < fx_count; ++i)
+ for (size_t i = 0; i < fx_count; ++i)
{
auto fx = new fx_definition_t(fx_names[i], fx_dirs[i], fx_requested_versions[i], fx_found_versions[i]);
init->fx_definitions.push_back(std::unique_ptr<fx_definition_t>(fx));
/// </summary>
inline std::system_error __cdecl create_system_error(unsigned long errorCode)
{
- std::error_code code((int)errorCode, platform_category());
+ std::error_code code(static_cast<int>(errorCode), platform_category());
return std::system_error(code, code.message());
}
/// </summary>
inline std::error_code __cdecl create_error_code(unsigned long errorCode)
{
- return std::error_code((int)errorCode, platform_category());
+ return std::error_code(static_cast<int>(errorCode), platform_category());
}
/// <summary>
#if defined SAFEINT_REMOVE_NOTHROW
#define SAFEINT_NOTHROW
#else
-#define SAFEINT_NOTHROW throw()
+#define SAFEINT_NOTHROW noexcept
#endif
namespace msl
*this = SafeInt< T, E >( (U)u );
}
+ SafeInt(const SafeInt< T, E >& u) SAFEINT_NOTHROW
+ {
+ *this = u;
+ }
+
template < typename U >
SafeInt( const U& i ) SAFEINT_CPP_THROW
{
#ifdef _Inout_updates_bytes_
#undef _Inout_updates_bytes_
#endif
-#define _Inout_updates_bytes_(x)
\ No newline at end of file
+#define _Inout_updates_bytes_(x)
/// Is the current value a null value?
/// </summary>
/// <returns><c>true</c> if the value is a null value, <c>false</c> otherwise</returns>
- bool is_null() const { return type() == Null; };
+ bool is_null() const { return type() == Null; }
/// <summary>
/// Is the current value a number value?
protected:
_Value() {}
+ _Value(const _Value& other) {}
+
virtual void format(std::basic_string<char>& stream) const
{
stream.append("null");
using namespace utility;
using namespace utility::conversions;
-std::array<signed char,128> _hexval = {{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+static std::array<signed char,128> _hexval = {{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
m_currentParsingDepth(0)
{ }
+ virtual ~JSON_Parser() { }
+
struct Location
{
size_t m_line;
auto ch = PeekCharacter();
while (ch >= '0' && ch <= '9')
{
- unsigned int next_digit = (unsigned int)(ch - '0');
+ unsigned int next_digit = static_cast<unsigned int>(ch - '0');
if (value > (ULLONG_MAX / 10) || (value == ULLONG_MAX/10 && next_digit > ULLONG_MAX%10))
return false;
return _wcstod_l(str, nullptr, utility::details::scoped_c_thread_locale::c_locale());
}
#else
- static int __attribute__((__unused__)) print_llu(char* ptr, size_t n, unsigned long long val64)
+ static int print_llu(char* ptr, size_t n, unsigned long long val64)
{
return snprintf(ptr, n, "%llu", val64);
}
- static int __attribute__((__unused__)) print_llu(char* ptr, size_t n, unsigned long val64)
+ static int print_llu(char* ptr, size_t n, unsigned long val64)
{
return snprintf(ptr, n, "%lu", val64);
}
- static double __attribute__((__unused__)) anystod(const char* str)
+ static double anystod(const char* str)
{
return strtod(str, nullptr);
}
- static double __attribute__((__unused__)) anystod(const wchar_t* str)
+ static double anystod(const wchar_t* str)
{
return wcstod(str, nullptr);
}
::std::vector<CharType> buf(::std::numeric_limits<uint64_t>::digits10 + 5);
int count = print_llu(buf.data(), buf.size(), val64);
_ASSERTE(count >= 0);
- _ASSERTE((size_t)count < buf.size());
+ _ASSERTE(static_cast<size_t>(count) < buf.size());
// Resize to cut off the null terminator
buf.resize(count);
// Not expected number character?
break;
}
- };
+ }
buf.push_back('\0');
token.double_val = anystod(buf.data());
case '}':
case ']':
{
- if((signed int)(--m_currentParsingDepth) < 0)
+ if(static_cast<signed int>(--m_currentParsingDepth) < 0)
{
SetErrorCode(result, json_error::mismatched_brances);
break;
{
#if !defined(ANDROID) && !defined(__ANDROID__)
-std::once_flag g_c_localeFlag;
-std::unique_ptr<scoped_c_thread_locale::xplat_locale, void(*)(scoped_c_thread_locale::xplat_locale *)> g_c_locale(nullptr, [](scoped_c_thread_locale::xplat_locale *){});
+static std::once_flag g_c_localeFlag;
+static std::unique_ptr<scoped_c_thread_locale::xplat_locale, void(*)(scoped_c_thread_locale::xplat_locale *)> g_c_locale(nullptr, [](scoped_c_thread_locale::xplat_locale *){});
scoped_c_thread_locale::xplat_locale scoped_c_thread_locale::c_locale()
{
std::call_once(g_c_localeFlag, [&]()
fxr_path.copy(buffer, len);
buffer[len] = '\0';
return StatusCode::Success;
-}
\ No newline at end of file
+}
size_t * buffer_size,
const char_t * assembly_path);
-#endif // __NETHOST_H__
\ No newline at end of file
+#endif // __NETHOST_H__
return false;
}
- m_specified_settings = (specified_setting)(m_specified_settings | setting);
+ m_specified_settings = static_cast<specified_setting>(m_specified_settings | setting);
return true;
}
if (hostHandle != nullptr)
{
- *hostHandle = (coreclr_t::host_handle_t*)(size_t) 0xdeadbeef;
+ *hostHandle = reinterpret_cast<coreclr_t::host_handle_t>(0xdeadbeef);
}
return StatusCode::Success;
const int MaxDelegates = 16;
-MockCoreClrDelegate DelegateState[MaxDelegates];
+static MockCoreClrDelegate DelegateState[MaxDelegates];
#define DelegateFunction(index)\
void Delegate_ ## index() { DelegateState[index].Echo(); }
DelegateState[delegateIndex] = delegateState;
- *delegate = (void*) delegates[delegateIndex];
+ *delegate = reinterpret_cast<void*>(delegates[delegateIndex]);
return StatusCode::Success;
}
return;
}
- for (int i = 0; i < arr.len; i++)
+ for (size_t i = 0; i < arr.len; i++)
{
std::cout << prefix << tostr(arr.arr[i]).data() << std::endl;
}
}
else
{
- for (int i = 0; i < init->config_keys.len; i++)
+ for (size_t i = 0; i < init->config_keys.len; i++)
{
std::cout << "mock config: " << tostr(init->config_keys.arr[i]).data() << "=" << tostr(init->config_values.arr[i]).data() << std::endl;
}
}
else
{
- for (int i = 0; i < init->fx_names.len; i++)
+ for (size_t i = 0; i < init->fx_names.len; i++)
{
std::cout << "mock frameworks: "
<< tostr(init->fx_names.arr[i]).data() << " "
bool synchronous(const pal::string_t &comhost_path, const pal::string_t &clsid_str, int count);
bool concurrent(const pal::string_t &comhost_path, const pal::string_t &clsid_str, int count);
-}
\ No newline at end of file
+}
pal::string_t fxr_path;
size_t len = fxr_path.size();
int res = get_hostfxr_path(nullptr, &len, assembly_path);
- if (res == StatusCode::HostApiBufferTooSmall)
+ if (static_cast<StatusCode>(res) == StatusCode::HostApiBufferTooSmall)
{
fxr_path.resize(len);
res = get_hostfxr_path(&fxr_path[0], &len, assembly_path);
}
- if (res == StatusCode::Success)
+ if (static_cast<StatusCode>(res) == StatusCode::Success)
{
std::cout << "get_hostfxr_path succeeded" << std::endl;
std::cout << "hostfxr_path: " << tostr(pal::to_lower(fxr_path)).data() << std::endl;
std::cerr << "Invalid arguments" << std::endl;
return -1;
}
-}
\ No newline at end of file
+}
static int compare(const version_t&a, const version_t& b);
};
-#endif // __VERSION_H__
\ No newline at end of file
+#endif // __VERSION_H__
pal::string_t pal::get_timestamp()
{
- std::time_t t = std::time(0);
+ std::time_t t = std::time(nullptr);
const std::size_t elems = 100;
char_t buf[elems];
std::strftime(buf, elems, _X("%c %Z"), std::gmtime(&t));
pal::string_t trim_quotes(pal::string_t stringToCleanup)
{
pal::char_t quote_array[2] = {'\"', '\''};
- for(int index = 0; index < sizeof(quote_array)/sizeof(quote_array[0]); index++)
+ for(size_t index = 0; index < sizeof(quote_array)/sizeof(quote_array[0]); index++)
{
size_t pos = stringToCleanup.find(quote_array[index]);
while(pos != std::string::npos)
//
// Needless to say, this will need to be updated if OSX RID were to become 11.* ever.
size_t size = sizeof(str);
- int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0);
+ int ret = sysctlbyname("kern.osrelease", str, &size, nullptr, 0);
if (ret == 0)
{
std::string release(str, size);
va_list dup_args;
va_copy(dup_args, args);
- int count = pal::str_vprintf(NULL, 0, format, args) + 1;
+ int count = pal::str_vprintf(nullptr, 0, format, args) + 1;
std::vector<pal::char_t> buffer(count);
pal::str_vprintf(&buffer[0], count, format, dup_args);
{
// No need for locking since g_error_writer is thread local.
return g_error_writer;
-}
\ No newline at end of file
+}
return ret + DIR_SEPARATOR;
}
- int pos = (int) path_sep;
+ int pos = static_cast<int>(path_sep);
while (pos >= 0 && ret[pos] == DIR_SEPARATOR)
{
pos--;
}
- return ret.substr(0, (size_t)pos + 1) + DIR_SEPARATOR;
+ return ret.substr(0, static_cast<size_t>(pos) + 1) + DIR_SEPARATOR;
}
void remove_trailing_dir_seperator(pal::string_t* dir)
void replace_char(pal::string_t* path, pal::char_t match, pal::char_t repl)
{
- int pos = 0;
+ size_t pos = 0;
while ((pos = path->find(match, pos)) != pal::string_t::npos)
{
(*path)[pos] = repl;
pal::string_t get_replaced_char(const pal::string_t& path, pal::char_t match, pal::char_t repl)
{
- int pos = path.find(match);
+ size_t pos = path.find(match);
if (pos == pal::string_t::npos)
{
return path;
const pal::char_t* get_arch()
{
-#if _TARGET_AMD64_
+#if defined(_TARGET_AMD64_)
return _X("x64");
-#elif _TARGET_X86_
+#elif defined(_TARGET_X86_)
return _X("x86");
-#elif _TARGET_ARM_
+#elif defined(_TARGET_ARM_)
return _X("arm");
-#elif _TARGET_ARM64_
+#elif defined(_TARGET_ARM64_)
return _X("arm64");
#else
#error "Unknown target"
}
unsigned char bytes[3];
- stream->read((char*) bytes, 3);
+ stream->read(reinterpret_cast<char*>(bytes), 3);
if ((stream->gcount() < 3) ||
(bytes[1] != 0xBB) ||
(bytes[2] != 0xBF))
{
return false;
}
- *num = (unsigned)std::stoul(str);
+ *num = std::stoul(str);
return true;
}
dev_cfg->assign(dev_json_path);
trace::verbose(_X("Runtime config is cfg=%s dev=%s"), json_path.c_str(), dev_json_path.c_str());
-}
\ No newline at end of file
+}
#include "trace.h"
#include "utils.h"
-#if FEATURE_APPHOST
+#if defined(FEATURE_APPHOST)
#include "cli/apphost/bundle/bundle_runner.h"
#define CURHOST_TYPE _X("apphost")
trace::info(_X("The managed DLL bound to this executable is: '%s'"), app_dll->c_str());
return true;
}
-#elif !FEATURE_LIBHOST
+#elif !defined(FEATURE_LIBHOST)
#define CURHOST_TYPE _X("dotnet")
#define CUREXE_PKG_VER HOST_PKG_VER
#define CURHOST_EXE
pal::string_t app_root;
bool requires_v2_hostfxr_interface = false;
-#if FEATURE_APPHOST
+#if defined(FEATURE_APPHOST)
pal::string_t embedded_app_name;
if (!is_exe_enabled_for_execution(&embedded_app_name))
{
// Obtain the entrypoints.
int rc;
- hostfxr_main_startupinfo_fn main_fn_v2 = (hostfxr_main_startupinfo_fn)pal::get_symbol(fxr, "hostfxr_main_startupinfo");
+ hostfxr_main_startupinfo_fn main_fn_v2 = reinterpret_cast<hostfxr_main_startupinfo_fn>(pal::get_symbol(fxr, "hostfxr_main_startupinfo"));
if (main_fn_v2 != nullptr)
{
const pal::char_t* host_path_cstr = host_path.c_str();
trace::info(_X("Dotnet path: [%s]"), dotnet_root.c_str());
trace::info(_X("App path: [%s]"), app_path.c_str());
- hostfxr_set_error_writer_fn set_error_writer_fn = (hostfxr_set_error_writer_fn)pal::get_symbol(fxr, "hostfxr_set_error_writer");
+ hostfxr_set_error_writer_fn set_error_writer_fn = reinterpret_cast<hostfxr_set_error_writer_fn>(pal::get_symbol(fxr, "hostfxr_set_error_writer"));
{
propagate_error_writer_t propagate_error_writer_to_hostfxr(set_error_writer_fn);
// For compat, use the v1 interface. This requires additional file I\O to re-parse parameters and
// for apphost, does not support DOTNET_ROOT or dll with different name for exe.
- hostfxr_main_fn main_fn_v1 = (hostfxr_main_fn)pal::get_symbol(fxr, "hostfxr_main");
+ hostfxr_main_fn main_fn_v1 = reinterpret_cast<hostfxr_main_fn>(pal::get_symbol(fxr, "hostfxr_main"));
if (main_fn_v1 != nullptr)
{
rc = main_fn_v1(argc, argv);
return exit_code;
}
-#endif
\ No newline at end of file
+#endif
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
else()
+ add_compile_options(-Wall)
+ add_compile_options(-Wextra)
+ if(CMAKE_C_COMPILER_ID STREQUAL Clang)
+ # Uncomment to enable additional, but likely irrelvant, warnings. For
+ # example, this will warn about using c++11 features even when
+ # compiling with -std=c++11.
+ # add_compile_options(-Weverything)
+ endif()
+ add_compile_options(-Werror)
+ add_compile_options(-Wno-missing-field-initializers)
+ add_compile_options(-Wno-unused-function)
add_compile_options(-Wno-unused-local-typedef)
- add_compile_options(-Werror=reorder)
+ add_compile_options(-Wno-unused-macros)
+ add_compile_options(-Wno-unused-parameter)
endif()
# Older CMake doesn't support CMAKE_CXX_STANDARD and GCC/Clang need a switch to enable C++ 11