1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00
putty-source/crypto
Simon Tatham 20f818af12 Rename 'ret' variables passed from allocation to return.
I mentioned recently (in commit 9e7d4c53d8) message that I'm no
longer fond of the variable name 'ret', because it's used in two quite
different contexts: it's the return value from a subroutine you just
called (e.g. 'int ret = read(fd, buf, len);' and then check for error
or EOF), or it's the value you're preparing to return from the
_containing_ routine (maybe by assigning it a default value and then
conditionally modifying it, or by starting at NULL and reallocating,
or setting it just before using the 'goto out' cleanup idiom). In the
past I've occasionally made mistakes by forgetting which meaning the
variable had, or accidentally conflating both uses.

If all else fails, I now prefer 'retd' (short for 'returned') in the
former situation, and 'toret' (obviously, the value 'to return') in
the latter case. But even better is to pick a name that actually says
something more specific about what the thing actually is.

One particular bad habit throughout this codebase is to have a set of
functions that deal with some object type (say 'Foo'), all *but one*
of which take a 'Foo *foo' parameter, but the foo_new() function
starts with 'Foo *ret = snew(Foo)'. If all the rest of them think the
canonical name for the ambient Foo is 'foo', so should foo_new()!

So here's a no-brainer start on cutting down on the uses of 'ret': I
looked for all the cases where it was being assigned the result of an
allocation, and renamed the variable to be a description of the thing
being allocated. In the case of a new() function belonging to a
family, I picked the same name as the rest of the functions in its own
family, for consistency. In other cases I picked something sensible.

One case where it _does_ make sense not to use your usual name for the
variable type is when you're cloning an existing object. In that case,
_neither_ of the Foo objects involved should be called 'foo', because
it's ambiguous! They should be named so you can see which is which. In
the two cases I found here, I've called them 'orig' and 'copy'.

As in the previous refactoring, many thanks to clang-rename for the
help.
2022-09-14 16:10:29 +01:00
..
aes-common.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aes-neon.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aes-ni.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aes-select.c Fix aes-select.c macros again. 2022-09-03 11:59:12 +01:00
aes-sw.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aes.h Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aesgcm-clmul.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aesgcm-common.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aesgcm-footer.h Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aesgcm-neon.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aesgcm-ref-poly.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aesgcm-select.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aesgcm-sw.c Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
aesgcm.h Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
arcfour.c Add 'next_message' methods to cipher and MAC vtables. 2022-08-16 18:27:06 +01:00
argon2.c Fix a batch of typos in comments and docs. 2022-01-03 06:40:51 +00:00
bcrypt.c Add a batch of missing 'static's. 2022-09-03 12:02:48 +01:00
blake2.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
blowfish.c Add 'next_message' methods to cipher and MAC vtables. 2022-08-16 18:27:06 +01:00
blowfish.h Update source file names in comments and docs. 2022-01-22 15:51:31 +00:00
chacha20-poly1305.c Remove a stray FIXME, added in 840043f06e. 2022-09-11 22:17:46 +01:00
CMakeLists.txt Implement AES-GCM using the @openssh.com protocol IDs. 2022-08-16 20:33:58 +01:00
crc32.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
des.c Add 'next_message' methods to cipher and MAC vtables. 2022-08-16 18:27:06 +01:00
diffie-hellman.c Change priority of new Diffie-Hellman groups. 2022-09-12 09:34:01 +01:00
dsa.c Formatting: realign run-on parenthesised stuff. 2022-08-03 20:48:46 +01:00
ecc-arithmetic.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
ecc-ssh.c Standardise RFC URLs in docs and comments. 2022-09-11 23:59:12 +01:00
ecc.h testcrypt: adjust some function parameter names. 2021-11-21 22:19:01 +00:00
hash_simple.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
hmac.c Add 'next_message' methods to cipher and MAC vtables. 2022-08-16 18:27:06 +01:00
mac_simple.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
mac.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
md5.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
mpint_i.h Update source file names in comments and docs. 2022-01-22 15:51:31 +00:00
mpint.c Utility function mp_resize. 2022-04-15 17:46:06 +01:00
ntru.c Fix a batch of resource leaks spotted by Coverity. 2022-09-07 14:28:52 +01:00
ntru.h Implement OpenSSH 9.x's NTRU Prime / Curve25519 kex. 2022-04-15 17:46:06 +01:00
openssh-certs.c opensshcert_components: switch expiry times to UTC. 2022-09-12 09:34:01 +01:00
prng.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
pubkey-pem.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
pubkey-ppk.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
pubkey-ssh1.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
rsa.c Rename 'ret' variables passed from allocation to return. 2022-09-14 16:10:29 +01:00
sha1-common.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha1-neon.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha1-ni.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha1-select.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha1-sw.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha1.h Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha3.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00
sha256-common.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha256-neon.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha256-ni.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha256-select.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha256-sw.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha256.h Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha512-common.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha512-neon.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha512-select.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha512-sw.c Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
sha512.h Break up crypto modules containing HW acceleration. 2021-04-21 21:55:26 +01:00
xdmauth.c Move crypto into its own subdirectory. 2021-04-21 21:55:26 +01:00