fix: add variable initialization

This commit is contained in:
dantmnf
2022-09-05 01:54:44 +08:00
parent 90a0621814
commit c103875cd9
3 changed files with 12 additions and 12 deletions

View File

@@ -38,7 +38,7 @@ std::string asst::utils::path_to_crt_string(const std::filesystem::path& path)
{
// UCRT may use UTF-8 encoding while ANSI code page is still some other MBCS encoding
// so we use CRT wcstombs instead of WideCharToMultiByte
size_t mbsize;
size_t mbsize = 0;
auto osstr = path.native();
auto err = wcstombs_s(&mbsize, nullptr, 0, osstr.c_str(), osstr.size());
if (err == 0) {
@@ -108,8 +108,8 @@ std::string asst::utils::callcmd(const std::string& cmdline)
auto pipe_buffer = std::make_unique<char[]>(PipeBuffSize);
std::string pipe_str;
DWORD err;
HANDLE pipe_parent_read, pipe_child_write;
DWORD err = 0;
HANDLE pipe_parent_read = INVALID_HANDLE_VALUE, pipe_child_write = INVALID_HANDLE_VALUE;
SECURITY_ATTRIBUTES sa_inherit { .nLength = sizeof(SECURITY_ATTRIBUTES), .bInheritHandle = TRUE };
if (!asst::win32::CreateOverlappablePipe(&pipe_parent_read, &pipe_child_write, nullptr, &sa_inherit, PipeBuffSize,
true, false)) {

View File

@@ -202,15 +202,15 @@ std::optional<std::string> asst::Controller::call_command(const std::string& cmd
using namespace std::chrono;
// LogTraceScope(std::string(__FUNCTION__) + " | `" + cmd + "`");
std::vector<uchar> pipe_data;
std::vector<uchar> sock_data;
std::string pipe_data;
std::string sock_data;
auto start_time = steady_clock::now();
#ifdef _WIN32
DWORD err;
HANDLE pipe_parent_read, pipe_child_write;
DWORD err = 0;
HANDLE pipe_parent_read = INVALID_HANDLE_VALUE, pipe_child_write = INVALID_HANDLE_VALUE;
SECURITY_ATTRIBUTES sa_inherit { .nLength = sizeof(SECURITY_ATTRIBUTES), .bInheritHandle = TRUE };
if (!asst::win32::CreateOverlappablePipe(&pipe_parent_read, &pipe_child_write, nullptr, &sa_inherit, PipeBuffSize, true,
false)) {
@@ -1200,7 +1200,7 @@ bool asst::Controller::connect(const std::string& adb_path, const std::string& a
}
}
auto socket_opt = try_to_init_socket(bind_address, adb_cfg.nc_port);
auto socket_opt = try_to_init_socket(bind_address);
if (socket_opt) {
nc_port = socket_opt.value();
m_adb.screencap_raw_by_nc = cmd_replace(adb_cfg.screencap_raw_by_nc);

View File

@@ -42,7 +42,7 @@ asst::OcrPack::~OcrPack()
bool asst::OcrPack::load(const std::filesystem::path& path)
{
bool use_temp_dir;
bool use_temp_dir = false;
auto paddle_dir = prepare_paddle_dir(path, &use_temp_dir);
if (paddle_dir.empty() || !std::filesystem::exists(paddle_dir)) {
@@ -63,9 +63,9 @@ bool asst::OcrPack::load(const std::filesystem::path& path)
PaddleOcrDestroy(m_ocr);
}
const auto det4paddle = asst::utils::path_to_crt_string(dst_filename);
const auto rec4paddle = asst::utils::path_to_crt_string(rec_filename);
const auto keys4paddle = asst::utils::path_to_crt_string(keys_filename);
const auto det4paddle = asst::utils::path_to_ansi_string(dst_filename);
const auto rec4paddle = asst::utils::path_to_ansi_string(rec_filename);
const auto keys4paddle = asst::utils::path_to_ansi_string(keys_filename);
if (det4paddle.empty() || rec4paddle.empty() || keys4paddle.empty()) {
return false;