mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Formatting: standardise on "func(\n", not "func\n(".
If the function name (or expression) in a function call or declaration is itself so long that even the first argument doesn't fit after it on the same line, or if that would leave so little space that it would be silly to try to wrap all the run-on lines into a tall thin column, then I used to do this ludicrously_long_function_name (arg1, arg2, arg3); and now prefer this ludicrously_long_function_name( arg1, arg2, arg3); I picked up the habit from Python, where the latter idiom is required by Python's syntactic significance of newlines (you can write the former if you use a backslash-continuation, but pretty much everyone seems to agree that that's much uglier). But I've found it works well in C as well: it makes it more obvious that the previous line is incomplete, it gives you a tiny bit more space to wrap the following lines into (the old idiom indents the _third_ line one space beyond the second), and I generally turn out to agree with the knock-on indentation decisions made by at least Emacs if you do it in the middle of a complex expression. Plus, of course, using the _same_ idiom between C and Python means less state-switching. So, while I'm making annoying indentation changes in general, this seems like a good time to dig out all the cases of the old idiom in this code, and switch them over to the new.
This commit is contained in:
@ -62,8 +62,8 @@ static void wm_copydata_agent_query(strbuf *query, void **out, int *outlen)
|
||||
psd = (PSECURITY_DESCRIPTOR)
|
||||
LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
|
||||
if (psd) {
|
||||
if (p_InitializeSecurityDescriptor
|
||||
(psd, SECURITY_DESCRIPTOR_REVISION) &&
|
||||
if (p_InitializeSecurityDescriptor(
|
||||
psd, SECURITY_DESCRIPTOR_REVISION) &&
|
||||
p_SetSecurityDescriptorOwner(psd, usersid, false)) {
|
||||
sa.nLength = sizeof(sa);
|
||||
sa.bInheritHandle = true;
|
||||
|
@ -385,10 +385,10 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
|
||||
SetWindowText(hwnd, str);
|
||||
sfree(str);
|
||||
char *buildinfo_text = buildinfo("\r\n");
|
||||
char *text = dupprintf
|
||||
("%s\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
appname, ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
char *text = dupprintf(
|
||||
"%s\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
appname, ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
sfree(buildinfo_text);
|
||||
SetDlgItemText(hwnd, IDA_TEXT, text);
|
||||
MakeDlgItemBorderless(hwnd, IDA_TEXT);
|
||||
|
@ -544,13 +544,13 @@ static void update_jumplist_from_registry(void)
|
||||
*/
|
||||
for (i = 0, found = false; i < nremoved && !found; i++) {
|
||||
IShellLink *rlink;
|
||||
if (SUCCEEDED(pRemoved->lpVtbl->GetAt
|
||||
(pRemoved, i, COMPTR(IShellLink, &rlink)))) {
|
||||
if (SUCCEEDED(pRemoved->lpVtbl->GetAt(
|
||||
pRemoved, i, COMPTR(IShellLink, &rlink)))) {
|
||||
char desc1[2048], desc2[2048];
|
||||
if (SUCCEEDED(link->lpVtbl->GetDescription
|
||||
(link, desc1, sizeof(desc1)-1)) &&
|
||||
SUCCEEDED(rlink->lpVtbl->GetDescription
|
||||
(rlink, desc2, sizeof(desc2)-1)) &&
|
||||
if (SUCCEEDED(link->lpVtbl->GetDescription(
|
||||
link, desc1, sizeof(desc1)-1)) &&
|
||||
SUCCEEDED(rlink->lpVtbl->GetDescription(
|
||||
rlink, desc2, sizeof(desc2)-1)) &&
|
||||
!strcmp(desc1, desc2)) {
|
||||
found = true;
|
||||
}
|
||||
@ -575,8 +575,8 @@ static void update_jumplist_from_registry(void)
|
||||
* Get the array form of the collection we've just constructed,
|
||||
* and put it in the jump list.
|
||||
*/
|
||||
if (!SUCCEEDED(collection->lpVtbl->QueryInterface
|
||||
(collection, COMPTR(IObjectArray, &array))))
|
||||
if (!SUCCEEDED(collection->lpVtbl->QueryInterface(
|
||||
collection, COMPTR(IObjectArray, &array))))
|
||||
goto cleanup;
|
||||
|
||||
pCDL->lpVtbl->AppendCategory(pCDL, L"Recent Sessions", array);
|
||||
@ -608,8 +608,8 @@ static void update_jumplist_from_registry(void)
|
||||
* Get the array form of the collection we've just constructed,
|
||||
* and put it in the jump list.
|
||||
*/
|
||||
if (!SUCCEEDED(collection->lpVtbl->QueryInterface
|
||||
(collection, COMPTR(IObjectArray, &array))))
|
||||
if (!SUCCEEDED(collection->lpVtbl->QueryInterface(
|
||||
collection, COMPTR(IObjectArray, &array))))
|
||||
goto cleanup;
|
||||
|
||||
pCDL->lpVtbl->AddUserTasks(pCDL, array);
|
||||
@ -636,8 +636,8 @@ static void update_jumplist_from_registry(void)
|
||||
* Get the array form of the collection we've just constructed,
|
||||
* and put it in the jump list.
|
||||
*/
|
||||
if (!SUCCEEDED(collection->lpVtbl->QueryInterface
|
||||
(collection, COMPTR(IObjectArray, &array))))
|
||||
if (!SUCCEEDED(collection->lpVtbl->QueryInterface(
|
||||
collection, COMPTR(IObjectArray, &array))))
|
||||
goto cleanup;
|
||||
|
||||
pCDL->lpVtbl->AddUserTasks(pCDL, array);
|
||||
|
@ -77,33 +77,33 @@ static bool create_named_pipe(NamedPipeServerSocket *ps, bool first_instance)
|
||||
sa.lpSecurityDescriptor = ps->psd;
|
||||
sa.bInheritHandle = false;
|
||||
|
||||
ps->pipehandle = CreateNamedPipe
|
||||
(/* lpName */
|
||||
ps->pipename,
|
||||
ps->pipehandle = CreateNamedPipe(
|
||||
/* lpName */
|
||||
ps->pipename,
|
||||
|
||||
/* dwOpenMode */
|
||||
PIPE_ACCESS_DUPLEX |
|
||||
FILE_FLAG_OVERLAPPED |
|
||||
(first_instance ? FILE_FLAG_FIRST_PIPE_INSTANCE : 0),
|
||||
/* dwOpenMode */
|
||||
PIPE_ACCESS_DUPLEX |
|
||||
FILE_FLAG_OVERLAPPED |
|
||||
(first_instance ? FILE_FLAG_FIRST_PIPE_INSTANCE : 0),
|
||||
|
||||
/* dwPipeMode */
|
||||
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT
|
||||
/* dwPipeMode */
|
||||
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT
|
||||
#ifdef PIPE_REJECT_REMOTE_CLIENTS
|
||||
| PIPE_REJECT_REMOTE_CLIENTS
|
||||
| PIPE_REJECT_REMOTE_CLIENTS
|
||||
#endif
|
||||
,
|
||||
,
|
||||
|
||||
/* nMaxInstances */
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
/* nMaxInstances */
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
|
||||
/* nOutBufferSize, nInBufferSize */
|
||||
4096, 4096, /* FIXME: think harder about buffer sizes? */
|
||||
/* nOutBufferSize, nInBufferSize */
|
||||
4096, 4096, /* FIXME: think harder about buffer sizes? */
|
||||
|
||||
/* nDefaultTimeOut */
|
||||
0 /* default timeout */,
|
||||
/* nDefaultTimeOut */
|
||||
0 /* default timeout */,
|
||||
|
||||
/* lpSecurityAttributes */
|
||||
&sa);
|
||||
/* lpSecurityAttributes */
|
||||
&sa);
|
||||
|
||||
return ps->pipehandle != INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
@ -133,10 +133,10 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG: {
|
||||
char *buildinfo_text = buildinfo("\r\n");
|
||||
char *text = dupprintf
|
||||
("Pageant\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
char *text = dupprintf(
|
||||
"Pageant\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
sfree(buildinfo_text);
|
||||
SetDlgItemText(hwnd, IDC_ABOUT_TEXTBOX, text);
|
||||
MakeDlgItemBorderless(hwnd, IDC_ABOUT_TEXTBOX);
|
||||
|
@ -543,10 +543,10 @@ static INT_PTR CALLBACK AboutProc(HWND hwnd, UINT msg,
|
||||
|
||||
{
|
||||
char *buildinfo_text = buildinfo("\r\n");
|
||||
char *text = dupprintf
|
||||
("PuTTYgen\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
char *text = dupprintf(
|
||||
"PuTTYgen\r\n\r\n%s\r\n\r\n%s\r\n\r\n%s",
|
||||
ver, buildinfo_text,
|
||||
"\251 " SHORT_COPYRIGHT_DETAILS ". All rights reserved.");
|
||||
sfree(buildinfo_text);
|
||||
SetDlgItemText(hwnd, 1000, text);
|
||||
MakeDlgItemBorderless(hwnd, 1000);
|
||||
@ -1922,10 +1922,10 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
||||
|
||||
if ((state->keytype == RSA || state->keytype == DSA) &&
|
||||
state->key_bits < 256) {
|
||||
char *message = dupprintf
|
||||
("PuTTYgen will not generate a key smaller than 256"
|
||||
" bits.\nKey length reset to default %d. Continue?",
|
||||
DEFAULT_KEY_BITS);
|
||||
char *message = dupprintf(
|
||||
"PuTTYgen will not generate a key smaller than 256"
|
||||
" bits.\nKey length reset to default %d. Continue?",
|
||||
DEFAULT_KEY_BITS);
|
||||
int ret = MessageBox(hwnd, message, "PuTTYgen Warning",
|
||||
MB_ICONWARNING | MB_OKCANCEL);
|
||||
sfree(message);
|
||||
@ -1935,9 +1935,9 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg,
|
||||
SetDlgItemInt(hwnd, IDC_BITS, DEFAULT_KEY_BITS, false);
|
||||
} else if ((state->keytype == RSA || state->keytype == DSA) &&
|
||||
state->key_bits < DEFAULT_KEY_BITS) {
|
||||
char *message = dupprintf
|
||||
("Keys shorter than %d bits are not recommended. "
|
||||
"Really generate this key?", DEFAULT_KEY_BITS);
|
||||
char *message = dupprintf(
|
||||
"Keys shorter than %d bits are not recommended. "
|
||||
"Really generate this key?", DEFAULT_KEY_BITS);
|
||||
int ret = MessageBox(hwnd, message, "PuTTYgen Warning",
|
||||
MB_ICONWARNING | MB_OKCANCEL);
|
||||
sfree(message);
|
||||
|
@ -685,8 +685,8 @@ void write_random_seed(void *data, int len)
|
||||
* returning the resulting concatenated list of strings in 'out' (if
|
||||
* non-null).
|
||||
*/
|
||||
static int transform_jumplist_registry
|
||||
(const char *add, const char *rem, char **out)
|
||||
static int transform_jumplist_registry(
|
||||
const char *add, const char *rem, char **out)
|
||||
{
|
||||
HKEY rkey = open_regkey(true, HKEY_CURRENT_USER, reg_jumplist_key);
|
||||
if (!rkey)
|
||||
|
@ -290,10 +290,10 @@ static bool really_restrict_process_acl(char **error)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (ERROR_SUCCESS != p_SetSecurityInfo
|
||||
(GetCurrentProcess(), SE_KERNEL_OBJECT,
|
||||
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
|
||||
usersid, NULL, acl, NULL)) {
|
||||
if (ERROR_SUCCESS != p_SetSecurityInfo(
|
||||
GetCurrentProcess(), SE_KERNEL_OBJECT,
|
||||
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
|
||||
usersid, NULL, acl, NULL)) {
|
||||
*error = dupprintf("Unable to set process ACL: %s",
|
||||
win_strerror(GetLastError()));
|
||||
goto cleanup;
|
||||
|
Reference in New Issue
Block a user