Skip to content
Open
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
31 changes: 5 additions & 26 deletions src/main/cpp/blaze_util_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ BOOL WINAPI ConsoleCtrlHandler(_In_ DWORD ctrlType) {

void SignalHandler::Install(const string& product_name,
const blaze_util::Path& output_base,
const ServerProcessInfo* server_process_info_,
const ServerProcessInfo* server_process_info,
SignalHandler::Callback cancel_server) {
product_name_ = product_name;
output_base_ = output_base;
server_process_info_ = server_process_info_;
server_process_info_ = server_process_info;
cancel_server_ = cancel_server;
::SetConsoleCtrlHandler(&ConsoleCtrlHandler, TRUE);
}
Expand Down Expand Up @@ -360,27 +360,6 @@ void SigPrintf(const char* format, ...) {
}
}

static void PrintErrorW(const wstring& op) {
DWORD last_error = ::GetLastError();
if (last_error == 0) {
return;
}

WCHAR* message_buffer;
FormatMessageW(
/* dwFlags */ FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
/* lpSource */ nullptr,
/* dwMessageId */ last_error,
/* dwLanguageId */ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
/* lpBuffer */ message_buffer,
/* nSize */ 0,
/* Arguments */ nullptr);

fwprintf(stderr, L"ERROR: %s: %s (%d)\n", op.c_str(), message_buffer,
last_error);
LocalFree(message_buffer);
}

void WarnFilesystemType(const blaze_util::Path& output_base) {}

