mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Change vtable defs to use C99 designated initialisers.
This is a sweeping change applied across the whole code base by a spot of Emacs Lisp. Now, everywhere I declare a vtable filled with function pointers (and the occasional const data member), all the members of the vtable structure are initialised by name using the '.fieldname = value' syntax introduced in C99. We were already using this syntax for a handful of things in the new key-generation progress report system, so it's not new to the code base as a whole. The advantage is that now, when a vtable only declares a subset of the available fields, I can initialise the rest to NULL or zero just by leaving them out. This is most dramatic in a couple of the outlying vtables in things like psocks (which has a ConnectionLayerVtable containing only one non-NULL method), but less dramatically, it means that the new 'flags' field in BackendVtable can be completely left out of every backend definition except for the SUPDUP one which defines it to a nonzero value. Similarly, the test_for_upstream method only used by SSH doesn't have to be mentioned in the rest of the backends; network Plugs for listening sockets don't have to explicitly null out 'receive' and 'sent', and vice versa for 'accepting', and so on. While I'm at it, I've normalised the declarations so they don't use the unnecessarily verbose 'struct' keyword. Also a handful of them weren't const; now they are.
This commit is contained in:
8
ssh.h
8
ssh.h
@ -209,6 +209,8 @@ struct ssh_rportfwd {
|
||||
};
|
||||
void free_rportfwd(struct ssh_rportfwd *rpf);
|
||||
|
||||
typedef struct ConnectionLayerVtable ConnectionLayerVtable;
|
||||
|
||||
struct ConnectionLayerVtable {
|
||||
/* Allocate and free remote-to-local port forwardings, called by
|
||||
* PortFwdManager or by connection sharing */
|
||||
@ -782,9 +784,9 @@ static inline void ssh_hash_digest_nondestructive(ssh_hash *h,
|
||||
|
||||
/* Handy macros for defining all those text-name fields at once */
|
||||
#define HASHALG_NAMES_BARE(base) \
|
||||
base, NULL, base
|
||||
#define HASHALG_NAMES_ANNOTATED(base, annotation) \
|
||||
base, annotation, base " (" annotation ")"
|
||||
.text_basename = base, .annotation = NULL, .text_name = base
|
||||
#define HASHALG_NAMES_ANNOTATED(base, ann) \
|
||||
.text_basename = base, .annotation = ann, .text_name = base " (" ann ")"
|
||||
|
||||
void hash_simple(const ssh_hashalg *alg, ptrlen data, void *output);
|
||||
|
||||
|
Reference in New Issue
Block a user