adb: win32: call SystemErrorCodeToString() from more places
Improve some error messages, or trace output. Change-Id: Ib09fac33a296f090d37f125cad7556fc5b5e928e Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
This commit is contained in:
parent
c70ac57db0
commit
8df9032176
21
adb/adb.cpp
21
adb/adb.cpp
|
@ -580,8 +580,8 @@ int launch_server(int server_port)
|
|||
FILE_SHARE_READ | FILE_SHARE_WRITE, &sa,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (nul_read == INVALID_HANDLE_VALUE) {
|
||||
fprintf(stderr, "CreateFileW(nul, GENERIC_READ) failure, error %ld\n",
|
||||
GetLastError());
|
||||
fprintf(stderr, "CreateFileW(nul, GENERIC_READ) failed: %s\n",
|
||||
SystemErrorCodeToString(GetLastError()).c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -589,8 +589,8 @@ int launch_server(int server_port)
|
|||
FILE_SHARE_READ | FILE_SHARE_WRITE, &sa,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (nul_write == INVALID_HANDLE_VALUE) {
|
||||
fprintf(stderr, "CreateFileW(nul, GENERIC_WRITE) failure, error %ld\n",
|
||||
GetLastError());
|
||||
fprintf(stderr, "CreateFileW(nul, GENERIC_WRITE) failed: %s\n",
|
||||
SystemErrorCodeToString(GetLastError()).c_str());
|
||||
CloseHandle(nul_read);
|
||||
return -1;
|
||||
}
|
||||
|
@ -598,7 +598,8 @@ int launch_server(int server_port)
|
|||
/* create pipe, and ensure its read handle isn't inheritable */
|
||||
ret = CreatePipe( &pipe_read, &pipe_write, &sa, 0 );
|
||||
if (!ret) {
|
||||
fprintf(stderr, "CreatePipe() failure, error %ld\n", GetLastError() );
|
||||
fprintf(stderr, "CreatePipe() failed: %s\n",
|
||||
SystemErrorCodeToString(GetLastError()).c_str());
|
||||
CloseHandle(nul_read);
|
||||
CloseHandle(nul_write);
|
||||
return -1;
|
||||
|
@ -640,8 +641,8 @@ int launch_server(int server_port)
|
|||
arraysize(program_path));
|
||||
if ((module_result == arraysize(program_path)) || (module_result == 0)) {
|
||||
// String truncation or some other error.
|
||||
fprintf(stderr, "GetModuleFileNameW() failure, error %ld\n",
|
||||
GetLastError());
|
||||
fprintf(stderr, "GetModuleFileNameW() failed: %s\n",
|
||||
SystemErrorCodeToString(GetLastError()).c_str());
|
||||
return -1;
|
||||
}
|
||||
WCHAR args[64];
|
||||
|
@ -666,7 +667,8 @@ int launch_server(int server_port)
|
|||
CloseHandle( pipe_write );
|
||||
|
||||
if (!ret) {
|
||||
fprintf(stderr, "CreateProcess failure, error %ld\n", GetLastError() );
|
||||
fprintf(stderr, "CreateProcess failed: %s\n",
|
||||
SystemErrorCodeToString(GetLastError()).c_str());
|
||||
CloseHandle( pipe_read );
|
||||
return -1;
|
||||
}
|
||||
|
@ -682,7 +684,8 @@ int launch_server(int server_port)
|
|||
ret = ReadFile( pipe_read, temp, 3, &count, NULL );
|
||||
CloseHandle( pipe_read );
|
||||
if ( !ret ) {
|
||||
fprintf(stderr, "could not read ok from ADB Server, error = %ld\n", GetLastError() );
|
||||
fprintf(stderr, "could not read ok from ADB Server, error: %s\n",
|
||||
SystemErrorCodeToString(GetLastError()).c_str());
|
||||
return -1;
|
||||
}
|
||||
if (count != 3 || temp[0] != 'O' || temp[1] != 'K' || temp[2] != '\n') {
|
||||
|
|
|
@ -305,7 +305,10 @@ static int get_user_keyfilepath(char *filename, size_t len)
|
|||
home = getenv("ANDROID_SDK_HOME");
|
||||
if (!home) {
|
||||
WCHAR path[MAX_PATH];
|
||||
if (FAILED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, path))) {
|
||||
const HRESULT hr = SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, path);
|
||||
if (FAILED(hr)) {
|
||||
D("SHGetFolderPathW failed: %s\n",
|
||||
SystemErrorCodeToString(hr).c_str());
|
||||
return -1;
|
||||
}
|
||||
home_str = narrow(path);
|
||||
|
|
|
@ -426,7 +426,8 @@ int adb_open(const char* path, int options)
|
|||
return -1;
|
||||
|
||||
default:
|
||||
D( "unknown error: %ld\n", err );
|
||||
D( "unknown error: %s\n",
|
||||
SystemErrorCodeToString( err ).c_str() );
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
@ -469,7 +470,8 @@ int adb_creat(const char* path, int mode)
|
|||
return -1;
|
||||
|
||||
default:
|
||||
D( "unknown error: %ld\n", err );
|
||||
D( "unknown error: %s\n",
|
||||
SystemErrorCodeToString( err ).c_str() );
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
@ -2315,7 +2317,7 @@ static bool _get_interesting_input_record_uncached(const HANDLE console,
|
|||
memset(input_record, 0, sizeof(*input_record));
|
||||
if (!ReadConsoleInputA(console, input_record, 1, &read_count)) {
|
||||
D("_get_interesting_input_record_uncached: ReadConsoleInputA() "
|
||||
"failure, error %ld\n", GetLastError());
|
||||
"failed: %s\n", SystemErrorCodeToString(GetLastError()).c_str());
|
||||
errno = EIO;
|
||||
return false;
|
||||
}
|
||||
|
@ -3129,8 +3131,8 @@ void stdin_raw_init(const int fd) {
|
|||
if (!SetConsoleMode(in, _old_console_mode & ~(ENABLE_PROCESSED_INPUT |
|
||||
ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT))) {
|
||||
// This really should not fail.
|
||||
D("stdin_raw_init: SetConsoleMode() failure, error %ld\n",
|
||||
GetLastError());
|
||||
D("stdin_raw_init: SetConsoleMode() failed: %s\n",
|
||||
SystemErrorCodeToString(GetLastError()).c_str());
|
||||
}
|
||||
|
||||
// Once this is set, it means that stdin has been configured for
|
||||
|
@ -3151,8 +3153,8 @@ void stdin_raw_restore(const int fd) {
|
|||
|
||||
if (!SetConsoleMode(in, _old_console_mode)) {
|
||||
// This really should not fail.
|
||||
D("stdin_raw_restore: SetConsoleMode() failure, error %ld\n",
|
||||
GetLastError());
|
||||
D("stdin_raw_restore: SetConsoleMode() failed: %s\n",
|
||||
SystemErrorCodeToString(GetLastError()).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue