зеркало из https://github.com/github/putty.git
Add lots of missing 'static' keywords.
A trawl through the code with -Wmissing-prototypes and -Wmissing-variable-declarations turned up a lot of things that should have been internal to a particular source file, but were accidentally global. Keep the namespace clean by making them all static. (Also, while I'm here, a couple of them were missing a 'const': the ONE and ZERO arrays in sshcrcda.c, and EMPTY_WINDOW_TITLE in terminal.c.)
This commit is contained in:
Родитель
787181bb12
Коммит
8d747d8029
|
@ -14,10 +14,10 @@ struct callback {
|
|||
void *ctx;
|
||||
};
|
||||
|
||||
struct callback *cbcurr = NULL, *cbhead = NULL, *cbtail = NULL;
|
||||
static struct callback *cbcurr = NULL, *cbhead = NULL, *cbtail = NULL;
|
||||
|
||||
toplevel_callback_notify_fn_t notify_frontend = NULL;
|
||||
void *notify_ctx = NULL;
|
||||
static toplevel_callback_notify_fn_t notify_frontend = NULL;
|
||||
static void *notify_ctx = NULL;
|
||||
|
||||
void request_callback_notifications(toplevel_callback_notify_fn_t fn,
|
||||
void *ctx)
|
||||
|
|
|
@ -102,7 +102,7 @@ typedef struct {
|
|||
#define SHAPE_FIRST 0x621
|
||||
#define SHAPE_LAST (SHAPE_FIRST + lenof(shapetypes) - 1)
|
||||
|
||||
const shape_node shapetypes[] = {
|
||||
static const shape_node shapetypes[] = {
|
||||
/* index, Typ, Iso, Ligature Index*/
|
||||
/* 621 */ {SU, 0xFE80},
|
||||
/* 622 */ {SR, 0xFE81},
|
||||
|
|
2
mpint.c
2
mpint.c
|
@ -878,7 +878,7 @@ unsigned mp_eq_integer(mp_int *x, uintmax_t n)
|
|||
return 1 ^ normalise_to_1(diff); /* return 1 if diff _is_ zero */
|
||||
}
|
||||
|
||||
void mp_neg_into(mp_int *r, mp_int *a)
|
||||
static void mp_neg_into(mp_int *r, mp_int *a)
|
||||
{
|
||||
mp_int zero;
|
||||
zero.nw = 0;
|
||||
|
|
|
@ -732,7 +732,7 @@ static int pfr_cmp(void *av, void *bv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void pfr_free(PortFwdRecord *pfr)
|
||||
static void pfr_free(PortFwdRecord *pfr)
|
||||
{
|
||||
/* Dispose of any listening socket. */
|
||||
if (pfr->local)
|
||||
|
|
2
ssh.c
2
ssh.c
|
@ -557,7 +557,7 @@ void ssh_user_close(Ssh *ssh, const char *fmt, ...)
|
|||
}
|
||||
}
|
||||
|
||||
void ssh_deferred_abort_callback(void *vctx)
|
||||
static void ssh_deferred_abort_callback(void *vctx)
|
||||
{
|
||||
Ssh *ssh = (Ssh *)vctx;
|
||||
char *msg = ssh->deferred_abort_message;
|
||||
|
|
2
sshaes.c
2
sshaes.c
|
@ -123,7 +123,7 @@ struct aes_extra {
|
|||
pid, 16, bits, bits/8, flags, name HW_NAME_SUFFIX, \
|
||||
NULL, NULL }; \
|
||||
\
|
||||
const struct aes_extra extra_##cid = { \
|
||||
static const struct aes_extra extra_##cid = { \
|
||||
&ssh_##cid##_sw, &ssh_##cid##_hw }; \
|
||||
\
|
||||
const ssh_cipheralg ssh_##cid = { \
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
|
||||
#define CMP(a, b) (memcmp(a, b, SSH_BLOCKSIZE))
|
||||
|
||||
uint8_t ONE[4] = { 1, 0, 0, 0 };
|
||||
uint8_t ZERO[4] = { 0, 0, 0, 0 };
|
||||
static const uint8_t ONE[4] = { 1, 0, 0, 0 };
|
||||
static const uint8_t ZERO[4] = { 0, 0, 0, 0 };
|
||||
|
||||
struct crcda_ctx {
|
||||
uint16_t *h;
|
||||
|
|
2
sshdes.c
2
sshdes.c
|
@ -430,7 +430,7 @@ static inline uint64_t bitsel(
|
|||
return ret;
|
||||
}
|
||||
|
||||
void des_key_setup(uint64_t key, des_keysched *sched)
|
||||
static void des_key_setup(uint64_t key, des_keysched *sched)
|
||||
{
|
||||
static const int8_t PC1[] = {
|
||||
7, 15, 23, 31, 39, 47, 55, 63, 6, 14, 22, 30, 38, 46,
|
||||
|
|
14
sshecc.c
14
sshecc.c
|
@ -1124,7 +1124,7 @@ static void eddsa_sign(ssh_key *key, ptrlen data,
|
|||
mp_free(s);
|
||||
}
|
||||
|
||||
const struct ecsign_extra sign_extra_ed25519 = {
|
||||
static const struct ecsign_extra sign_extra_ed25519 = {
|
||||
ec_ed25519, &ssh_sha512,
|
||||
NULL, 0,
|
||||
};
|
||||
|
@ -1154,7 +1154,7 @@ const ssh_keyalg ssh_ecdsa_ed25519 = {
|
|||
static const unsigned char nistp256_oid[] = {
|
||||
0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07
|
||||
};
|
||||
const struct ecsign_extra sign_extra_nistp256 = {
|
||||
static const struct ecsign_extra sign_extra_nistp256 = {
|
||||
ec_p256, &ssh_sha256,
|
||||
nistp256_oid, lenof(nistp256_oid),
|
||||
};
|
||||
|
@ -1184,7 +1184,7 @@ const ssh_keyalg ssh_ecdsa_nistp256 = {
|
|||
static const unsigned char nistp384_oid[] = {
|
||||
0x2b, 0x81, 0x04, 0x00, 0x22
|
||||
};
|
||||
const struct ecsign_extra sign_extra_nistp384 = {
|
||||
static const struct ecsign_extra sign_extra_nistp384 = {
|
||||
ec_p384, &ssh_sha384,
|
||||
nistp384_oid, lenof(nistp384_oid),
|
||||
};
|
||||
|
@ -1214,7 +1214,7 @@ const ssh_keyalg ssh_ecdsa_nistp384 = {
|
|||
static const unsigned char nistp521_oid[] = {
|
||||
0x2b, 0x81, 0x04, 0x00, 0x23
|
||||
};
|
||||
const struct ecsign_extra sign_extra_nistp521 = {
|
||||
static const struct ecsign_extra sign_extra_nistp521 = {
|
||||
ec_p521, &ssh_sha512,
|
||||
nistp521_oid, lenof(nistp521_oid),
|
||||
};
|
||||
|
@ -1449,7 +1449,7 @@ const ssh_kex ssh_ec_kex_curve25519 = {
|
|||
&ssh_sha256, &kex_extra_curve25519,
|
||||
};
|
||||
|
||||
const struct eckex_extra kex_extra_nistp256 = {
|
||||
static const struct eckex_extra kex_extra_nistp256 = {
|
||||
ec_p256,
|
||||
ssh_ecdhkex_w_setup,
|
||||
ssh_ecdhkex_w_cleanup,
|
||||
|
@ -1461,7 +1461,7 @@ const ssh_kex ssh_ec_kex_nistp256 = {
|
|||
&ssh_sha256, &kex_extra_nistp256,
|
||||
};
|
||||
|
||||
const struct eckex_extra kex_extra_nistp384 = {
|
||||
static const struct eckex_extra kex_extra_nistp384 = {
|
||||
ec_p384,
|
||||
ssh_ecdhkex_w_setup,
|
||||
ssh_ecdhkex_w_cleanup,
|
||||
|
@ -1473,7 +1473,7 @@ const ssh_kex ssh_ec_kex_nistp384 = {
|
|||
&ssh_sha384, &kex_extra_nistp384,
|
||||
};
|
||||
|
||||
const struct eckex_extra kex_extra_nistp521 = {
|
||||
static const struct eckex_extra kex_extra_nistp521 = {
|
||||
ec_p521,
|
||||
ssh_ecdhkex_w_setup,
|
||||
ssh_ecdhkex_w_cleanup,
|
||||
|
|
12
sshhmac.c
12
sshhmac.c
|
@ -160,7 +160,7 @@ static const char *hmac_text_name(ssh2_mac *mac)
|
|||
return ctx->text_name->s;
|
||||
}
|
||||
|
||||
const struct hmac_extra ssh_hmac_sha256_extra = { &ssh_sha256, "" };
|
||||
static const struct hmac_extra ssh_hmac_sha256_extra = { &ssh_sha256, "" };
|
||||
const ssh2_macalg ssh_hmac_sha256 = {
|
||||
hmac_new, hmac_free, hmac_key,
|
||||
hmac_start, hmac_genresult, hmac_text_name,
|
||||
|
@ -168,7 +168,7 @@ const ssh2_macalg ssh_hmac_sha256 = {
|
|||
32, 32, &ssh_hmac_sha256_extra,
|
||||
};
|
||||
|
||||
const struct hmac_extra ssh_hmac_md5_extra = { &ssh_md5, "" };
|
||||
static const struct hmac_extra ssh_hmac_md5_extra = { &ssh_md5, "" };
|
||||
const ssh2_macalg ssh_hmac_md5 = {
|
||||
hmac_new, hmac_free, hmac_key,
|
||||
hmac_start, hmac_genresult, hmac_text_name,
|
||||
|
@ -176,7 +176,7 @@ const ssh2_macalg ssh_hmac_md5 = {
|
|||
16, 16, &ssh_hmac_md5_extra,
|
||||
};
|
||||
|
||||
const struct hmac_extra ssh_hmac_sha1_extra = { &ssh_sha1, "" };
|
||||
static const struct hmac_extra ssh_hmac_sha1_extra = { &ssh_sha1, "" };
|
||||
|
||||
const ssh2_macalg ssh_hmac_sha1 = {
|
||||
hmac_new, hmac_free, hmac_key,
|
||||
|
@ -185,7 +185,7 @@ const ssh2_macalg ssh_hmac_sha1 = {
|
|||
20, 20, &ssh_hmac_sha1_extra,
|
||||
};
|
||||
|
||||
const struct hmac_extra ssh_hmac_sha1_96_extra = { &ssh_sha1, "-96" };
|
||||
static const struct hmac_extra ssh_hmac_sha1_96_extra = { &ssh_sha1, "-96" };
|
||||
|
||||
const ssh2_macalg ssh_hmac_sha1_96 = {
|
||||
hmac_new, hmac_free, hmac_key,
|
||||
|
@ -194,7 +194,7 @@ const ssh2_macalg ssh_hmac_sha1_96 = {
|
|||
12, 20, &ssh_hmac_sha1_96_extra,
|
||||
};
|
||||
|
||||
const struct hmac_extra ssh_hmac_sha1_buggy_extra = {
|
||||
static const struct hmac_extra ssh_hmac_sha1_buggy_extra = {
|
||||
&ssh_sha1, "", "bug-compatible"
|
||||
};
|
||||
|
||||
|
@ -205,7 +205,7 @@ const ssh2_macalg ssh_hmac_sha1_buggy = {
|
|||
20, 16, &ssh_hmac_sha1_buggy_extra,
|
||||
};
|
||||
|
||||
const struct hmac_extra ssh_hmac_sha1_96_buggy_extra = {
|
||||
static const struct hmac_extra ssh_hmac_sha1_96_buggy_extra = {
|
||||
&ssh_sha1, "-96", "bug-compatible"
|
||||
};
|
||||
|
||||
|
|
4
sshmd5.c
4
sshmd5.c
|
@ -130,7 +130,7 @@ static void MD5_Block(MD5_Core_State *s, uint32_t *block)
|
|||
|
||||
static void MD5_BinarySink_write(BinarySink *bs, const void *data, size_t len);
|
||||
|
||||
void MD5Init(struct MD5Context *s)
|
||||
static void MD5Init(struct MD5Context *s)
|
||||
{
|
||||
MD5_Core_Init(&s->core);
|
||||
s->blkused = 0;
|
||||
|
@ -183,7 +183,7 @@ static void MD5_BinarySink_write(BinarySink *bs, const void *data, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
void MD5Final(unsigned char output[16], struct MD5Context *s)
|
||||
static void MD5Final(unsigned char output[16], struct MD5Context *s)
|
||||
{
|
||||
int i;
|
||||
unsigned pad;
|
||||
|
|
4
sshrsa.c
4
sshrsa.c
|
@ -128,7 +128,7 @@ bool rsa_ssh1_encrypt(unsigned char *data, int length, RSAKey *key)
|
|||
* Uses Chinese Remainder Theorem to speed computation up over the
|
||||
* obvious implementation of a single big modpow.
|
||||
*/
|
||||
mp_int *crt_modpow(mp_int *base, mp_int *exp, mp_int *mod,
|
||||
static mp_int *crt_modpow(mp_int *base, mp_int *exp, mp_int *mod,
|
||||
mp_int *p, mp_int *q, mp_int *iqmp)
|
||||
{
|
||||
mp_int *pm1, *qm1, *pexp, *qexp, *presult, *qresult;
|
||||
|
@ -780,7 +780,7 @@ static void rsa2_sign(ssh_key *key, ptrlen data,
|
|||
mp_free(out);
|
||||
}
|
||||
|
||||
char *rsa2_invalid(ssh_key *key, unsigned flags)
|
||||
static char *rsa2_invalid(ssh_key *key, unsigned flags)
|
||||
{
|
||||
RSAKey *rsa = container_of(key, RSAKey, sshk);
|
||||
size_t bits = mp_get_nbits(rsa->modulus), nbytes = (bits + 7) / 8;
|
||||
|
|
|
@ -193,14 +193,14 @@ static void SHA512_Block(SHA512_State *s, uint64_t *block) {
|
|||
static void SHA512_BinarySink_write(BinarySink *bs,
|
||||
const void *p, size_t len);
|
||||
|
||||
void SHA512_Init(SHA512_State *s) {
|
||||
static void SHA512_Init(SHA512_State *s) {
|
||||
SHA512_Core_Init(s);
|
||||
s->blkused = 0;
|
||||
s->lenhi = s->lenlo = 0;
|
||||
BinarySink_INIT(s, SHA512_BinarySink_write);
|
||||
}
|
||||
|
||||
void SHA384_Init(SHA512_State *s) {
|
||||
static void SHA384_Init(SHA512_State *s) {
|
||||
SHA384_Core_Init(s);
|
||||
s->blkused = 0;
|
||||
s->lenhi = s->lenlo = 0;
|
||||
|
@ -246,7 +246,7 @@ static void SHA512_BinarySink_write(BinarySink *bs,
|
|||
}
|
||||
}
|
||||
|
||||
void SHA512_Final(SHA512_State *s, unsigned char *digest) {
|
||||
static void SHA512_Final(SHA512_State *s, unsigned char *digest) {
|
||||
int i;
|
||||
int pad;
|
||||
unsigned char c[BLKSIZE];
|
||||
|
@ -271,7 +271,7 @@ void SHA512_Final(SHA512_State *s, unsigned char *digest) {
|
|||
PUT_64BIT_MSB_FIRST(digest + i*8, s->h[i]);
|
||||
}
|
||||
|
||||
void SHA384_Final(SHA512_State *s, unsigned char *digest) {
|
||||
static void SHA384_Final(SHA512_State *s, unsigned char *digest) {
|
||||
unsigned char biggerDigest[512 / 8];
|
||||
SHA512_Final(s, biggerDigest);
|
||||
memcpy(digest, biggerDigest, 384 / 8);
|
||||
|
|
|
@ -55,12 +55,12 @@
|
|||
|
||||
#define has_compat(x) ( ((CL_##x)&term->compatibility_level) != 0 )
|
||||
|
||||
const char *EMPTY_WINDOW_TITLE = "";
|
||||
static const char *const EMPTY_WINDOW_TITLE = "";
|
||||
|
||||
const char sco2ansicolour[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||
static const char sco2ansicolour[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||
|
||||
#define sel_nl_sz (sizeof(sel_nl)/sizeof(wchar_t))
|
||||
const wchar_t sel_nl[] = SEL_NL;
|
||||
static const wchar_t sel_nl[] = SEL_NL;
|
||||
|
||||
/*
|
||||
* Fetch the character at a particular position in a line array,
|
||||
|
|
|
@ -99,7 +99,7 @@ enum ValueType {
|
|||
|
||||
typedef enum ValueType ValueType;
|
||||
|
||||
const char *const type_names[] = {
|
||||
static const char *const type_names[] = {
|
||||
#define VALTYPE_NAME(n,t,f) #n,
|
||||
VALUE_TYPES(VALTYPE_NAME)
|
||||
#undef VALTYPE_NAME
|
||||
|
@ -384,7 +384,7 @@ struct finaliser {
|
|||
};
|
||||
|
||||
static struct finaliser *finalisers;
|
||||
size_t nfinalisers, finalisersize;
|
||||
static size_t nfinalisers, finalisersize;
|
||||
|
||||
static void add_finaliser(finaliser_fn_t fn, void *ctx)
|
||||
{
|
||||
|
|
|
@ -3279,14 +3279,14 @@ static void messagebox_handler(union control *ctrl, dlgparam *dp,
|
|||
dlg_end(dp, ctrl->generic.context.i);
|
||||
}
|
||||
|
||||
const struct message_box_button button_array_yn[] = {
|
||||
static const struct message_box_button button_array_yn[] = {
|
||||
{"Yes", 'y', +1, 1},
|
||||
{"No", 'n', -1, 0},
|
||||
};
|
||||
const struct message_box_buttons buttons_yn = {
|
||||
button_array_yn, lenof(button_array_yn),
|
||||
};
|
||||
const struct message_box_button button_array_ok[] = {
|
||||
static const struct message_box_button button_array_ok[] = {
|
||||
{"OK", 'o', 1, 1},
|
||||
};
|
||||
const struct message_box_buttons buttons_ok = {
|
||||
|
|
|
@ -45,7 +45,7 @@ static void uxpgnt_log(PageantListenerClient *plc, const char *fmt, va_list ap)
|
|||
fprintf(pageant_logfp, "\n");
|
||||
}
|
||||
|
||||
const PageantListenerClientVtable uxpgnt_vtable = {
|
||||
static const PageantListenerClientVtable uxpgnt_vtable = {
|
||||
uxpgnt_log,
|
||||
};
|
||||
|
||||
|
|
|
@ -32,9 +32,8 @@ struct x11_err_to_ignore {
|
|||
unsigned long serial;
|
||||
};
|
||||
|
||||
struct x11_err_to_ignore *errs;
|
||||
|
||||
size_t nerrs, errsize;
|
||||
static struct x11_err_to_ignore *errs;
|
||||
static size_t nerrs, errsize;
|
||||
|
||||
static int x11_error_handler(Display *thisdisp, XErrorEvent *err)
|
||||
{
|
||||
|
|
|
@ -1188,7 +1188,7 @@ int flags = FLAG_SYNCAGENT;
|
|||
struct winpgnt_client {
|
||||
PageantListenerClient plc;
|
||||
};
|
||||
const PageantListenerClientVtable winpgnt_vtable = {
|
||||
static const PageantListenerClientVtable winpgnt_vtable = {
|
||||
NULL, /* no logging */
|
||||
};
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ static size_t named_pipe_agent_gotdata(
|
|||
return 0;
|
||||
}
|
||||
|
||||
agent_pending_query *named_pipe_agent_query(
|
||||
static agent_pending_query *named_pipe_agent_query(
|
||||
strbuf *query, void **out, int *outlen,
|
||||
void (*callback)(void *, void *, int), void *callback_ctx)
|
||||
{
|
||||
|
|
|
@ -92,7 +92,7 @@ PSID get_user_sid(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool getsids(char **error)
|
||||
static bool getsids(char **error)
|
||||
{
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
|
|
Загрузка…
Ссылка в новой задаче