From f6af7c442df3e569492ced730e70d1bc72356c5e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 15 May 2021 21:22:50 +0300 Subject: get rid of SafeInt --- src/symbol.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/symbol.cpp') diff --git a/src/symbol.cpp b/src/symbol.cpp index ad7bd3f..9f5e11d 100644 --- a/src/symbol.cpp +++ b/src/symbol.cpp @@ -5,7 +5,6 @@ #include -#include #include #include @@ -13,6 +12,7 @@ #include #include +#include #include #include #include @@ -21,21 +21,17 @@ namespace pdb { namespace { std::size_t calc_size(const SymbolInfo::Impl& impl) { - try { - static constexpr auto char_size = sizeof(std::remove_extent::type); - return SafeInt{impl.SizeOfStruct} + (impl.NameLen - 1) * char_size; - } catch (const SafeIntException&) { - throw std::runtime_error{"invalid SYMBOL_INFO size"}; - } + static constexpr auto char_size = sizeof(std::remove_extent::type); + return impl.SizeOfStruct + (impl.NameLen - 1) * char_size; } unsigned long cast_line_number(DWORD impl) { unsigned long dest = 0; - if (!SafeCast(impl, dest)) + if (impl > std::numeric_limits::max()) throw std::runtime_error{"invalid line number"}; - return dest; + return static_cast(dest); } } // namespace -- cgit v1.3