Skip to content

Static analyzer (PVS Studio) fixes #1372

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

Merged
merged 7 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Release/include/cpprest/producerconsumerstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class basic_producer_consumer_buffer : public streams::details::streambuf_state_
/// </summary>
basic_producer_consumer_buffer(size_t alloc_size)
: streambuf_state_manager<_CharType>(std::ios_base::out | std::ios_base::in)
, m_mode(std::ios_base::in)
, m_alloc_size(alloc_size)
, m_allocBlock(nullptr)
, m_total(0)
Expand Down
2 changes: 1 addition & 1 deletion Release/src/http/listener/http_server_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void http_server_api::unregister_server_api()
throw http_exception(_XPLATSTR("Server API was cleared while listeners were still attached"));
}

s_server_api.release();
s_server_api.reset();
}

void http_server_api::unsafe_register_server_api(std::unique_ptr<http_server> server_api)
Expand Down
2 changes: 1 addition & 1 deletion Release/src/http/listener/http_server_httpsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace http::details;
using namespace http::experimental::listener;
using namespace http::experimental::details;

#define CHUNK_SIZE 64 * 1024
#define CHUNK_SIZE (64 * 1024)

namespace web
{
Expand Down
2 changes: 1 addition & 1 deletion Release/src/pch/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
// Windows Header Files:
#ifndef __cplusplus_winrt
#include <winhttp.h>
#endif !__cplusplus_winrt
#endif // !__cplusplus_winrt

#else // LINUX or APPLE
#define __STDC_LIMIT_MACROS
Expand Down
10 changes: 5 additions & 5 deletions Release/src/streams/fileio_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void CALLBACK IoCompletionCallback(PTP_CALLBACK_INSTANCE instance,

EXTENDED_OVERLAPPED* pExtOverlapped = static_cast<EXTENDED_OVERLAPPED*>(pOverlapped);
pExtOverlapped->func(result, static_cast<DWORD>(numberOfBytesTransferred), static_cast<LPOVERLAPPED>(pOverlapped));
delete pOverlapped;
delete pExtOverlapped;
}
#endif

Expand Down Expand Up @@ -399,10 +399,10 @@ size_t _write_file_async(_In_ streams::details::_file_info_impl* fInfo,

size_t result = static_cast<size_t>(-1);

if (wrResult == TRUE)
if (wrResult)
{
// If WriteFile returned true, it must be because the operation completed immediately.
// However, we didn't pass in an address for the number of bytes written, so
// However, we didn't pass in an address for the number of bytes written, so
// we have to retrieve it using 'GetOverlappedResult,' which may, in turn, fail.
DWORD written = 0;
result = GetOverlappedResult(fInfo->m_handle, pOverlapped.get(), &written, FALSE) ? static_cast<size_t>(written)
Expand Down Expand Up @@ -496,7 +496,7 @@ size_t _read_file_async(_In_ streams::details::_file_info_impl* fInfo,

size_t result = static_cast<size_t>(-1);

if (wrResult == TRUE)
if (wrResult)
{
// If ReadFile returned true, it must be because the operation completed immediately.
// However, we didn't pass in an address for the number of bytes written, so
Expand Down Expand Up @@ -941,7 +941,7 @@ utility::size64_t __cdecl _get_size(_In_ concurrency::streams::details::_file_in

LARGE_INTEGER size;

if (GetFileSizeEx(fInfo->m_handle, &size) == TRUE)
if (GetFileSizeEx(fInfo->m_handle, &size))
return utility::size64_t(size.QuadPart / char_size);
else
return 0;
Expand Down
2 changes: 1 addition & 1 deletion Release/src/utilities/asyncrt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ datetime __cdecl datetime::from_string(const utility::string_t& dateString, date
{
tzHours = 8;
}
else if ((tzCh == _XPLATSTR('+') || tzCh == _XPLATSTR('-')) && ascii_isdigit2(str[1]) &&
else if ((str[0] == _XPLATSTR('+') || str[0] == _XPLATSTR('-')) && ascii_isdigit2(str[1]) &&
ascii_isdigit(str[2]) && ascii_isdigit5(str[3]) && ascii_isdigit(str[4]))
{
tzCh = str[0];
Expand Down
3 changes: 2 additions & 1 deletion Release/tests/functional/utils/datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ SUITE(datetime)
_XPLATSTR("01 Jan 1971 00:00:61 GMT"),
_XPLATSTR("01 Jan 1899 00:00:00 GMT"), // underflow
_XPLATSTR("01 Jan 1969 00:00:00 CEST"), // bad tz
_XPLATSTR("01 Jan 1970 00:00:00 +2400"), // bad tzoffsets
_XPLATSTR("14 Jan 2019 23:16:21 G0100"), // bad tzoffsets
_XPLATSTR("01 Jan 1970 00:00:00 +2400"),
_XPLATSTR("01 Jan 1970 00:00:00 -3000"),
_XPLATSTR("01 Jan 1970 00:00:00 +2160"),
_XPLATSTR("01 Jan 1970 00:00:00 -2400"),
Expand Down