diff --git a/crypto/rsa.c b/crypto/rsa.c index aa0e08a6..b92fbeaf 100644 --- a/crypto/rsa.c +++ b/crypto/rsa.c @@ -340,11 +340,11 @@ char *rsa_ssh1_fingerprint(RSAKey *key) */ char **rsa_ssh1_fake_all_fingerprints(RSAKey *key) { - char **ret = snewn(SSH_N_FPTYPES, char *); + char **fingerprints = snewn(SSH_N_FPTYPES, char *); for (unsigned i = 0; i < SSH_N_FPTYPES; i++) - ret[i] = NULL; - ret[SSH_FPTYPE_MD5] = rsa_ssh1_fingerprint(key); - return ret; + fingerprints[i] = NULL; + fingerprints[SSH_FPTYPE_MD5] = rsa_ssh1_fingerprint(key); + return fingerprints; } /* diff --git a/dialog.c b/dialog.c index b9306982..88173aee 100644 --- a/dialog.c +++ b/dialog.c @@ -41,15 +41,15 @@ int ctrl_path_compare(const char *p1, const char *p2) struct controlbox *ctrl_new_box(void) { - struct controlbox *ret = snew(struct controlbox); + struct controlbox *b = snew(struct controlbox); - ret->nctrlsets = ret->ctrlsetsize = 0; - ret->ctrlsets = NULL; - ret->nfrees = ret->freesize = 0; - ret->frees = NULL; - ret->freefuncs = NULL; + b->nctrlsets = b->ctrlsetsize = 0; + b->ctrlsets = NULL; + b->nfrees = b->freesize = 0; + b->frees = NULL; + b->freefuncs = NULL; - return ret; + return b; } void ctrl_free_box(struct controlbox *b) diff --git a/import.c b/import.c index 918de50e..8e901bb5 100644 --- a/import.c +++ b/import.c @@ -339,7 +339,7 @@ static void BinarySink_put_mp_ssh2_from_string(BinarySink *bs, ptrlen str) static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, const char **errmsg_p) { - struct openssh_pem_key *ret; + struct openssh_pem_key *key; char *line = NULL; const char *errmsg; char *p; @@ -347,8 +347,8 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, char base64_bit[4]; int base64_chars = 0; - ret = snew(struct openssh_pem_key); - ret->keyblob = strbuf_new_nm(); + key = snew(struct openssh_pem_key); + key->keyblob = strbuf_new_nm(); if (!(line = bsgetline(src))) { errmsg = "unexpected end of file"; @@ -366,11 +366,11 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, * base64. */ if (!strcmp(line, "-----BEGIN RSA PRIVATE KEY-----")) { - ret->keytype = OP_RSA; + key->keytype = OP_RSA; } else if (!strcmp(line, "-----BEGIN DSA PRIVATE KEY-----")) { - ret->keytype = OP_DSA; + key->keytype = OP_DSA; } else if (!strcmp(line, "-----BEGIN EC PRIVATE KEY-----")) { - ret->keytype = OP_ECDSA; + key->keytype = OP_ECDSA; } else if (!strcmp(line, "-----BEGIN OPENSSH PRIVATE KEY-----")) { errmsg = "this is a new-style OpenSSH key"; goto error; @@ -382,8 +382,8 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, sfree(line); line = NULL; - ret->encrypted = false; - memset(ret->iv, 0, sizeof(ret->iv)); + key->encrypted = false; + memset(key->iv, 0, sizeof(key->iv)); headers_done = false; while (1) { @@ -411,15 +411,15 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, } p += 2; if (!strcmp(p, "ENCRYPTED")) - ret->encrypted = true; + key->encrypted = true; } else if (!strcmp(line, "DEK-Info")) { int i, ivlen; if (!strncmp(p, "DES-EDE3-CBC,", 13)) { - ret->encryption = OP_E_3DES; + key->encryption = OP_E_3DES; ivlen = 8; } else if (!strncmp(p, "AES-128-CBC,", 12)) { - ret->encryption = OP_E_AES; + key->encryption = OP_E_AES; ivlen = 16; } else { errmsg = "unsupported cipher"; @@ -432,7 +432,7 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, errmsg = "expected more iv data in DEK-Info"; goto error; } - ret->iv[i] = j; + key->iv[i] = j; p += 2; } if (*p) { @@ -459,7 +459,7 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, goto error; } - put_data(ret->keyblob, out, len); + put_data(key->keyblob, out, len); smemclr(out, sizeof(out)); } @@ -472,12 +472,12 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, line = NULL; } - if (!ret->keyblob || ret->keyblob->len == 0) { + if (!key->keyblob || key->keyblob->len == 0) { errmsg = "key body not present"; goto error; } - if (ret->encrypted && ret->keyblob->len % 8 != 0) { + if (key->encrypted && key->keyblob->len % 8 != 0) { errmsg = "encrypted key blob is not a multiple of " "cipher block size"; goto error; @@ -485,7 +485,7 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, smemclr(base64_bit, sizeof(base64_bit)); if (errmsg_p) *errmsg_p = NULL; - return ret; + return key; error: if (line) { @@ -494,11 +494,11 @@ static struct openssh_pem_key *load_openssh_pem_key(BinarySource *src, line = NULL; } smemclr(base64_bit, sizeof(base64_bit)); - if (ret) { - if (ret->keyblob) - strbuf_free(ret->keyblob); - smemclr(ret, sizeof(*ret)); - sfree(ret); + if (key) { + if (key->keyblob) + strbuf_free(key->keyblob); + smemclr(key, sizeof(*key)); + sfree(key); } if (errmsg_p) *errmsg_p = errmsg; return NULL; @@ -1119,7 +1119,7 @@ struct openssh_new_key { static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, const char **errmsg_p) { - struct openssh_new_key *ret; + struct openssh_new_key *key; char *line = NULL; const char *errmsg; char *p; @@ -1129,8 +1129,8 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, ptrlen str; unsigned key_index; - ret = snew(struct openssh_new_key); - ret->keyblob = strbuf_new_nm(); + key = snew(struct openssh_new_key); + key->keyblob = strbuf_new_nm(); if (!(line = bsgetline(filesrc))) { errmsg = "unexpected end of file"; @@ -1171,7 +1171,7 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, goto error; } - put_data(ret->keyblob, out, len); + put_data(key->keyblob, out, len); smemclr(out, sizeof(out)); } @@ -1183,12 +1183,12 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, line = NULL; } - if (ret->keyblob->len == 0) { + if (key->keyblob->len == 0) { errmsg = "key body not present"; goto error; } - BinarySource_BARE_INIT_PL(src, ptrlen_from_strbuf(ret->keyblob)); + BinarySource_BARE_INIT_PL(src, ptrlen_from_strbuf(key->keyblob)); if (strcmp(get_asciz(src), "openssh-key-v1") != 0) { errmsg = "new-style OpenSSH magic number missing\n"; @@ -1198,11 +1198,11 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, /* Cipher name */ str = get_string(src); if (ptrlen_eq_string(str, "none")) { - ret->cipher = ON_E_NONE; + key->cipher = ON_E_NONE; } else if (ptrlen_eq_string(str, "aes256-cbc")) { - ret->cipher = ON_E_AES256CBC; + key->cipher = ON_E_AES256CBC; } else if (ptrlen_eq_string(str, "aes256-ctr")) { - ret->cipher = ON_E_AES256CTR; + key->cipher = ON_E_AES256CTR; } else { errmsg = get_err(src) ? "no cipher name found" : "unrecognised cipher name\n"; @@ -1212,9 +1212,9 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, /* Key derivation function name */ str = get_string(src); if (ptrlen_eq_string(str, "none")) { - ret->kdf = ON_K_NONE; + key->kdf = ON_K_NONE; } else if (ptrlen_eq_string(str, "bcrypt")) { - ret->kdf = ON_K_BCRYPT; + key->kdf = ON_K_BCRYPT; } else { errmsg = get_err(src) ? "no kdf name found" : "unrecognised kdf name\n"; @@ -1223,7 +1223,7 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, /* KDF extra options */ str = get_string(src); - switch (ret->kdf) { + switch (key->kdf) { case ON_K_NONE: if (str.len != 0) { errmsg = "expected empty options string for 'none' kdf"; @@ -1234,8 +1234,8 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, BinarySource opts[1]; BinarySource_BARE_INIT_PL(opts, str); - ret->kdfopts.bcrypt.salt = get_string(opts); - ret->kdfopts.bcrypt.rounds = get_uint32(opts); + key->kdfopts.bcrypt.salt = get_string(opts); + key->kdfopts.bcrypt.rounds = get_uint32(opts); if (get_err(opts)) { errmsg = "failed to parse bcrypt options string"; @@ -1257,23 +1257,23 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, * 'key_wanted' field is set to a value in the range [0, * nkeys) by some mechanism. */ - ret->nkeys = toint(get_uint32(src)); - if (ret->nkeys != 1) { + key->nkeys = toint(get_uint32(src)); + if (key->nkeys != 1) { errmsg = get_err(src) ? "no key count found" : "multiple keys in new-style OpenSSH key file not supported\n"; goto error; } - ret->key_wanted = 0; + key->key_wanted = 0; /* Read and ignore a string per public key. */ - for (key_index = 0; key_index < ret->nkeys; key_index++) + for (key_index = 0; key_index < key->nkeys; key_index++) str = get_string(src); /* * Now we expect a string containing the encrypted part of the * key file. */ - ret->private = get_string(src); + key->private = get_string(src); if (get_err(src)) { errmsg = "no private key container string found\n"; goto error; @@ -1285,7 +1285,7 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, smemclr(base64_bit, sizeof(base64_bit)); if (errmsg_p) *errmsg_p = NULL; - return ret; + return key; error: if (line) { @@ -1294,10 +1294,10 @@ static struct openssh_new_key *load_openssh_new_key(BinarySource *filesrc, line = NULL; } smemclr(base64_bit, sizeof(base64_bit)); - if (ret) { - strbuf_free(ret->keyblob); - smemclr(ret, sizeof(*ret)); - sfree(ret); + if (key) { + strbuf_free(key->keyblob); + smemclr(key, sizeof(*key)); + sfree(key); } if (errmsg_p) *errmsg_p = errmsg; return NULL; @@ -1725,7 +1725,7 @@ struct sshcom_key { static struct sshcom_key *load_sshcom_key(BinarySource *src, const char **errmsg_p) { - struct sshcom_key *ret; + struct sshcom_key *key; char *line = NULL; int hdrstart, len; const char *errmsg; @@ -1734,9 +1734,9 @@ static struct sshcom_key *load_sshcom_key(BinarySource *src, char base64_bit[4]; int base64_chars = 0; - ret = snew(struct sshcom_key); - ret->comment[0] = '\0'; - ret->keyblob = strbuf_new_nm(); + key = snew(struct sshcom_key); + key->comment[0] = '\0'; + key->keyblob = strbuf_new_nm(); if (!(line = bsgetline(src))) { errmsg = "unexpected end of file"; @@ -1803,8 +1803,8 @@ static struct sshcom_key *load_sshcom_key(BinarySource *src, p++; p[strlen(p)-1] = '\0'; } - strncpy(ret->comment, p, sizeof(ret->comment)); - ret->comment[sizeof(ret->comment)-1] = '\0'; + strncpy(key->comment, p, sizeof(key->comment)); + key->comment[sizeof(key->comment)-1] = '\0'; } } else { headers_done = true; @@ -1824,7 +1824,7 @@ static struct sshcom_key *load_sshcom_key(BinarySource *src, goto error; } - put_data(ret->keyblob, out, len); + put_data(key->keyblob, out, len); } p++; @@ -1835,13 +1835,13 @@ static struct sshcom_key *load_sshcom_key(BinarySource *src, line = NULL; } - if (ret->keyblob->len == 0) { + if (key->keyblob->len == 0) { errmsg = "key body not present"; goto error; } if (errmsg_p) *errmsg_p = NULL; - return ret; + return key; error: if (line) { @@ -1849,10 +1849,10 @@ static struct sshcom_key *load_sshcom_key(BinarySource *src, sfree(line); line = NULL; } - if (ret) { - strbuf_free(ret->keyblob); - smemclr(ret, sizeof(*ret)); - sfree(ret); + if (key) { + strbuf_free(key->keyblob); + smemclr(key, sizeof(*key)); + sfree(key); } if (errmsg_p) *errmsg_p = errmsg; return NULL; diff --git a/pageant.c b/pageant.c index 455e434f..6cd1120b 100644 --- a/pageant.c +++ b/pageant.c @@ -2673,14 +2673,14 @@ int pageant_sign(struct pageant_pubkey *key, ptrlen message, strbuf *out, } } -struct pageant_pubkey *pageant_pubkey_copy(struct pageant_pubkey *key) +struct pageant_pubkey *pageant_pubkey_copy(struct pageant_pubkey *orig) { - struct pageant_pubkey *ret = snew(struct pageant_pubkey); - ret->blob = strbuf_new(); - put_data(ret->blob, key->blob->s, key->blob->len); - ret->comment = key->comment ? dupstr(key->comment) : NULL; - ret->ssh_version = key->ssh_version; - return ret; + struct pageant_pubkey *copy = snew(struct pageant_pubkey); + copy->blob = strbuf_new(); + put_data(copy->blob, orig->blob->s, orig->blob->len); + copy->comment = orig->comment ? dupstr(orig->comment) : NULL; + copy->ssh_version = orig->ssh_version; + return copy; } void pageant_pubkey_free(struct pageant_pubkey *key) diff --git a/ssh/crc-attack-detector.c b/ssh/crc-attack-detector.c index 18044754..58e4e99b 100644 --- a/ssh/crc-attack-detector.c +++ b/ssh/crc-attack-detector.c @@ -54,10 +54,10 @@ struct crcda_ctx { struct crcda_ctx *crcda_make_context(void) { - struct crcda_ctx *ret = snew(struct crcda_ctx); - ret->h = NULL; - ret->n = HASH_MINSIZE / HASH_ENTRYSIZE; - return ret; + struct crcda_ctx *ctx = snew(struct crcda_ctx); + ctx->h = NULL; + ctx->n = HASH_MINSIZE / HASH_ENTRYSIZE; + return ctx; } void crcda_free_context(struct crcda_ctx *ctx) diff --git a/ssh/sftp.c b/ssh/sftp.c index 1f98c5ec..09d173bb 100644 --- a/ssh/sftp.c +++ b/ssh/sftp.c @@ -736,7 +736,7 @@ struct fxp_names *fxp_readdir_recv(struct sftp_packet *pktin, { sfree(req); if (pktin->type == SSH_FXP_NAME) { - struct fxp_names *ret; + struct fxp_names *names; unsigned long i; i = get_uint32(pktin); @@ -766,28 +766,28 @@ struct fxp_names *fxp_readdir_recv(struct sftp_packet *pktin, return NULL; } - ret = snew(struct fxp_names); - ret->nnames = i; - ret->names = snewn(ret->nnames, struct fxp_name); - for (i = 0; i < (unsigned long)ret->nnames; i++) { - ret->names[i].filename = mkstr(get_string(pktin)); - ret->names[i].longname = mkstr(get_string(pktin)); - get_fxp_attrs(pktin, &ret->names[i].attrs); + names = snew(struct fxp_names); + names->nnames = i; + names->names = snewn(names->nnames, struct fxp_name); + for (i = 0; i < (unsigned long)names->nnames; i++) { + names->names[i].filename = mkstr(get_string(pktin)); + names->names[i].longname = mkstr(get_string(pktin)); + get_fxp_attrs(pktin, &names->names[i].attrs); } if (get_err(pktin)) { fxp_internal_error("malformed FXP_NAME packet"); - for (i = 0; i < (unsigned long)ret->nnames; i++) { - sfree(ret->names[i].filename); - sfree(ret->names[i].longname); + for (i = 0; i < (unsigned long)names->nnames; i++) { + sfree(names->names[i].filename); + sfree(names->names[i].longname); } - sfree(ret->names); - sfree(ret); + sfree(names->names); + sfree(names); sfree(pktin); return NULL; } sftp_pkt_free(pktin); - return ret; + return names; } else { fxp_got_status(pktin); sftp_pkt_free(pktin); @@ -840,14 +840,14 @@ void fxp_free_names(struct fxp_names *names) /* * Duplicate an fxp_name structure. */ -struct fxp_name *fxp_dup_name(struct fxp_name *name) +struct fxp_name *fxp_dup_name(struct fxp_name *orig) { - struct fxp_name *ret; - ret = snew(struct fxp_name); - ret->filename = dupstr(name->filename); - ret->longname = dupstr(name->longname); - ret->attrs = name->attrs; /* structure copy */ - return ret; + struct fxp_name *copy; + copy = snew(struct fxp_name); + copy->filename = dupstr(orig->filename); + copy->longname = dupstr(orig->longname); + copy->attrs = orig->attrs; /* structure copy */ + return copy; } /* diff --git a/sshpubk.c b/sshpubk.c index 0648b4c4..bcc204ac 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -713,7 +713,7 @@ ssh2_userkey *ppk_load_s(BinarySource *src, const char *passphrase, { char header[40], *b, *encryption, *comment, *mac; const ssh_keyalg *alg; - ssh2_userkey *ret; + ssh2_userkey *ukey; strbuf *public_blob, *private_blob, *cipher_mac_keys_blob; strbuf *passphrase_salt = strbuf_new(); ptrlen cipherkey, cipheriv, mackey; @@ -724,7 +724,7 @@ ssh2_userkey *ppk_load_s(BinarySource *src, const char *passphrase, const char *error = NULL; ppk_save_parameters params; - ret = NULL; /* return NULL for most errors */ + ukey = NULL; /* return NULL for most errors */ encryption = comment = mac = NULL; public_blob = private_blob = cipher_mac_keys_blob = NULL; @@ -960,10 +960,10 @@ ssh2_userkey *ppk_load_s(BinarySource *src, const char *passphrase, * unencrypted. Otherwise, it means Wrong Passphrase. */ if (ciphertype->keylen != 0) { error = "wrong passphrase"; - ret = SSH2_WRONG_PASSPHRASE; + ukey = SSH2_WRONG_PASSPHRASE; } else { error = "MAC failed"; - ret = NULL; + ukey = NULL; } goto error; } @@ -972,15 +972,15 @@ ssh2_userkey *ppk_load_s(BinarySource *src, const char *passphrase, /* * Create and return the key. */ - ret = snew(ssh2_userkey); - ret->comment = comment; + ukey = snew(ssh2_userkey); + ukey->comment = comment; comment = NULL; - ret->key = ssh_key_new_priv( + ukey->key = ssh_key_new_priv( alg, ptrlen_from_strbuf(public_blob), ptrlen_from_strbuf(private_blob)); - if (!ret->key) { - sfree(ret); - ret = NULL; + if (!ukey->key) { + sfree(ukey); + ukey = NULL; error = "createkey failed"; goto error; } @@ -1005,7 +1005,7 @@ ssh2_userkey *ppk_load_s(BinarySource *src, const char *passphrase, strbuf_free(passphrase_salt); if (errorstr) *errorstr = error; - return ret; + return ukey; } ssh2_userkey *ppk_load_f(const Filename *filename, const char *passphrase, diff --git a/unix/network.c b/unix/network.c index 31c754bd..207047db 100644 --- a/unix/network.c +++ b/unix/network.c @@ -271,18 +271,18 @@ SockAddr *sk_namelookup(const char *host, char **canonicalname, SockAddr *sk_nonamelookup(const char *host) { - SockAddr *ret = snew(SockAddr); - ret->error = NULL; - ret->superfamily = UNRESOLVED; - strncpy(ret->hostname, host, lenof(ret->hostname)); - ret->hostname[lenof(ret->hostname)-1] = '\0'; + SockAddr *addr = snew(SockAddr); + addr->error = NULL; + addr->superfamily = UNRESOLVED; + strncpy(addr->hostname, host, lenof(addr->hostname)); + addr->hostname[lenof(addr->hostname)-1] = '\0'; #ifndef NO_IPV6 - ret->ais = NULL; + addr->ais = NULL; #else ret->addresses = NULL; #endif - ret->refcount = 1; - return ret; + addr->refcount = 1; + return addr; } static bool sk_nextaddr(SockAddr *addr, SockAddrStep *step) @@ -505,42 +505,42 @@ static const SocketVtable NetSocket_sockvt = { static Socket *sk_net_accept(accept_ctx_t ctx, Plug *plug) { int sockfd = ctx.i; - NetSocket *ret; + NetSocket *s; /* * Create NetSocket structure. */ - ret = snew(NetSocket); - ret->sock.vt = &NetSocket_sockvt; - ret->error = NULL; - ret->plug = plug; - bufchain_init(&ret->output_data); - ret->writable = true; /* to start with */ - ret->sending_oob = 0; - ret->frozen = true; - ret->localhost_only = false; /* unused, but best init anyway */ - ret->pending_error = 0; - ret->oobpending = false; - ret->outgoingeof = EOF_NO; - ret->incomingeof = false; - ret->listener = false; - ret->parent = ret->child = NULL; - ret->addr = NULL; - ret->connected = true; + s = snew(NetSocket); + s->sock.vt = &NetSocket_sockvt; + s->error = NULL; + s->plug = plug; + bufchain_init(&s->output_data); + s->writable = true; /* to start with */ + s->sending_oob = 0; + s->frozen = true; + s->localhost_only = false; /* unused, but best init anyway */ + s->pending_error = 0; + s->oobpending = false; + s->outgoingeof = EOF_NO; + s->incomingeof = false; + s->listener = false; + s->parent = s->child = NULL; + s->addr = NULL; + s->connected = true; - ret->s = sockfd; + s->s = sockfd; - if (ret->s < 0) { - ret->error = strerror(errno); - return &ret->sock; + if (s->s < 0) { + s->error = strerror(errno); + return &s->sock; } - ret->oobinline = false; + s->oobinline = false; - uxsel_tell(ret); - add234(sktree, ret); + uxsel_tell(s); + add234(sktree, s); - return &ret->sock; + return &s->sock; } static int try_connect(NetSocket *sock) @@ -750,51 +750,51 @@ static int try_connect(NetSocket *sock) Socket *sk_new(SockAddr *addr, int port, bool privport, bool oobinline, bool nodelay, bool keepalive, Plug *plug) { - NetSocket *ret; + NetSocket *s; int err; /* * Create NetSocket structure. */ - ret = snew(NetSocket); - ret->sock.vt = &NetSocket_sockvt; - ret->error = NULL; - ret->plug = plug; - bufchain_init(&ret->output_data); - ret->connected = false; /* to start with */ - ret->writable = false; /* to start with */ - ret->sending_oob = 0; - ret->frozen = false; - ret->localhost_only = false; /* unused, but best init anyway */ - ret->pending_error = 0; - ret->parent = ret->child = NULL; - ret->oobpending = false; - ret->outgoingeof = EOF_NO; - ret->incomingeof = false; - ret->listener = false; - ret->addr = addr; - START_STEP(ret->addr, ret->step); - ret->s = -1; - ret->oobinline = oobinline; - ret->nodelay = nodelay; - ret->keepalive = keepalive; - ret->privport = privport; - ret->port = port; + s = snew(NetSocket); + s->sock.vt = &NetSocket_sockvt; + s->error = NULL; + s->plug = plug; + bufchain_init(&s->output_data); + s->connected = false; /* to start with */ + s->writable = false; /* to start with */ + s->sending_oob = 0; + s->frozen = false; + s->localhost_only = false; /* unused, but best init anyway */ + s->pending_error = 0; + s->parent = s->child = NULL; + s->oobpending = false; + s->outgoingeof = EOF_NO; + s->incomingeof = false; + s->listener = false; + s->addr = addr; + START_STEP(s->addr, s->step); + s->s = -1; + s->oobinline = oobinline; + s->nodelay = nodelay; + s->keepalive = keepalive; + s->privport = privport; + s->port = port; do { - err = try_connect(ret); - } while (err && sk_nextaddr(ret->addr, &ret->step)); + err = try_connect(s); + } while (err && sk_nextaddr(s->addr, &s->step)); if (err) - ret->error = strerror(err); + s->error = strerror(err); - return &ret->sock; + return &s->sock; } Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug, bool local_host_only, int orig_address_family) { - int s; + int fd; #ifndef NO_IPV6 struct addrinfo hints, *ai = NULL; char portstr[6]; @@ -802,7 +802,7 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug, union sockaddr_union u; union sockaddr_union *addr; int addrlen; - NetSocket *ret; + NetSocket *s; int retcode; int address_family; int on = 1; @@ -810,23 +810,23 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug, /* * Create NetSocket structure. */ - ret = snew(NetSocket); - ret->sock.vt = &NetSocket_sockvt; - ret->error = NULL; - ret->plug = plug; - bufchain_init(&ret->output_data); - ret->writable = false; /* to start with */ - ret->sending_oob = 0; - ret->frozen = false; - ret->localhost_only = local_host_only; - ret->pending_error = 0; - ret->parent = ret->child = NULL; - ret->oobpending = false; - ret->outgoingeof = EOF_NO; - ret->incomingeof = false; - ret->listener = true; - ret->addr = NULL; - ret->s = -1; + s = snew(NetSocket); + s->sock.vt = &NetSocket_sockvt; + s->error = NULL; + s->plug = plug; + bufchain_init(&s->output_data); + s->writable = false; /* to start with */ + s->sending_oob = 0; + s->frozen = false; + s->localhost_only = local_host_only; + s->pending_error = 0; + s->parent = s->child = NULL; + s->oobpending = false; + s->outgoingeof = EOF_NO; + s->incomingeof = false; + s->listener = true; + s->addr = NULL; + s->s = -1; /* * Translate address_family from platform-independent constants @@ -850,30 +850,30 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug, /* * Open socket. */ - s = socket(address_family, SOCK_STREAM, 0); + fd = socket(address_family, SOCK_STREAM, 0); #ifndef NO_IPV6 /* If the host doesn't support IPv6 try fallback to IPv4. */ - if (s < 0 && address_family == AF_INET6) { + if (fd < 0 && address_family == AF_INET6) { address_family = AF_INET; - s = socket(address_family, SOCK_STREAM, 0); + fd = socket(address_family, SOCK_STREAM, 0); } #endif - if (s < 0) { - ret->error = strerror(errno); - return &ret->sock; + if (fd < 0) { + s->error = strerror(errno); + return &s->sock; } - cloexec(s); + cloexec(fd); - ret->oobinline = false; + s->oobinline = false; - if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on)) < 0) { - ret->error = strerror(errno); - close(s); - return &ret->sock; + s->error = strerror(errno); + close(fd); + return &s->sock; } retcode = -1; @@ -941,7 +941,7 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug, } } - retcode = bind(s, &addr->sa, addrlen); + retcode = bind(fd, &addr->sa, addrlen); #ifndef NO_IPV6 if (ai) @@ -949,15 +949,15 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug, #endif if (retcode < 0) { - close(s); - ret->error = strerror(errno); - return &ret->sock; + close(fd); + s->error = strerror(errno); + return &s->sock; } - if (listen(s, SOMAXCONN) < 0) { - close(s); - ret->error = strerror(errno); - return &ret->sock; + if (listen(fd, SOMAXCONN) < 0) { + close(fd); + s->error = strerror(errno); + return &s->sock; } #ifndef NO_IPV6 @@ -975,25 +975,25 @@ Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug, if (other) { if (!other->error) { - other->parent = ret; - ret->child = other; + other->parent = s; + s->child = other; } else { /* If we couldn't create a listening socket on IPv4 as well * as IPv6, we must return an error overall. */ - close(s); - sfree(ret); + close(fd); + sfree(s); return &other->sock; } } } #endif - ret->s = s; + s->s = fd; - uxsel_tell(ret); - add234(sktree, ret); + uxsel_tell(s); + add234(sktree, s); - return &ret->sock; + return &s->sock; } static void sk_net_close(Socket *sock) @@ -1612,107 +1612,107 @@ char *get_hostname(void) SockAddr *platform_get_x11_unix_address(const char *sockpath, int displaynum) { - SockAddr *ret = snew(SockAddr); + SockAddr *addr = snew(SockAddr); int n; - memset(ret, 0, sizeof *ret); - ret->superfamily = UNIX; + memset(addr, 0, sizeof *addr); + addr->superfamily = UNIX; /* * In special circumstances (notably Mac OS X Leopard), we'll * have been passed an explicit Unix socket path. */ if (sockpath) { - n = snprintf(ret->hostname, sizeof ret->hostname, + n = snprintf(addr->hostname, sizeof addr->hostname, "%s", sockpath); } else { - n = snprintf(ret->hostname, sizeof ret->hostname, + n = snprintf(addr->hostname, sizeof addr->hostname, "%s%d", X11_UNIX_PATH, displaynum); } if (n < 0) - ret->error = "snprintf failed"; - else if (n >= sizeof ret->hostname) - ret->error = "X11 UNIX name too long"; + addr->error = "snprintf failed"; + else if (n >= sizeof addr->hostname) + addr->error = "X11 UNIX name too long"; #ifndef NO_IPV6 - ret->ais = NULL; + addr->ais = NULL; #else ret->addresses = NULL; ret->naddresses = 0; #endif - ret->refcount = 1; - return ret; + addr->refcount = 1; + return addr; } SockAddr *unix_sock_addr(const char *path) { - SockAddr *ret = snew(SockAddr); + SockAddr *addr = snew(SockAddr); int n; - memset(ret, 0, sizeof *ret); - ret->superfamily = UNIX; - n = snprintf(ret->hostname, sizeof ret->hostname, "%s", path); + memset(addr, 0, sizeof *addr); + addr->superfamily = UNIX; + n = snprintf(addr->hostname, sizeof addr->hostname, "%s", path); if (n < 0) - ret->error = "snprintf failed"; - else if (n >= sizeof ret->hostname || + addr->error = "snprintf failed"; + else if (n >= sizeof addr->hostname || n >= sizeof(((struct sockaddr_un *)0)->sun_path)) - ret->error = "socket pathname too long"; + addr->error = "socket pathname too long"; #ifndef NO_IPV6 - ret->ais = NULL; + addr->ais = NULL; #else ret->addresses = NULL; ret->naddresses = 0; #endif - ret->refcount = 1; - return ret; + addr->refcount = 1; + return addr; } Socket *new_unix_listener(SockAddr *listenaddr, Plug *plug) { - int s; + int fd; union sockaddr_union u; union sockaddr_union *addr; int addrlen; - NetSocket *ret; + NetSocket *s; int retcode; /* * Create NetSocket structure. */ - ret = snew(NetSocket); - ret->sock.vt = &NetSocket_sockvt; - ret->error = NULL; - ret->plug = plug; - bufchain_init(&ret->output_data); - ret->writable = false; /* to start with */ - ret->sending_oob = 0; - ret->frozen = false; - ret->localhost_only = true; - ret->pending_error = 0; - ret->parent = ret->child = NULL; - ret->oobpending = false; - ret->outgoingeof = EOF_NO; - ret->incomingeof = false; - ret->listener = true; - ret->addr = listenaddr; - ret->s = -1; + s = snew(NetSocket); + s->sock.vt = &NetSocket_sockvt; + s->error = NULL; + s->plug = plug; + bufchain_init(&s->output_data); + s->writable = false; /* to start with */ + s->sending_oob = 0; + s->frozen = false; + s->localhost_only = true; + s->pending_error = 0; + s->parent = s->child = NULL; + s->oobpending = false; + s->outgoingeof = EOF_NO; + s->incomingeof = false; + s->listener = true; + s->addr = listenaddr; + s->s = -1; assert(listenaddr->superfamily == UNIX); /* * Open socket. */ - s = socket(AF_UNIX, SOCK_STREAM, 0); - if (s < 0) { - ret->error = strerror(errno); - return &ret->sock; + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { + s->error = strerror(errno); + return &s->sock; } - cloexec(s); + cloexec(fd); - ret->oobinline = false; + s->oobinline = false; memset(&u, '\0', sizeof(u)); u.su.sun_family = AF_UNIX; @@ -1728,28 +1728,28 @@ Socket *new_unix_listener(SockAddr *listenaddr, Plug *plug) addrlen = sizeof(u.su); if (unlink(u.su.sun_path) < 0 && errno != ENOENT) { - close(s); - ret->error = strerror(errno); - return &ret->sock; + close(fd); + s->error = strerror(errno); + return &s->sock; } - retcode = bind(s, &addr->sa, addrlen); + retcode = bind(fd, &addr->sa, addrlen); if (retcode < 0) { - close(s); - ret->error = strerror(errno); - return &ret->sock; + close(fd); + s->error = strerror(errno); + return &s->sock; } - if (listen(s, SOMAXCONN) < 0) { - close(s); - ret->error = strerror(errno); - return &ret->sock; + if (listen(fd, SOMAXCONN) < 0) { + close(fd); + s->error = strerror(errno); + return &s->sock; } - ret->s = s; + s->s = fd; - uxsel_tell(ret); - add234(sktree, ret); + uxsel_tell(s); + add234(sktree, s); - return &ret->sock; + return &s->sock; } diff --git a/unix/printing.c b/unix/printing.c index 416db396..7f26ce00 100644 --- a/unix/printing.c +++ b/unix/printing.c @@ -12,17 +12,17 @@ struct printer_job_tag { printer_job *printer_start_job(char *printer) { - printer_job *ret = snew(printer_job); + printer_job *pj = snew(printer_job); /* * On Unix, we treat the printer string as the name of a * command to pipe to - typically lpr, of course. */ - ret->fp = popen(printer, "w"); - if (!ret->fp) { - sfree(ret); - ret = NULL; + pj->fp = popen(printer, "w"); + if (!pj->fp) { + sfree(pj); + pj = NULL; } - return ret; + return pj; } void printer_job_data(printer_job *pj, const void *data, size_t len) diff --git a/unix/sftp.c b/unix/sftp.c index 023f41ee..dafd4fd9 100644 --- a/unix/sftp.c +++ b/unix/sftp.c @@ -125,14 +125,14 @@ RFile *open_existing_file(const char *name, uint64_t *size, long *perms) { int fd; - RFile *ret; + RFile *f; fd = open(name, O_RDONLY); if (fd < 0) return NULL; - ret = snew(RFile); - ret->fd = fd; + f = snew(RFile); + f->fd = fd; if (size || mtime || atime || perms) { struct stat statbuf; @@ -154,7 +154,7 @@ RFile *open_existing_file(const char *name, uint64_t *size, *perms = statbuf.st_mode; } - return ret; + return f; } int read_from_file(RFile *f, void *buffer, int length) @@ -176,33 +176,33 @@ struct WFile { WFile *open_new_file(const char *name, long perms) { int fd; - WFile *ret; + WFile *f; fd = open(name, O_CREAT | O_TRUNC | O_WRONLY, (mode_t)(perms ? perms : 0666)); if (fd < 0) return NULL; - ret = snew(WFile); - ret->fd = fd; - ret->name = dupstr(name); + f = snew(WFile); + f->fd = fd; + f->name = dupstr(name); - return ret; + return f; } WFile *open_existing_wfile(const char *name, uint64_t *size) { int fd; - WFile *ret; + WFile *f; fd = open(name, O_APPEND | O_WRONLY); if (fd < 0) return NULL; - ret = snew(WFile); - ret->fd = fd; - ret->name = dupstr(name); + f = snew(WFile); + f->fd = fd; + f->name = dupstr(name); if (size) { struct stat statbuf; @@ -214,7 +214,7 @@ WFile *open_existing_wfile(const char *name, uint64_t *size) *size = statbuf.st_size; } - return ret; + return f; } int write_to_file(WFile *f, void *buffer, int length) @@ -311,18 +311,15 @@ struct DirHandle { DirHandle *open_directory(const char *name, const char **errmsg) { - DIR *dir; - DirHandle *ret; - - dir = opendir(name); - if (!dir) { + DIR *dp = opendir(name); + if (!dp) { *errmsg = strerror(errno); return NULL; } - ret = snew(DirHandle); - ret->dir = dir; - return ret; + DirHandle *dir = snew(DirHandle); + dir->dir = dp; + return dir; } char *read_filename(DirHandle *dir) @@ -388,16 +385,16 @@ struct WildcardMatcher { int i; }; WildcardMatcher *begin_wildcard_matching(const char *name) { - WildcardMatcher *ret = snew(WildcardMatcher); + WildcardMatcher *dir = snew(WildcardMatcher); - if (glob(name, 0, NULL, &ret->globbed) < 0) { - sfree(ret); + if (glob(name, 0, NULL, &dir->globbed) < 0) { + sfree(dir); return NULL; } - ret->i = 0; + dir->i = 0; - return ret; + return dir; } char *wildcard_get_filename(WildcardMatcher *dir) { if (dir->i < dir->globbed.gl_pathc) { diff --git a/unix/utils/filename.c b/unix/utils/filename.c index 208483d2..e786b222 100644 --- a/unix/utils/filename.c +++ b/unix/utils/filename.c @@ -9,9 +9,9 @@ Filename *filename_from_str(const char *str) { - Filename *ret = snew(Filename); - ret->path = dupstr(str); - return ret; + Filename *fn = snew(Filename); + fn->path = dupstr(str); + return fn; } Filename *filename_copy(const Filename *fn) diff --git a/utils/tree234.c b/utils/tree234.c index 6440f871..463f218c 100644 --- a/utils/tree234.c +++ b/utils/tree234.c @@ -63,11 +63,11 @@ struct node234_Tag { */ tree234 *newtree234(cmpfn234 cmp) { - tree234 *ret = snew(tree234); - LOG(("created tree %p\n", ret)); - ret->root = NULL; - ret->cmp = cmp; - return ret; + tree234 *t = snew(tree234); + LOG(("created tree %p\n", t)); + t->root = NULL; + t->cmp = cmp; + return t; } /* diff --git a/windows/named-pipe-server.c b/windows/named-pipe-server.c index 87adb940..ef770796 100644 --- a/windows/named-pipe-server.c +++ b/windows/named-pipe-server.c @@ -201,35 +201,35 @@ static const SocketVtable NamedPipeServerSocket_sockvt = { Socket *new_named_pipe_listener(const char *pipename, Plug *plug) { - NamedPipeServerSocket *ret = snew(NamedPipeServerSocket); - ret->sock.vt = &NamedPipeServerSocket_sockvt; - ret->plug = plug; - ret->error = NULL; - ret->psd = NULL; - ret->pipename = dupstr(pipename); - ret->acl = NULL; - ret->callback_handle = NULL; + NamedPipeServerSocket *ps = snew(NamedPipeServerSocket); + ps->sock.vt = &NamedPipeServerSocket_sockvt; + ps->plug = plug; + ps->error = NULL; + ps->psd = NULL; + ps->pipename = dupstr(pipename); + ps->acl = NULL; + ps->callback_handle = NULL; assert(strncmp(pipename, "\\\\.\\pipe\\", 9) == 0); assert(strchr(pipename + 9, '\\') == NULL); if (!make_private_security_descriptor(GENERIC_READ | GENERIC_WRITE, - &ret->psd, &ret->acl, &ret->error)) { + &ps->psd, &ps->acl, &ps->error)) { goto cleanup; } - if (!create_named_pipe(ret, true)) { - ret->error = dupprintf("unable to create named pipe '%s': %s", + if (!create_named_pipe(ps, true)) { + ps->error = dupprintf("unable to create named pipe '%s': %s", pipename, win_strerror(GetLastError())); goto cleanup; } - memset(&ret->connect_ovl, 0, sizeof(ret->connect_ovl)); - ret->connect_ovl.hEvent = CreateEvent(NULL, true, false, NULL); - ret->callback_handle = add_handle_wait( - ret->connect_ovl.hEvent, named_pipe_connect_callback, ret); - named_pipe_accept_loop(ret, false); + memset(&ps->connect_ovl, 0, sizeof(ps->connect_ovl)); + ps->connect_ovl.hEvent = CreateEvent(NULL, true, false, NULL); + ps->callback_handle = add_handle_wait( + ps->connect_ovl.hEvent, named_pipe_connect_callback, ps); + named_pipe_accept_loop(ps, false); cleanup: - return &ret->sock; + return &ps->sock; } diff --git a/windows/network.c b/windows/network.c index 2c087b69..d9716d69 100644 --- a/windows/network.c +++ b/windows/network.c @@ -547,18 +547,18 @@ SockAddr *sk_namelookup(const char *host, char **canonicalname, static SockAddr *sk_special_addr(SuperFamily superfamily, const char *name) { - SockAddr *ret = snew(SockAddr); - ret->error = NULL; - ret->superfamily = superfamily; + SockAddr *addr = snew(SockAddr); + addr->error = NULL; + addr->superfamily = superfamily; #ifndef NO_IPV6 - ret->ais = NULL; + addr->ais = NULL; #endif - ret->addresses = NULL; - ret->naddresses = 0; - ret->refcount = 1; - strncpy(ret->hostname, name, lenof(ret->hostname)); - ret->hostname[lenof(ret->hostname)-1] = '\0'; - return ret; + addr->addresses = NULL; + addr->naddresses = 0; + addr->refcount = 1; + strncpy(addr->hostname, name, lenof(addr->hostname)); + addr->hostname[lenof(addr->hostname)-1] = '\0'; + return addr; } SockAddr *sk_nonamelookup(const char *host) @@ -838,47 +838,47 @@ static Socket *sk_net_accept(accept_ctx_t ctx, Plug *plug) { DWORD err; const char *errstr; - NetSocket *ret; + NetSocket *s; /* * Create NetSocket structure. */ - ret = snew(NetSocket); - ret->sock.vt = &NetSocket_sockvt; - ret->error = NULL; - ret->plug = plug; - bufchain_init(&ret->output_data); - ret->writable = true; /* to start with */ - ret->sending_oob = 0; - ret->outgoingeof = EOF_NO; - ret->frozen = true; - ret->frozen_readable = false; - ret->localhost_only = false; /* unused, but best init anyway */ - ret->pending_error = 0; - ret->parent = ret->child = NULL; - ret->addr = NULL; + s = snew(NetSocket); + s->sock.vt = &NetSocket_sockvt; + s->error = NULL; + s->plug = plug; + bufchain_init(&s->output_data); + s->writable = true; /* to start with */ + s->sending_oob = 0; + s->outgoingeof = EOF_NO; + s->frozen = true; + s->frozen_readable = false; + s->localhost_only = false; /* unused, but best init anyway */ + s->pending_error = 0; + s->parent = s->child = NULL; + s->addr = NULL; - ret->s = (SOCKET)ctx.p; + s->s = (SOCKET)ctx.p; - if (ret->s == INVALID_SOCKET) { + if (s->s == INVALID_SOCKET) { err = p_WSAGetLastError(); - ret->error = winsock_error_string(err); - return &ret->sock; + s->error = winsock_error_string(err); + return &s->sock; } - ret->oobinline = false; + s->oobinline = false; /* Set up a select mechanism. This could be an AsyncSelect on a * window, or an EventSelect on an event object. */ - errstr = do_select(ret->s, true); + errstr = do_select(s->s, true); if (errstr) { - ret->error = errstr; - return &ret->sock; + s->error = errstr; + return &s->sock; } - add234(sktree, ret); + add234(sktree, s); - return &ret->sock; + return &s->sock; } static DWORD try_connect(NetSocket *sock) @@ -1087,48 +1087,48 @@ static DWORD try_connect(NetSocket *sock) Socket *sk_new(SockAddr *addr, int port, bool privport, bool oobinline, bool nodelay, bool keepalive, Plug *plug) { - NetSocket *ret; + NetSocket *s; DWORD err; /* * Create NetSocket structure. */ - ret = snew(NetSocket); - ret->sock.vt = &NetSocket_sockvt; - ret->error = NULL; - ret->plug = plug; - bufchain_init(&ret->output_data); - ret->connected = false; /* to start with */ - ret->writable = false; /* to start with */ - ret->sending_oob = 0; - ret->outgoingeof = EOF_NO; - ret->frozen = false; - ret->frozen_readable = false; - ret->localhost_only = false; /* unused, but best init anyway */ - ret->pending_error = 0; - ret->parent = ret->child = NULL; - ret->oobinline = oobinline; - ret->nodelay = nodelay; - ret->keepalive = keepalive; - ret->privport = privport; - ret->port = port; - ret->addr = addr; - START_STEP(ret->addr, ret->step); - ret->s = INVALID_SOCKET; + s = snew(NetSocket); + s->sock.vt = &NetSocket_sockvt; + s->error = NULL; + s->plug = plug; + bufchain_init(&s->output_data); + s->connected = false; /* to start with */ + s->writable = false; /* to start with */ + s->sending_oob = 0; + s->outgoingeof = EOF_NO; + s->frozen = false; + s->frozen_readable = false; + s->localhost_only = false; /* unused, but best init anyway */ + s->pending_error = 0; + s->parent = s->child = NULL; + s->oobinline = oobinline; + s->nodelay = nodelay; + s->keepalive = keepalive; + s->privport = privport; + s->port = port; + s->addr = addr; + START_STEP(s->addr, s->step); + s->s = INVALID_SOCKET; err = 0; do { - err = try_connect(ret); - } while (err && sk_nextaddr(ret->addr, &ret->step)); + err = try_connect(s); + } while (err && sk_nextaddr(s->addr, &s->step)); - return &ret->sock; + return &s->sock; } static Socket *sk_newlistener_internal( const char *srcaddr, int port, Plug *plug, bool local_host_only, int orig_address_family) { - SOCKET s; + SOCKET sk; SOCKADDR_IN a; #ifndef NO_IPV6 SOCKADDR_IN6 a6; @@ -1141,7 +1141,7 @@ static Socket *sk_newlistener_internal( DWORD err; const char *errstr; - NetSocket *ret; + NetSocket *s; int retcode; int address_family = orig_address_family; @@ -1149,20 +1149,20 @@ static Socket *sk_newlistener_internal( /* * Create NetSocket structure. */ - ret = snew(NetSocket); - ret->sock.vt = &NetSocket_sockvt; - ret->error = NULL; - ret->plug = plug; - bufchain_init(&ret->output_data); - ret->writable = false; /* to start with */ - ret->sending_oob = 0; - ret->outgoingeof = EOF_NO; - ret->frozen = false; - ret->frozen_readable = false; - ret->localhost_only = local_host_only; - ret->pending_error = 0; - ret->parent = ret->child = NULL; - ret->addr = NULL; + s = snew(NetSocket); + s->sock.vt = &NetSocket_sockvt; + s->error = NULL; + s->plug = plug; + bufchain_init(&s->output_data); + s->writable = false; /* to start with */ + s->sending_oob = 0; + s->outgoingeof = EOF_NO; + s->frozen = false; + s->frozen_readable = false; + s->localhost_only = local_host_only; + s->pending_error = 0; + s->parent = s->child = NULL; + s->addr = NULL; /* * Our default, if passed the `don't care' value @@ -1176,25 +1176,25 @@ static Socket *sk_newlistener_internal( /* * Open socket. */ - s = p_socket(address_family, SOCK_STREAM, 0); - ret->s = s; + sk = p_socket(address_family, SOCK_STREAM, 0); + s->s = sk; - if (s == INVALID_SOCKET) { + if (sk == INVALID_SOCKET) { err = p_WSAGetLastError(); - ret->error = winsock_error_string(err); - return &ret->sock; + s->error = winsock_error_string(err); + return &s->sock; } - SetHandleInformation((HANDLE)s, HANDLE_FLAG_INHERIT, 0); + SetHandleInformation((HANDLE)sk, HANDLE_FLAG_INHERIT, 0); - ret->oobinline = false; + s->oobinline = false; #if HAVE_AFUNIX_H if (address_family != AF_UNIX) #endif { BOOL on = true; - p_setsockopt(s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, + p_setsockopt(sk, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (const char *)&on, sizeof(on)); } @@ -1244,7 +1244,7 @@ static Socket *sk_newlistener_internal( a.sin_addr.s_addr = p_inet_addr(srcaddr); if (a.sin_addr.s_addr != INADDR_NONE) { /* Override localhost_only with specified listen addr. */ - ret->localhost_only = ipv4_is_loopback(a.sin_addr); + s->localhost_only = ipv4_is_loopback(a.sin_addr); got_addr = true; } } @@ -1277,7 +1277,7 @@ static Socket *sk_newlistener_internal( unreachable("bad address family in sk_newlistener_internal"); } - retcode = p_bind(s, bindaddr, bindsize); + retcode = p_bind(sk, bindaddr, bindsize); if (retcode != SOCKET_ERROR) { err = 0; } else { @@ -1285,28 +1285,28 @@ static Socket *sk_newlistener_internal( } if (err) { - p_closesocket(s); - ret->error = winsock_error_string(err); - return &ret->sock; + p_closesocket(sk); + s->error = winsock_error_string(err); + return &s->sock; } - if (p_listen(s, SOMAXCONN) == SOCKET_ERROR) { - p_closesocket(s); - ret->error = winsock_error_string(p_WSAGetLastError()); - return &ret->sock; + if (p_listen(sk, SOMAXCONN) == SOCKET_ERROR) { + p_closesocket(sk); + s->error = winsock_error_string(p_WSAGetLastError()); + return &s->sock; } /* Set up a select mechanism. This could be an AsyncSelect on a * window, or an EventSelect on an event object. */ - errstr = do_select(s, true); + errstr = do_select(sk, true); if (errstr) { - p_closesocket(s); - ret->error = errstr; - return &ret->sock; + p_closesocket(sk); + s->error = errstr; + return &s->sock; } - add234(sktree, ret); + add234(sktree, s); #ifndef NO_IPV6 /* @@ -1320,8 +1320,8 @@ static Socket *sk_newlistener_internal( if (other) { NetSocket *ns = container_of(other, NetSocket, sock); if (!ns->error) { - ns->parent = ret; - ret->child = ns; + ns->parent = s; + s->child = ns; } else { sfree(ns); } @@ -1329,7 +1329,7 @@ static Socket *sk_newlistener_internal( } #endif - return &ret->sock; + return &s->sock; } Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug, @@ -1871,9 +1871,9 @@ char *get_hostname(void) SockAddr *platform_get_x11_unix_address(const char *display, int displaynum) { - SockAddr *ret = snew(SockAddr); - memset(ret, 0, sizeof(SockAddr)); - ret->error = "unix sockets for X11 not supported on this platform"; - ret->refcount = 1; - return ret; + SockAddr *addr = snew(SockAddr); + memset(addr, 0, sizeof(SockAddr)); + addr->error = "unix sockets for X11 not supported on this platform"; + addr->refcount = 1; + return addr; } diff --git a/windows/printing.c b/windows/printing.c index 2286c236..965b6384 100644 --- a/windows/printing.c +++ b/windows/printing.c @@ -93,7 +93,7 @@ static bool printer_add_enum(int param, DWORD level, char **buffer, printer_enum *printer_start_enum(int *nprinters_ptr) { - printer_enum *ret = snew(printer_enum); + printer_enum *pe = snew(printer_enum); char *buffer = NULL; *nprinters_ptr = 0; /* default return value */ @@ -110,30 +110,30 @@ printer_enum *printer_start_enum(int *nprinters_ptr) * Bletch. */ if (osPlatformId != VER_PLATFORM_WIN32_NT) { - ret->enum_level = 5; + pe->enum_level = 5; } else { - ret->enum_level = 4; + pe->enum_level = 4; } if (!printer_add_enum(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, - ret->enum_level, &buffer, 0, nprinters_ptr)) + pe->enum_level, &buffer, 0, nprinters_ptr)) goto error; - switch (ret->enum_level) { + switch (pe->enum_level) { case 4: - ret->info.i4 = (LPPRINTER_INFO_4)buffer; + pe->info.i4 = (LPPRINTER_INFO_4)buffer; break; case 5: - ret->info.i5 = (LPPRINTER_INFO_5)buffer; + pe->info.i5 = (LPPRINTER_INFO_5)buffer; break; } - ret->nprinters = *nprinters_ptr; + pe->nprinters = *nprinters_ptr; - return ret; + return pe; error: sfree(buffer); - sfree(ret); + sfree(pe); *nprinters_ptr = 0; return NULL; } @@ -171,38 +171,38 @@ void printer_finish_enum(printer_enum *pe) printer_job *printer_start_job(char *printer) { - printer_job *ret = snew(printer_job); + printer_job *pj = snew(printer_job); DOC_INFO_1 docinfo; bool jobstarted = false, pagestarted = false; init_winfuncs(); - ret->hprinter = NULL; - if (!p_OpenPrinter(printer, &ret->hprinter, NULL)) + pj->hprinter = NULL; + if (!p_OpenPrinter(printer, &pj->hprinter, NULL)) goto error; docinfo.pDocName = "PuTTY remote printer output"; docinfo.pOutputFile = NULL; docinfo.pDatatype = "RAW"; - if (!p_StartDocPrinter(ret->hprinter, 1, (LPBYTE)&docinfo)) + if (!p_StartDocPrinter(pj->hprinter, 1, (LPBYTE)&docinfo)) goto error; jobstarted = true; - if (!p_StartPagePrinter(ret->hprinter)) + if (!p_StartPagePrinter(pj->hprinter)) goto error; pagestarted = true; - return ret; + return pj; error: if (pagestarted) - p_EndPagePrinter(ret->hprinter); + p_EndPagePrinter(pj->hprinter); if (jobstarted) - p_EndDocPrinter(ret->hprinter); - if (ret->hprinter) - p_ClosePrinter(ret->hprinter); - sfree(ret); + p_EndDocPrinter(pj->hprinter); + if (pj->hprinter) + p_ClosePrinter(pj->hprinter); + sfree(pj); return NULL; } diff --git a/windows/sftp.c b/windows/sftp.c index a6546269..2c4c94e4 100644 --- a/windows/sftp.c +++ b/windows/sftp.c @@ -104,15 +104,15 @@ RFile *open_existing_file(const char *name, uint64_t *size, long *perms) { HANDLE h; - RFile *ret; + RFile *f; h = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if (h == INVALID_HANDLE_VALUE) return NULL; - ret = snew(RFile); - ret->h = h; + f = snew(RFile); + f->h = h; if (size) { DWORD lo, hi; @@ -132,7 +132,7 @@ RFile *open_existing_file(const char *name, uint64_t *size, if (perms) *perms = -1; - return ret; + return f; } int read_from_file(RFile *f, void *buffer, int length) @@ -157,31 +157,31 @@ struct WFile { WFile *open_new_file(const char *name, long perms) { HANDLE h; - WFile *ret; + WFile *f; h = CreateFile(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (h == INVALID_HANDLE_VALUE) return NULL; - ret = snew(WFile); - ret->h = h; + f = snew(WFile); + f->h = h; - return ret; + return f; } WFile *open_existing_wfile(const char *name, uint64_t *size) { HANDLE h; - WFile *ret; + WFile *f; h = CreateFile(name, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if (h == INVALID_HANDLE_VALUE) return NULL; - ret = snew(WFile); - ret->h = h; + f = snew(WFile); + f->h = h; if (size) { DWORD lo, hi; @@ -189,7 +189,7 @@ WFile *open_existing_wfile(const char *name, uint64_t *size) *size = uint64_from_words(hi, lo); } - return ret; + return f; } int write_to_file(WFile *f, void *buffer, int length) @@ -277,7 +277,7 @@ DirHandle *open_directory(const char *name, const char **errmsg) HANDLE h; WIN32_FIND_DATA fdat; char *findfile; - DirHandle *ret; + DirHandle *dir; /* Enumerate files in dir `foo'. */ findfile = dupcat(name, "/*"); @@ -288,10 +288,10 @@ DirHandle *open_directory(const char *name, const char **errmsg) } sfree(findfile); - ret = snew(DirHandle); - ret->h = h; - ret->name = dupstr(fdat.cFileName); - return ret; + dir = snew(DirHandle); + dir->h = h; + dir->name = dupstr(fdat.cFileName); + return dir; } char *read_filename(DirHandle *dir) @@ -384,26 +384,26 @@ WildcardMatcher *begin_wildcard_matching(const char *name) { HANDLE h; WIN32_FIND_DATA fdat; - WildcardMatcher *ret; + WildcardMatcher *dir; char *last; h = FindFirstFile(name, &fdat); if (h == INVALID_HANDLE_VALUE) return NULL; - ret = snew(WildcardMatcher); - ret->h = h; - ret->srcpath = dupstr(name); - last = stripslashes(ret->srcpath, true); + dir = snew(WildcardMatcher); + dir->h = h; + dir->srcpath = dupstr(name); + last = stripslashes(dir->srcpath, true); *last = '\0'; if (fdat.cFileName[0] == '.' && (fdat.cFileName[1] == '\0' || (fdat.cFileName[1] == '.' && fdat.cFileName[2] == '\0'))) - ret->name = NULL; + dir->name = NULL; else - ret->name = dupcat(ret->srcpath, fdat.cFileName); + dir->name = dupcat(dir->srcpath, fdat.cFileName); - return ret; + return dir; } char *wildcard_get_filename(WildcardMatcher *dir) diff --git a/windows/storage.c b/windows/storage.c index 24c98447..b871ad5b 100644 --- a/windows/storage.c +++ b/windows/storage.c @@ -51,9 +51,9 @@ settings_w *open_settings_w(const char *sessionname, char **errmsg) } strbuf_free(sb); - settings_w *toret = snew(settings_w); - toret->sesskey = sesskey; - return toret; + settings_w *handle = snew(settings_w); + handle->sesskey = sesskey; + return handle; } void write_setting_s(settings_w *handle, const char *key, const char *value) @@ -91,9 +91,9 @@ settings_r *open_settings_r(const char *sessionname) if (!sesskey) return NULL; - settings_r *toret = snew(settings_r); - toret->sesskey = sesskey; - return toret; + settings_r *handle = snew(settings_r); + handle->sesskey = sesskey; + return handle; } char *read_setting_s(settings_r *handle, const char *key) @@ -221,13 +221,13 @@ settings_e *enum_settings_start(void) if (!key) return NULL; - settings_e *ret = snew(settings_e); - if (ret) { - ret->key = key; - ret->i = 0; + settings_e *e = snew(settings_e); + if (e) { + e->key = key; + e->i = 0; } - return ret; + return e; } bool enum_settings_next(settings_e *e, strbuf *sb) diff --git a/windows/utils/filename.c b/windows/utils/filename.c index f4457ecb..a91732c8 100644 --- a/windows/utils/filename.c +++ b/windows/utils/filename.c @@ -6,9 +6,9 @@ Filename *filename_from_str(const char *str) { - Filename *ret = snew(Filename); - ret->path = dupstr(str); - return ret; + Filename *fn = snew(Filename); + fn->path = dupstr(str); + return fn; } Filename *filename_copy(const Filename *fn) diff --git a/windows/utils/request_file.c b/windows/utils/request_file.c index dd2cab18..1602942e 100644 --- a/windows/utils/request_file.c +++ b/windows/utils/request_file.c @@ -60,9 +60,9 @@ bool request_file(filereq *state, OPENFILENAME *of, bool preserve, bool save) filereq *filereq_new(void) { - filereq *ret = snew(filereq); - ret->cwd[0] = '\0'; - return ret; + filereq *state = snew(filereq); + state->cwd[0] = '\0'; + return state; } void filereq_free(filereq *state)