Resolve code analysis warnings
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
5fc35751a3
commit
91c9a71a5d
@ -16,6 +16,7 @@ namespace UnitTests
|
||||
{
|
||||
stdex::utf32_t tmp[0x100];
|
||||
stdex::strncpy(tmp, u"This is a 🐔Test🐮.");
|
||||
tmp[_countof(tmp) - 1] = 0;
|
||||
Assert::IsTrue(stdex::strcmp(U"This is a 🐔Test🐮.", tmp) == 0);
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,9 @@ namespace stdex
|
||||
_In_ int flags = stdex::parser::match_default)
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
stdex_assert(text || start + 17 >= end);
|
||||
if (start + 17 < end &&
|
||||
text[start + 0] == 'u' &&
|
||||
stdex_assert(text || start >= end);
|
||||
if (start < end && start + 17 < end &&
|
||||
text[start] == 'u' &&
|
||||
text[start + 1] == 'n' &&
|
||||
text[start + 2] == 't' &&
|
||||
text[start + 3] == 'r' &&
|
||||
@ -73,9 +73,9 @@ namespace stdex
|
||||
_In_ int flags = stdex::parser::match_default)
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
stdex_assert(text || start + 1 >= end);
|
||||
if (start + 1 < end &&
|
||||
text[start + 0] == '\r' &&
|
||||
stdex_assert(text || start >= end);
|
||||
if (start < end && start + 1 < end &&
|
||||
text[start] == '\r' &&
|
||||
text[start + 1] == '\n')
|
||||
{
|
||||
this->interval.end = (this->interval.start = start) + 2;
|
||||
|
@ -4961,7 +4961,7 @@ namespace stdex
|
||||
uint32_t nominator;
|
||||
|
||||
this->interval.end = start;
|
||||
if (this->interval.end + 1 >= end ||
|
||||
if (this->interval.end >= end || this->interval.end + 1 >= end ||
|
||||
(case_insensitive ? ctype.toupper(text[this->interval.end]) : text[this->interval.end]) != 'R' ||
|
||||
(case_insensitive ? ctype.toupper(text[this->interval.end + 1]) : text[this->interval.end + 1]) != 'F')
|
||||
goto error; // incomplete or wrong reference ID
|
||||
@ -5199,7 +5199,7 @@ namespace stdex
|
||||
const bool case_insensitive = flags & match_case_insensitive ? true : false;
|
||||
|
||||
this->interval.end = start;
|
||||
if (this->interval.end + 1 >= end ||
|
||||
if (this->interval.end >= end || this->interval.end + 1 >= end ||
|
||||
(case_insensitive ? ctype.toupper(text[this->interval.end]) : text[this->interval.end]) != 'S' ||
|
||||
(case_insensitive ? ctype.toupper(text[this->interval.end + 1]) : text[this->interval.end + 1]) != 'I')
|
||||
goto error; // incomplete or wrong reference ID
|
||||
@ -5894,7 +5894,7 @@ namespace stdex
|
||||
_In_ int flags = match_default)
|
||||
{
|
||||
stdex_assert(text || start >= end);
|
||||
if (start + 2 < end &&
|
||||
if (start < end && start + 2 < end &&
|
||||
text[start] == '*' &&
|
||||
text[start + 1] == '/' &&
|
||||
text[start + 2] == '*')
|
||||
@ -6090,7 +6090,7 @@ namespace stdex
|
||||
for (;;) {
|
||||
if (this->interval.end < end && text[this->interval.end]) {
|
||||
if ('0' <= text[this->interval.end] && text[this->interval.end] <= '9') {
|
||||
size_t _value = static_cast<size_t>(value) * 10 + static_cast<size_t>(text[this->interval.end] - '0');
|
||||
size_t _value = static_cast<size_t>(value) * 10 + text[this->interval.end] - '0';
|
||||
if (_value > UINT16_MAX) {
|
||||
value = 0;
|
||||
this->interval.invalidate();
|
||||
@ -6472,7 +6472,7 @@ namespace stdex
|
||||
for (;;) {
|
||||
if (this->interval.end < end && text[this->interval.end]) {
|
||||
if ('0' <= text[this->interval.end] && text[this->interval.end] <= '9') {
|
||||
celi_del = celi_del * 10 + static_cast<size_t>(text[this->interval.end] - '0');
|
||||
celi_del = celi_del * 10 + text[this->interval.end] - '0';
|
||||
this->interval.end++;
|
||||
}
|
||||
else if (text[this->interval.end] == '.') {
|
||||
@ -6480,7 +6480,7 @@ namespace stdex
|
||||
for (;;) {
|
||||
if (this->interval.end < end && text[this->interval.end]) {
|
||||
if ('0' <= text[this->interval.end] && text[this->interval.end] <= '9') {
|
||||
decimalni_del = decimalni_del * 10 + static_cast<size_t>(text[this->interval.end] - '0');
|
||||
decimalni_del = decimalni_del * 10 + text[this->interval.end] - '0';
|
||||
decimalni_del_n *= 10;
|
||||
this->interval.end++;
|
||||
}
|
||||
@ -7368,8 +7368,8 @@ namespace stdex
|
||||
_In_ int flags = match_multiline)
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
stdex_assert(text || start + 1 >= end);
|
||||
if (start + 1 < end &&
|
||||
stdex_assert(text || start >= end);
|
||||
if (start < end && start + 1 < end &&
|
||||
text[start] == '/' &&
|
||||
text[start + 1] == '*')
|
||||
{
|
||||
@ -7419,8 +7419,8 @@ namespace stdex
|
||||
_In_ int flags = match_multiline)
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
stdex_assert(text || start + 3 >= end);
|
||||
if (start + 3 < end &&
|
||||
stdex_assert(text || start >= end);
|
||||
if (start < end && start + 3 < end &&
|
||||
text[start] == '<' &&
|
||||
text[start + 1] == '!' &&
|
||||
text[start + 2] == '-' &&
|
||||
@ -7457,8 +7457,8 @@ namespace stdex
|
||||
_In_ int flags = match_multiline)
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
stdex_assert(text || start + 2 >= end);
|
||||
if (start + 2 < end &&
|
||||
stdex_assert(text || start >= end);
|
||||
if (start < end && start + 2 < end &&
|
||||
text[start] == '-' &&
|
||||
text[start + 1] == '-' &&
|
||||
text[start + 2] == '>')
|
||||
@ -7571,8 +7571,8 @@ namespace stdex
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
this->interval.end = start;
|
||||
stdex_assert(text || this->interval.end + 3 >= end);
|
||||
if (this->interval.end + 3 < end &&
|
||||
stdex_assert(text || this->interval.end >= end);
|
||||
if (this->interval.end < end && this->interval.end + 3 < end &&
|
||||
(text[this->interval.end] == 'u' || text[this->interval.end] == 'U') &&
|
||||
(text[this->interval.end + 1] == 'r' || text[this->interval.end + 1] == 'R') &&
|
||||
(text[this->interval.end + 2] == 'l' || text[this->interval.end + 2] == 'L') &&
|
||||
@ -7681,8 +7681,8 @@ namespace stdex
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
this->interval.end = start;
|
||||
stdex_assert(text || this->interval.end + 6 >= end);
|
||||
if (this->interval.end + 6 < end &&
|
||||
stdex_assert(text || this->interval.end >= end);
|
||||
if (this->interval.end < end && this->interval.end + 6 < end &&
|
||||
text[this->interval.end] == '@' &&
|
||||
(text[this->interval.end + 1] == 'i' || text[this->interval.end + 1] == 'I') &&
|
||||
(text[this->interval.end + 2] == 'm' || text[this->interval.end + 2] == 'M') &&
|
||||
@ -7811,7 +7811,7 @@ namespace stdex
|
||||
// Skip whitespace.
|
||||
for (; this->interval.end < end && text[this->interval.end] && ctype.is(ctype.space, text[this->interval.end]); this->interval.end++);
|
||||
|
||||
if (this->interval.end + 7 < end &&
|
||||
if (this->interval.end < end && this->interval.end + 7 < end &&
|
||||
(text[this->interval.end] == 'c' || text[this->interval.end] == 'C') &&
|
||||
(text[this->interval.end + 1] == 'h' || text[this->interval.end + 1] == 'H') &&
|
||||
(text[this->interval.end + 2] == 'a' || text[this->interval.end + 2] == 'A') &&
|
||||
@ -8074,7 +8074,7 @@ namespace stdex
|
||||
else if (text[this->interval.end] == '!') {
|
||||
// <!...
|
||||
this->interval.end++;
|
||||
if (this->interval.end + 1 < end &&
|
||||
if (this->interval.end < end && this->interval.end + 1 < end &&
|
||||
text[this->interval.end] == '-' &&
|
||||
text[this->interval.end + 1] == '-')
|
||||
{
|
||||
@ -8149,7 +8149,7 @@ namespace stdex
|
||||
this->attributes.clear();
|
||||
for (;;) {
|
||||
if (this->type == html_sequence_t::element_start &&
|
||||
this->interval.end + 1 < end &&
|
||||
this->interval.end < end && this->interval.end + 1 < end &&
|
||||
text[this->interval.end] == '/' &&
|
||||
text[this->interval.end + 1] == '>')
|
||||
{
|
||||
@ -8166,7 +8166,7 @@ namespace stdex
|
||||
break;
|
||||
}
|
||||
if (this->type == html_sequence_t::declaration &&
|
||||
this->interval.end + 1 < end &&
|
||||
this->interval.end < end && this->interval.end + 1 < end &&
|
||||
text[this->interval.end] == '!' &&
|
||||
text[this->interval.end + 1] == '>')
|
||||
{
|
||||
@ -8175,7 +8175,7 @@ namespace stdex
|
||||
break;
|
||||
}
|
||||
if (this->type == html_sequence_t::declaration &&
|
||||
this->interval.end + 1 < end &&
|
||||
this->interval.end < end && this->interval.end + 1 < end &&
|
||||
text[this->interval.end] == '-' &&
|
||||
text[this->interval.end + 1] == '-')
|
||||
{
|
||||
@ -8285,8 +8285,8 @@ namespace stdex
|
||||
_In_ int flags = match_multiline)
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
stdex_assert(text || start + 2 >= end);
|
||||
if (start + 2 < end &&
|
||||
stdex_assert(text || start >= end);
|
||||
if (start < end && start + 2 < end &&
|
||||
text[start] == '<' &&
|
||||
text[start + 1] == '!' &&
|
||||
text[start + 2] == '[')
|
||||
@ -8342,8 +8342,8 @@ namespace stdex
|
||||
_In_ int flags = match_multiline)
|
||||
{
|
||||
_Unreferenced_(flags);
|
||||
stdex_assert(text || start + 2 >= end);
|
||||
if (start + 2 < end &&
|
||||
stdex_assert(text || start >= end);
|
||||
if (start < end && start + 2 < end &&
|
||||
text[start] == ']' &&
|
||||
text[start + 1] == ']' &&
|
||||
text[start + 2] == '>')
|
||||
|
@ -1195,7 +1195,8 @@ namespace stdex
|
||||
case op_t::flush:
|
||||
source->flush();
|
||||
break;
|
||||
case op_t::noop:;
|
||||
case op_t::noop:
|
||||
break;
|
||||
}
|
||||
op = op_t::noop;
|
||||
lk.unlock();
|
||||
|
@ -1840,7 +1840,7 @@ namespace stdex
|
||||
///
|
||||
template <class T1, size_t N1, class T2, size_t N2>
|
||||
size_t strncpy(
|
||||
_Out_ _Post_maybez_ T1(&dst)[N1],
|
||||
_Inout_ _Post_maybez_ T1(&dst)[N1],
|
||||
_In_ const T2(&src)[N2])
|
||||
{
|
||||
return strncpy(dst, N1, src, N2);
|
||||
@ -2823,7 +2823,7 @@ namespace stdex
|
||||
}
|
||||
size_t offset = str.size();
|
||||
str.resize(offset + count);
|
||||
if (vsnprintf(&str[offset], count + 1, format, locale, arg) != count) _Unlikely_
|
||||
if (vsnprintf(&str[offset], static_cast<size_t>(count) + 1, format, locale, arg) != count) _Unlikely_
|
||||
throw std::runtime_error("failed to format string");
|
||||
#else
|
||||
size_t offset = str.size();
|
||||
|
Loading…
x
Reference in New Issue
Block a user