From 04c1617f207241a543d9f0084c4df577d65f1cf4 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 3 Aug 2022 20:48:46 +0100 Subject: [PATCH] Formatting: realign labels and case/default statements. My aim has always been to have those back-dented by 2 spaces (half an indent level) compared to the statements around them, so that in particular switch statements have distinct alignment for the statement, the cases and the interior code without consuming two whole indent levels. This patch sweeps up all the violations of that principle found by my bulk-reindentation exercise. --- import.c | 20 ++++----- ldisc.c | 2 +- otherbackends/supdup.c | 94 ++++++++++++++++++++-------------------- unix/agent-client.c | 2 +- unix/network.c | 4 +- unix/pty.c | 2 +- unix/sftp.c | 8 ++-- unix/storage.c | 2 +- unix/window.c | 2 +- windows/network.c | 2 +- windows/printing.c | 4 +- windows/sftp.c | 8 ++-- windows/utils/security.c | 2 +- windows/window.c | 2 +- 14 files changed, 77 insertions(+), 77 deletions(-) diff --git a/import.c b/import.c index 7e0d7b74..79a4359d 100644 --- a/import.c +++ b/import.c @@ -498,7 +498,7 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, if (errmsg_p) *errmsg_p = NULL; return ret; - error: + error: if (line) { smemclr(line, strlen(line)); sfree(line); @@ -801,7 +801,7 @@ static ssh2_userkey *openssh_pem_read( errmsg = NULL; /* no error */ retval = retkey; - error: + error: strbuf_free(blob); strbuf_free(key->keyblob); smemclr(key, sizeof(*key)); @@ -1084,7 +1084,7 @@ static bool openssh_pem_write( fclose(fp); ret = true; - error: + error: if (outblob) strbuf_free(outblob); if (spareblob) { @@ -1298,7 +1298,7 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, if (errmsg_p) *errmsg_p = NULL; return ret; - error: + error: if (line) { smemclr(line, strlen(line)); sfree(line); @@ -1488,7 +1488,7 @@ static ssh2_userkey *openssh_new_read( retval = retkey; retkey = NULL; /* prevent the free */ - error: + error: if (retkey) { sfree(retkey->comment); if (retkey->key) @@ -1619,7 +1619,7 @@ static bool openssh_new_write( fclose(fp); ret = true; - error: + error: if (cblob) strbuf_free(cblob); if (privblob) @@ -1854,7 +1854,7 @@ static struct sshcom_key *load_sshcom_key(BinarySource *src, if (errmsg_p) *errmsg_p = NULL; return ret; - error: + error: if (line) { smemclr(line, strlen(line)); sfree(line); @@ -1892,7 +1892,7 @@ static bool sshcom_encrypted(BinarySource *filesrc, char **comment) if (!ptrlen_eq_string(str, "none")) answer = true; - done: + done: if (key) { *comment = dupstr(key->comment); strbuf_free(key->keyblob); @@ -2143,7 +2143,7 @@ static ssh2_userkey *sshcom_read( errmsg = NULL; /* no error */ ret = retkey; - error: + error: if (blob) { strbuf_free(blob); } @@ -2322,7 +2322,7 @@ static bool sshcom_write( fclose(fp); ret = true; - error: + error: if (outblob) strbuf_free(outblob); if (privblob) diff --git a/ldisc.c b/ldisc.c index f0e59658..caff52d0 100644 --- a/ldisc.c +++ b/ldisc.c @@ -522,7 +522,7 @@ void ldisc_send(Ldisc *ldisc, const void *vbuf, int len, bool interactive) } /* FALLTHROUGH */ default: /* get to this label from ^V handler */ - default_case: + default_case: sgrowarray(ldisc->buf, ldisc->bufsiz, ldisc->buflen); ldisc->buf[ldisc->buflen++] = c; if (ECHOING) diff --git a/otherbackends/supdup.c b/otherbackends/supdup.c index 54cfbef9..3479f0f9 100644 --- a/otherbackends/supdup.c +++ b/otherbackends/supdup.c @@ -202,49 +202,49 @@ static void do_toplevel(Supdup *supdup, strbuf *outbuf, int c) supdup->td_argindex = 0; supdup->td_code = c; switch (c) { - case TDMOV: + case TDMOV: // %TD codes using 4 arguments supdup->td_argcount = 4; supdup->tdstate = TD_ARGS; break; - case TDMV0: - case TDMV1: + case TDMV0: + case TDMV1: // %TD codes using 2 arguments supdup->td_argcount = 2; supdup->tdstate = TD_ARGS; break; - case TDQOT: - case TDILP: - case TDDLP: - case TDICP: - case TDDCP: + case TDQOT: + case TDILP: + case TDDLP: + case TDICP: + case TDDCP: // %TD codes using 1 argument supdup->td_argcount = 1; supdup->tdstate = TD_ARGS; break; - case TDEOF: - case TDEOL: - case TDDLF: - case TDCRL: - case TDNOP: - case TDORS: - case TDFS: - case TDCLR: - case TDBEL: - case TDBOW: - case TDRST: - case TDBS: - case TDCR: - case TDLF: + case TDEOF: + case TDEOL: + case TDDLF: + case TDCRL: + case TDNOP: + case TDORS: + case TDFS: + case TDCLR: + case TDBEL: + case TDBOW: + case TDRST: + case TDBS: + case TDCR: + case TDLF: // %TD codes using 0 arguments supdup->td_argcount = 0; supdup->tdstate = TD_ARGSDONE; break; - default: + default: // Unhandled, ignore break; } @@ -279,7 +279,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) // Arguments for %TD code have been collected; dispatch based // on the %TD code we're handling. switch (supdup->td_code) { - case TDMOV: + case TDMOV: /* General cursor position code. Followed by four bytes; the first two are the "old" vertical and horizontal @@ -292,8 +292,8 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[%d;%dH", supdup->td_args[2]+1, supdup->td_args[3]+1); break; - case TDMV0: - case TDMV1: + case TDMV0: + case TDMV1: /* General cursor position code. Followed by two bytes; the new vertical and horizontal positions. @@ -301,7 +301,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[%d;%dH", supdup->td_args[0]+1, supdup->td_args[1]+1); break; - case TDEOF: + case TDEOF: /* Erase to end of screen. This is an optional function since many terminals do not support this. If the @@ -315,7 +315,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[J"); break; - case TDEOL: + case TDEOL: /* Erase to end of line. This erases the character position the cursor is at and all positions to the right @@ -324,7 +324,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[K"); break; - case TDDLF: + case TDDLF: /* Clear the character position the cursor is on. The cursor does not move. @@ -332,7 +332,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[X"); break; - case TDCRL: + case TDCRL: /* If the cursor is not on the bottom line of the screen, move cursor to the beginning of the next line and clear @@ -342,13 +342,13 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\015\012"); break; - case TDNOP: + case TDNOP: /* No-op; should be ignored. */ break; - case TDORS: + case TDORS: /* Output reset. This code serves as a data mark for aborting output much as IAC DM does in the ordinary @@ -364,7 +364,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) sk_write(supdup->s, buf, 4); break; - case TDQOT: + case TDQOT: /* Quotes the following character. This is used when sending 8-bit codes which are not %TD codes, for @@ -376,7 +376,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_byte(outbuf, supdup->td_args[0]); break; - case TDFS: + case TDFS: /* Non-destructive forward space. The cursor moves right one position; this code will not be sent at the end of a @@ -386,7 +386,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[C"); break; - case TDCLR: + case TDCLR: /* Erase the screen. Home the cursor to the top left hand corner of the screen. @@ -394,7 +394,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[2J\033[H"); break; - case TDBEL: + case TDBEL: /* Generate an audio tone, bell, whatever. */ @@ -402,7 +402,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\007"); break; - case TDILP: + case TDILP: /* Insert blank lines at the cursor; followed by a byte containing a count of the number of blank lines to @@ -413,7 +413,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[%dL", supdup->td_args[0]); break; - case TDDLP: + case TDDLP: /* Delete lines at the cursor; followed by a count. The cursor is unmoved. The first line deleted is the one @@ -424,7 +424,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[%dM", supdup->td_args[0]); break; - case TDICP: + case TDICP: /* Insert blank character positions at the cursor; followed by a count. The cursor is unmoved. The character the @@ -435,7 +435,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[%d@", supdup->td_args[0]); break; - case TDDCP: + case TDDCP: /* Delete characters at the cursor; followed by a count. The cursor is unmoved. The first character deleted is @@ -445,8 +445,8 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_fmt(outbuf, "\033[%dP", supdup->td_args[0]); break; - case TDBOW: - case TDRST: + case TDBOW: + case TDRST: /* Display black characters on white screen. HIGHLY OPTIONAL. @@ -463,7 +463,7 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) * official documentation, behavior is based on UNIX * SUPDUP implementation from MIT. */ - case TDBS: + case TDBS: /* * Backspace -- move cursor back one character (does not * appear to wrap...) @@ -471,14 +471,14 @@ static void do_argsdone(Supdup *supdup, strbuf *outbuf, int c) put_byte(outbuf, '\010'); break; - case TDLF: + case TDLF: /* * Linefeed -- move cursor down one line (again, no wrapping) */ put_byte(outbuf, '\012'); break; - case TDCR: + case TDCR: /* * Carriage return -- move cursor to start of current line. */ @@ -512,7 +512,7 @@ static void do_supdup_read(Supdup *supdup, const char *buf, size_t len) while (len--) { int c = (unsigned char)*buf++; switch (supdup->state) { - case CONNECTING: + case CONNECTING: // "Following the transmission of the terminal options by // the user, the server should respond with an ASCII // greeting message, terminated with a %TDNOP code..." @@ -528,7 +528,7 @@ static void do_supdup_read(Supdup *supdup, const char *buf, size_t len) } break; - case CONNECTED: + case CONNECTED: // "All transmissions from the server after the %TDNOP // [see above] are either printing characters or virtual // terminal display codes." Forward these on to the diff --git a/unix/agent-client.c b/unix/agent-client.c index e4d671d2..6d7a3662 100644 --- a/unix/agent-client.c +++ b/unix/agent-client.c @@ -219,7 +219,7 @@ agent_pending_query *agent_query( uxsel_set(sock, SELECT_R, agent_select_result); return conn; - failure: + failure: *out = NULL; *outlen = 0; return NULL; diff --git a/unix/network.c b/unix/network.c index e95af9f7..31c754bd 100644 --- a/unix/network.c +++ b/unix/network.c @@ -731,7 +731,7 @@ static int try_connect(NetSocket *sock) uxsel_tell(sock); - ret: + ret: /* * No matter what happened, put the socket back in the tree. @@ -1043,7 +1043,7 @@ void *sk_getxdmdata(Socket *sock, int *lenp) PUT_16BIT_MSB_FIRST(buf+4, ntohs(u.sin.sin_port)); break; #ifndef NO_IPV6 - case AF_INET6: + case AF_INET6: *lenp = 6; buf = snewn(*lenp, char); if (IN6_IS_ADDR_V4MAPPED(&u.sin6.sin6_addr)) { diff --git a/unix/pty.c b/unix/pty.c index 625f1bb1..05c58929 100644 --- a/unix/pty.c +++ b/unix/pty.c @@ -354,7 +354,7 @@ static void pty_open_master(Pty *pty) fprintf(stderr, "pterm: unable to open a pseudo-terminal device\n"); exit(1); - got_one: + got_one: /* We need to chown/chmod the /dev/ttyXX device. */ gp = getgrnam("tty"); diff --git a/unix/sftp.c b/unix/sftp.c index 9d099f55..023f41ee 100644 --- a/unix/sftp.c +++ b/unix/sftp.c @@ -265,16 +265,16 @@ int seek_file(WFile *f, uint64_t offset, int whence) int lseek_whence; switch (whence) { - case FROM_START: + case FROM_START: lseek_whence = SEEK_SET; break; - case FROM_CURRENT: + case FROM_CURRENT: lseek_whence = SEEK_CUR; break; - case FROM_END: + case FROM_END: lseek_whence = SEEK_END; break; - default: + default: return -1; } diff --git a/unix/storage.c b/unix/storage.c index 83e1c19c..a2456fc4 100644 --- a/unix/storage.c +++ b/unix/storage.c @@ -806,7 +806,7 @@ int check_stored_host_key(const char *hostname, int port, else ret = 2; /* key mismatch */ - done: + done: sfree(line); if (ret != 1) break; diff --git a/unix/window.c b/unix/window.c index d1c4bfff..d35b1106 100644 --- a/unix/window.c +++ b/unix/window.c @@ -1978,7 +1978,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data) goto done; } - done: + done: if (end-start > 0) { if (special) { diff --git a/windows/network.c b/windows/network.c index 72afbe37..d0ad14a9 100644 --- a/windows/network.c +++ b/windows/network.c @@ -1068,7 +1068,7 @@ static DWORD try_connect(NetSocket *sock) err = 0; - ret: + ret: /* * No matter what happened, put the socket back in the tree. diff --git a/windows/printing.c b/windows/printing.c index 0ec81376..2286c236 100644 --- a/windows/printing.c +++ b/windows/printing.c @@ -131,7 +131,7 @@ printer_enum *printer_start_enum(int *nprinters_ptr) return ret; - error: + error: sfree(buffer); sfree(ret); *nprinters_ptr = 0; @@ -195,7 +195,7 @@ printer_job *printer_start_job(char *printer) return ret; - error: + error: if (pagestarted) p_EndPagePrinter(ret->hprinter); if (jobstarted) diff --git a/windows/sftp.c b/windows/sftp.c index fc8e711b..a6546269 100644 --- a/windows/sftp.c +++ b/windows/sftp.c @@ -222,16 +222,16 @@ int seek_file(WFile *f, uint64_t offset, int whence) DWORD movemethod; switch (whence) { - case FROM_START: + case FROM_START: movemethod = FILE_BEGIN; break; - case FROM_CURRENT: + case FROM_CURRENT: movemethod = FILE_CURRENT; break; - case FROM_END: + case FROM_END: movemethod = FILE_END; break; - default: + default: return -1; } diff --git a/windows/utils/security.c b/windows/utils/security.c index 14e55090..48330437 100644 --- a/windows/utils/security.c +++ b/windows/utils/security.c @@ -155,7 +155,7 @@ static bool getsids(char **error) ret = true; - cleanup: + cleanup: return ret; } diff --git a/windows/window.c b/windows/window.c index ee6ed580..6be9cbe5 100644 --- a/windows/window.c +++ b/windows/window.c @@ -892,7 +892,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) run_toplevel_callbacks(); } - finished: + finished: cleanup_exit(msg.wParam); /* this doesn't return... */ return msg.wParam; /* ... but optimiser doesn't know */ }