Skip to content

Commit

Permalink
Fix some unreachable code and possible loss of data warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanuhrig committed Oct 12, 2022
1 parent 2f08d5f commit 190b030
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/odbc/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
# endif
#endif
//------------------------------------------------------------------------------
#ifdef _WIN32
#if defined(__clang__) || defined(__GNUC__)
# define ODBC_UNREACHABLE __builtin_unreachable()
#elif defined(_MSC_VER)
# define ODBC_UNREACHABLE __assume(false)
#else
# define ODBC_UNREACHABLE ((void)0)
#endif
//------------------------------------------------------------------------------
#ifdef _MSC_VER
# pragma warning(disable: 4251 4275)
#endif
//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/odbc/StringConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ u16string StringConverter::utf8ToUtf16(const char* begin, const char* end)
}
else
{
str.push_back(cp.second);
str.push_back(static_cast<char16_t>(cp.second));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/odbc/internal/charset/Utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline bool isValidSequence(int len, const char* c)
return ((c[0] & 0xF8) == 0xF0) && ((c[1] & 0xC0) == 0x80)
&& ((c[2] & 0xC0) == 0x80) && ((c[3] & 0xC0) == 0x80);
}
assert(false);
ODBC_UNREACHABLE;
}
//------------------------------------------------------------------------------
/**
Expand Down Expand Up @@ -121,7 +121,7 @@ inline char32_t decode(int len, const char* c)
case 4:
return decode4(c);
}
assert(false);
ODBC_UNREACHABLE;
}
//------------------------------------------------------------------------------
} // namespace utf8
Expand Down

0 comments on commit 190b030

Please sign in to comment.