From 91d16881abf19592737ae31471b9540aeac24e8d Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 3 Nov 2018 08:25:28 +0000 Subject: [PATCH] Add missing 'static' on file-internal declarations. sk_startup and sk_nextaddr are entirely internal to winnet.c; nearly all of import.c and minibidi.c's internal routines should have been static and weren't; {read,write}_utf8 are internal to charset/utf8.c (and didn't even need separate declarations at all); do_sftp_cleanup is internal to psftp.c, and get_listitemheight to gtkdlg.c. While I was editing those prototypes anyway, I've also added missing 'const' to the 'char *' passphrase parameters in import,c. --- charset/utf8.c | 17 ++++-------- import.c | 72 +++++++++++++++++++++++------------------------- minibidi.c | 32 +++++++++++---------- psftp.c | 4 +-- unix/gtkdlg.c | 4 +-- windows/winnet.c | 4 +-- 6 files changed, 64 insertions(+), 69 deletions(-) diff --git a/charset/utf8.c b/charset/utf8.c index fe46cf98..13c5baa8 100644 --- a/charset/utf8.c +++ b/charset/utf8.c @@ -7,18 +7,13 @@ #include "charset.h" #include "internal.h" -void read_utf8(charset_spec const *, long int, charset_state *, - void (*)(void *, long int), void *); -void write_utf8(charset_spec const *, long int, - charset_state *, void (*)(void *, long int), void *); - /* * UTF-8 has no associated data, so `charset' may be ignored. */ -void read_utf8(charset_spec const *charset, long int input_chr, - charset_state *state, - void (*emit)(void *ctx, long int output), void *emitctx) +static void read_utf8(charset_spec const *charset, long int input_chr, + charset_state *state, + void (*emit)(void *ctx, long int output), void *emitctx) { UNUSEDARG(charset); @@ -186,9 +181,9 @@ void read_utf8(charset_spec const *charset, long int input_chr, * charset_state. */ -void write_utf8(charset_spec const *charset, long int input_chr, - charset_state *state, - void (*emit)(void *ctx, long int output), void *emitctx) +static void write_utf8(charset_spec const *charset, long int input_chr, + charset_state *state, + void (*emit)(void *ctx, long int output), void *emitctx) { UNUSEDARG(charset); UNUSEDARG(state); diff --git a/import.c b/import.c index d88ad2bb..e3ba53c4 100644 --- a/import.c +++ b/import.c @@ -12,26 +12,24 @@ #include "ssh.h" #include "misc.h" -bool openssh_pem_encrypted(const Filename *filename); -bool openssh_new_encrypted(const Filename *filename); -struct ssh2_userkey *openssh_pem_read(const Filename *filename, - char *passphrase, - const char **errmsg_p); -struct ssh2_userkey *openssh_new_read(const Filename *filename, - char *passphrase, - const char **errmsg_p); -bool openssh_auto_write(const Filename *filename, struct ssh2_userkey *key, - char *passphrase); -bool openssh_pem_write(const Filename *filename, struct ssh2_userkey *key, - char *passphrase); -bool openssh_new_write(const Filename *filename, struct ssh2_userkey *key, - char *passphrase); +static bool openssh_pem_encrypted(const Filename *file); +static bool openssh_new_encrypted(const Filename *file); +static struct ssh2_userkey *openssh_pem_read( + const Filename *file, const char *passphrase, const char **errmsg_p); +static struct ssh2_userkey *openssh_new_read( + const Filename *file, const char *passphrase, const char **errmsg_p); +static bool openssh_auto_write( + const Filename *file, struct ssh2_userkey *key, const char *passphrase); +static bool openssh_pem_write( + const Filename *file, struct ssh2_userkey *key, const char *passphrase); +static bool openssh_new_write( + const Filename *file, struct ssh2_userkey *key, const char *passphrase); -bool sshcom_encrypted(const Filename *filename, char **comment); -struct ssh2_userkey *sshcom_read(const Filename *filename, char *passphrase, - const char **errmsg_p); -bool sshcom_write(const Filename *filename, struct ssh2_userkey *key, - char *passphrase); +static bool sshcom_encrypted(const Filename *file, char **comment); +static struct ssh2_userkey *sshcom_read( + const Filename *file, const char *passphrase, const char **errmsg_p); +static bool sshcom_write( + const Filename *file, struct ssh2_userkey *key, const char *passphrase); /* * Given a key type, determine whether we know how to import it. @@ -482,7 +480,7 @@ static struct openssh_pem_key *load_openssh_pem_key(const Filename *filename, return NULL; } -bool openssh_pem_encrypted(const Filename *filename) +static bool openssh_pem_encrypted(const Filename *filename) { struct openssh_pem_key *key = load_openssh_pem_key(filename, NULL); bool ret; @@ -496,9 +494,8 @@ bool openssh_pem_encrypted(const Filename *filename) return ret; } -struct ssh2_userkey *openssh_pem_read(const Filename *filename, - char *passphrase, - const char **errmsg_p) +static struct ssh2_userkey *openssh_pem_read( + const Filename *filename, const char *passphrase, const char **errmsg_p) { struct openssh_pem_key *key = load_openssh_pem_key(filename, errmsg_p); struct ssh2_userkey *retkey; @@ -775,8 +772,8 @@ struct ssh2_userkey *openssh_pem_read(const Filename *filename, return retval; } -bool openssh_pem_write(const Filename *filename, struct ssh2_userkey *key, - char *passphrase) +static bool openssh_pem_write( + const Filename *filename, struct ssh2_userkey *key, const char *passphrase) { strbuf *pubblob, *privblob, *outblob; unsigned char *spareblob; @@ -1319,7 +1316,7 @@ static struct openssh_new_key *load_openssh_new_key(const Filename *filename, return NULL; } -bool openssh_new_encrypted(const Filename *filename) +static bool openssh_new_encrypted(const Filename *filename) { struct openssh_new_key *key = load_openssh_new_key(filename, NULL); bool ret; @@ -1334,9 +1331,8 @@ bool openssh_new_encrypted(const Filename *filename) return ret; } -struct ssh2_userkey *openssh_new_read(const Filename *filename, - char *passphrase, - const char **errmsg_p) +static struct ssh2_userkey *openssh_new_read( + const Filename *filename, const char *passphrase, const char **errmsg_p) { struct openssh_new_key *key = load_openssh_new_key(filename, errmsg_p); struct ssh2_userkey *retkey = NULL; @@ -1515,8 +1511,8 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename, return retval; } -bool openssh_new_write(const Filename *filename, struct ssh2_userkey *key, - char *passphrase) +static bool openssh_new_write( + const Filename *filename, struct ssh2_userkey *key, const char *passphrase) { strbuf *pubblob, *privblob, *cblob; int padvalue, i; @@ -1644,8 +1640,8 @@ bool openssh_new_write(const Filename *filename, struct ssh2_userkey *key, * The switch function openssh_auto_write(), which chooses one of the * concrete OpenSSH output formats based on the key type. */ -bool openssh_auto_write(const Filename *filename, struct ssh2_userkey *key, - char *passphrase) +static bool openssh_auto_write( + const Filename *filename, struct ssh2_userkey *key, const char *passphrase) { /* * The old OpenSSH format supports a fixed list of key types. We @@ -1905,7 +1901,7 @@ static struct sshcom_key *load_sshcom_key(const Filename *filename, return NULL; } -bool sshcom_encrypted(const Filename *filename, char **comment) +static bool sshcom_encrypted(const Filename *filename, char **comment) { struct sshcom_key *key = load_sshcom_key(filename, NULL); BinarySource src[1]; @@ -1970,8 +1966,8 @@ static ptrlen BinarySource_get_mp_sshcom_as_string(BinarySource *src) #define get_mp_sshcom_as_string(bs) \ BinarySource_get_mp_sshcom_as_string(BinarySource_UPCAST(bs)) -struct ssh2_userkey *sshcom_read(const Filename *filename, char *passphrase, - const char **errmsg_p) +static struct ssh2_userkey *sshcom_read( + const Filename *filename, const char *passphrase, const char **errmsg_p) { struct sshcom_key *key = load_sshcom_key(filename, errmsg_p); const char *errmsg; @@ -2181,8 +2177,8 @@ struct ssh2_userkey *sshcom_read(const Filename *filename, char *passphrase, return ret; } -bool sshcom_write(const Filename *filename, struct ssh2_userkey *key, - char *passphrase) +static bool sshcom_write( + const Filename *filename, struct ssh2_userkey *key, const char *passphrase) { strbuf *pubblob, *privblob, *outblob; ptrlen numbers[6]; diff --git a/minibidi.c b/minibidi.c index 64f27a96..6838b440 100644 --- a/minibidi.c +++ b/minibidi.c @@ -55,14 +55,15 @@ typedef struct bidi_char { } bidi_char; /* function declarations */ -void flipThisRun(bidi_char *from, unsigned char* level, int max, int count); -int findIndexOfRun(unsigned char* level , int start, int count, int tlevel); -unsigned char getType(int ch); -unsigned char setOverrideBits(unsigned char level, unsigned char override); -int getPreviousLevel(unsigned char* level, int from); -int do_shape(bidi_char *line, bidi_char *to, int count); -int do_bidi(bidi_char *line, int count); -void doMirror(unsigned int *ch); +static void flipThisRun( + bidi_char *from, unsigned char *level, int max, int count); +static int findIndexOfRun( + unsigned char *level, int start, int count, int tlevel); +static unsigned char getType(int ch); +static unsigned char setOverrideBits( + unsigned char level, unsigned char override); +static int getPreviousLevel(unsigned char *level, int from); +static void doMirror(unsigned int *ch); /* character types */ enum { @@ -297,7 +298,8 @@ const shape_node shapetypes[] = { * max: the maximum level found in this line (should be unsigned char) * count: line size in bidi_char */ -void flipThisRun(bidi_char *from, unsigned char *level, int max, int count) +static void flipThisRun( + bidi_char *from, unsigned char *level, int max, int count) { int i, j, k, tlevel; bidi_char temp; @@ -323,7 +325,8 @@ void flipThisRun(bidi_char *from, unsigned char *level, int max, int count) /* * Finds the index of a run with level equals tlevel */ -int findIndexOfRun(unsigned char* level , int start, int count, int tlevel) +static int findIndexOfRun( + unsigned char *level , int start, int count, int tlevel) { int i; for (i=start; i 0) { unsigned char current = level[--from]; @@ -1630,7 +1634,7 @@ int do_bidi(bidi_char *line, int count) * takes a pointer to a character that is checked for * having a mirror glyph. */ -void doMirror(unsigned int *ch) +static void doMirror(unsigned int *ch) { if ((*ch & 0xFF00) == 0) { switch (*ch) { diff --git a/psftp.c b/psftp.c index 3fb8ffbe..d87fea21 100644 --- a/psftp.c +++ b/psftp.c @@ -26,7 +26,7 @@ const char *const appname = "PSFTP"; static int psftp_connect(char *userhost, char *user, int portnumber); static int do_sftp_init(void); -void do_sftp_cleanup(); +static void do_sftp_cleanup(void); /* ---------------------------------------------------------------------- * sftp client state. @@ -2383,7 +2383,7 @@ static int do_sftp_init(void) return 0; } -void do_sftp_cleanup() +static void do_sftp_cleanup(void) { char ch; if (backend) { diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index d2fd6f64..1d88d7fc 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -150,7 +150,7 @@ static void coloursel_ok(GtkButton *button, gpointer data); static void coloursel_cancel(GtkButton *button, gpointer data); #endif static void dlgparam_destroy(GtkWidget *widget, gpointer data); -int get_listitemheight(GtkWidget *widget); +static int get_listitemheight(GtkWidget *widget); static int uctrl_cmp_byctrl(void *av, void *bv) { @@ -2836,7 +2836,7 @@ void shortcut_add(struct Shortcuts *scs, GtkWidget *labelw, shortcut_highlight(labelw, chr); } -int get_listitemheight(GtkWidget *w) +static int get_listitemheight(GtkWidget *w) { #if !GTK_CHECK_VERSION(2,0,0) GtkWidget *listitem = gtk_list_item_new_with_label("foo"); diff --git a/windows/winnet.c b/windows/winnet.c index f26343be..459d584a 100644 --- a/windows/winnet.c +++ b/windows/winnet.c @@ -206,7 +206,7 @@ static HMODULE winsock2_module = NULL; static HMODULE wship6_module = NULL; #endif -bool sk_startup(int hi, int lo) +static bool sk_startup(int hi, int lo) { WORD winsock_ver; @@ -590,7 +590,7 @@ SockAddr *sk_namedpipe_addr(const char *pipename) return ret; } -bool sk_nextaddr(SockAddr *addr, SockAddrStep *step) +static bool sk_nextaddr(SockAddr *addr, SockAddrStep *step) { #ifndef NO_IPV6 if (step->ai) {