Expand Down Expand Up @@ -589,7 +568,7 @@ static HANDLE CreateJvmOutputFile(const blaze_util::Path& path,
/* hTemplateFile */ nullptr);
if (handle != INVALID_HANDLE_VALUE) {
if (daemon_out_append &&
!SetFilePointerEx(handle, {0}, nullptr, FILE_END)) {
!SetFilePointerEx(handle, {}, nullptr, FILE_END)) {
fprintf(stderr, "Could not seek to end of file (%s)\n",
path.AsPrintablePath().c_str());
return INVALID_HANDLE_VALUE;
Expand Down Expand Up @@ -690,7 +669,7 @@ int ExecuteDaemon(
}

PROCESS_INFORMATION processInfo = {0};
STARTUPINFOEXW startupInfoEx = {0};
STARTUPINFOEXW startupInfoEx = {};
lpAttributeList->InitStartupInfoExW(&startupInfoEx);

std::vector<std::wstring> wesc_args_vector;
Expand Down Expand Up @@ -1250,7 +1229,7 @@ bool IsEmacsTerminal() {
bool IsStandardTerminal() {
for (DWORD i : {STD_OUTPUT_HANDLE, STD_ERROR_HANDLE}) {
DWORD mode = 0;
HANDLE handle = ::GetStdHandle(STD_ERROR_HANDLE);
HANDLE handle = ::GetStdHandle(i);
// handle may be invalid when std{out,err} is redirected
if (handle == INVALID_HANDLE_VALUE || !::GetConsoleMode(handle, &mode) ||
!(mode & ENABLE_PROCESSED_OUTPUT) ||
Expand Down
2 changes: 1 addition & 1 deletion src/main/cpp/util/errors_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ string GetLastErrorString() {
}

char* message_buffer;
size_t size = FormatMessageA(
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, last_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
Expand Down
15 changes: 1 addition & 14 deletions src/main/native/windows/process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@ static std::wstring ToString(const T& e) {
return s.str();
}

static bool DupeHandle(HANDLE h, AutoHandle* out, std::wstring* error) {
HANDLE dup;
if (!DuplicateHandle(GetCurrentProcess(), h, GetCurrentProcess(), &dup, 0,
TRUE, DUPLICATE_SAME_ACCESS)) {
DWORD err = GetLastError();
*error =
MakeErrorMessage(WSTR(__FILE__), __LINE__, L"DupeHandle", L"", err);
return false;
}
*out = dup;
return true;
}

bool WaitableProcess::Create(const std::wstring& argv0,
const std::wstring& argv_rest, void* env,
const std::wstring& wcwd, std::wstring* error) {
Expand Down Expand Up @@ -113,7 +100,7 @@ bool WaitableProcess::Create(const std::wstring& argv0,
return false;
}

JOBOBJECT_EXTENDED_LIMIT_INFORMATION job_info = {0};
JOBOBJECT_EXTENDED_LIMIT_INFORMATION job_info = {};
job_info.BasicLimitInformation.LimitFlags =
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if (!SetInformationJobObject(job_, JobObjectExtendedLimitInformation,
Expand Down
4 changes: 2 additions & 2 deletions src/main/native/windows/processes-jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class NativeProcess {
stdout_redirect, err_code);
return false;
}
if (!SetFilePointerEx(stdout_process, {0}, nullptr, FILE_END)) {
if (!SetFilePointerEx(stdout_process, {}, nullptr, FILE_END)) {
DWORD err_code = GetLastError();
error_ = bazel::windows::MakeErrorMessage(WSTR(__FILE__), __LINE__,
L"nativeCreateProcess",
Expand Down Expand Up @@ -339,7 +339,7 @@ class NativeProcess {
stderr_redirect, err_code);
return false;
}
if (!SetFilePointerEx(stderr_process, {0}, nullptr, FILE_END)) {
if (!SetFilePointerEx(stderr_process, {}, nullptr, FILE_END)) {
DWORD err_code = GetLastError();
error_ = bazel::windows::MakeErrorMessage(WSTR(__FILE__), __LINE__,
L"nativeCreateProcess",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/launcher/util/launcher_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ string GetLastErrorString() {
}

char* message_buffer;
size_t size = FormatMessageA(
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, last_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
Expand Down
7 changes: 7 additions & 0 deletions third_party/def_parser/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ cc_library(
name = "def_parser_lib",
srcs = ["def_parser.cc"],
hdrs = ["def_parser.h"],
copts = select({
"@rules_cc//cc/compiler:clang": [
# third_party/def_parser/def_parser.cc:349:10: warning: unused variable 'size' [-Wunused-variable]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we just remove the unused variable here?

"-Wno-unused-variable",
],
"//conditions:default": [],
}),
tags = [
"__DONT_DEPEND_ON_DEF_PARSER__",
],
Expand Down
23 changes: 1 addition & 22 deletions tools/test/windows/tw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ bool AppendFileTo(const Path& file, const size_t total_size, HANDLE output) {
// If the MIME type is unknown or an error occurs, the method returns
// "application/octet-stream".
std::string GetMimeType(const std::string& filename) {
static constexpr char* kDefaultMimeType = "application/octet-stream";
static constexpr const char* kDefaultMimeType = "application/octet-stream";
std::string::size_type pos = filename.find_last_of('.');
if (pos == std::string::npos) {
return kDefaultMimeType;
Expand Down Expand Up @@ -1145,9 +1145,6 @@ bool PrintTestLogStartMarker() {
return true;
}

inline bool GetWorkspaceName(std::wstring* result) {
return GetEnv(L"TEST_WORKSPACE", result) && !result->empty();
}

inline void ComputeRunfilePath(const std::wstring& test_workspace,
std::wstring* s) {
Expand Down Expand Up @@ -1232,24 +1229,6 @@ bool FindTestBinary(const Path& argv0, const Path& cwd, std::wstring test_path,
return true;
}

bool CreateCommandLine(const Path& path, const std::wstring& args,
std::unique_ptr<WCHAR[]>* result) {
// kMaxCmdline value: see lpCommandLine parameter of CreateProcessW.
static constexpr size_t kMaxCmdline = 32767;

if (path.Get().size() + args.size() > kMaxCmdline) {
LogErrorWithValue(__LINE__, L"Command is too long",
path.Get().size() + args.size());
return false;
}

// Add an extra character for the final null-terminator.
result->reset(new WCHAR[path.Get().size() + args.size() + 1]);

wcsncpy(result->get(), path.Get().c_str(), path.Get().size());
wcsncpy(result->get() + path.Get().size(), args.c_str(), args.size() + 1);
return true;
}

bool StartSubprocess(const Path& path, const std::wstring& args,
const Path& outerr, std::unique_ptr<Tee>* tee,
Expand Down