1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-09 23:33:46 -05:00

Make new_error_socket() into a printf-style function.

Almost all the call sites were doing a cumbersome dupprintf-use-free
cycle to get a formatted message into an ErrorSocket anyway, so it
seems more sensible to give them an easier way of doing so.

The few call sites that were passing a constant string literal
_shouldn't_ have been - they'll be all the better for adding a
strerror suffix to the message they were previously giving!
This commit is contained in:
Simon Tatham
2018-10-07 14:47:16 +01:00
parent 55860cace7
commit cea1329b9e
5 changed files with 38 additions and 37 deletions

View File

@ -50,30 +50,30 @@ Socket *platform_new_connection(SockAddr *addr, const char *hostname,
sa.lpSecurityDescriptor = NULL; /* default */
sa.bInheritHandle = TRUE;
if (!CreatePipe(&us_from_cmd, &cmd_to_us, &sa, 0)) {
Socket *ret =
new_error_socket("Unable to create pipes for proxy command", plug);
sfree(cmd);
return ret;
return new_error_socket_fmt(
plug, "Unable to create pipes for proxy command: %s",
win_strerror(GetLastError()));
}
if (!CreatePipe(&cmd_from_us, &us_to_cmd, &sa, 0)) {
Socket *ret =
new_error_socket("Unable to create pipes for proxy command", plug);
sfree(cmd);
CloseHandle(us_from_cmd);
CloseHandle(cmd_to_us);
return ret;
return new_error_socket_fmt(
plug, "Unable to create pipes for proxy command: %s",
win_strerror(GetLastError()));
}
if (!CreatePipe(&us_from_cmd_err, &cmd_err_to_us, &sa, 0)) {
Socket *ret = new_error_socket
("Unable to create pipes for proxy command", plug);
sfree(cmd);
CloseHandle(us_from_cmd);
CloseHandle(cmd_to_us);
CloseHandle(us_to_cmd);
CloseHandle(cmd_from_us);
return ret;
return new_error_socket_fmt(
plug, "Unable to create pipes for proxy command: %s",
win_strerror(GetLastError()));
}
SetHandleInformation(us_to_cmd, HANDLE_FLAG_INHERIT, 0);