Mark local functions as static

This helps to catch unused functions like the former mosh_read_line,
allows the compiler to make better inlining decisions, and reduces the
binary size a bit.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2014-04-23 16:31:27 -04:00
committed by John Hood
parent a52b095f50
commit cd2ae36f36
7 changed files with 88 additions and 88 deletions
+2 -2
View File
@@ -70,7 +70,7 @@
# error "SysV or X/Open-compatible Curses header file required"
#endif
void usage( const char *argv0 ) {
static void usage( const char *argv0 ) {
fprintf( stderr, "mosh-client (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION );
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" );
@@ -78,7 +78,7 @@ void usage( const char *argv0 ) {
fprintf( stderr, "Usage: %s IP PORT\n %s -c\n", argv0, argv0 );
}
void print_colorcount( void )
static void print_colorcount( void )
{
/* check colors */
setupterm((char *)0, 1, (int *)0);
+22 -22
View File
@@ -91,28 +91,28 @@
typedef Network::Transport< Terminal::Complete, Network::UserStream > ServerConnection;
void serve( int host_fd,
Terminal::Complete &terminal,
ServerConnection &network );
static void serve( int host_fd,
Terminal::Complete &terminal,
ServerConnection &network );
int run_server( const char *desired_ip, const char *desired_port,
const string &command_path, char *command_argv[],
const int colors, bool verbose, bool with_motd );
static int run_server( const char *desired_ip, const char *desired_port,
const string &command_path, char *command_argv[],
const int colors, bool verbose, bool with_motd );
using namespace std;
void print_usage( const char *argv0 )
static void print_usage( const char *argv0 )
{
fprintf( stderr, "Usage: %s new [-s] [-v] [-i LOCALADDR] [-p PORT[:PORT2]] [-c COLORS] [-l NAME=VALUE] [-- COMMAND...]\n", argv0 );
}
void print_motd( void );
void chdir_homedir( void );
bool motd_hushed( void );
void warn_unattached( const string & ignore_entry );
static void print_motd( void );
static void chdir_homedir( void );
static bool motd_hushed( void );
static void warn_unattached( const string & ignore_entry );
/* Simple spinloop */
void spin( void )
static void spin( void )
{
static unsigned int spincount = 0;
spincount++;
@@ -126,7 +126,7 @@ void spin( void )
}
}
string get_SSH_IP( void )
static string get_SSH_IP( void )
{
const char *SSH_CONNECTION = getenv( "SSH_CONNECTION" );
if ( !SSH_CONNECTION ) { /* Older sshds don't set this */
@@ -327,9 +327,9 @@ int main( int argc, char *argv[] )
}
}
int run_server( const char *desired_ip, const char *desired_port,
const string &command_path, char *command_argv[],
const int colors, bool verbose, bool with_motd ) {
static int run_server( const char *desired_ip, const char *desired_port,
const string &command_path, char *command_argv[],
const int colors, bool verbose, bool with_motd ) {
/* get initial window size */
struct winsize window_size;
if ( ioctl( STDIN_FILENO, TIOCGWINSZ, &window_size ) < 0 ||
@@ -521,7 +521,7 @@ int run_server( const char *desired_ip, const char *desired_port,
return 0;
}
void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network )
static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network )
{
/* prepare to poll for events */
Select &sel = Select::get_instance();
@@ -746,7 +746,7 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
}
/* OpenSSH prints the motd on startup, so we will too */
void print_motd( void )
static void print_motd( void )
{
FILE *motd = fopen( "/etc/motd", "r" );
if ( !motd ) {
@@ -770,7 +770,7 @@ void print_motd( void )
fclose( motd );
}
void chdir_homedir( void )
static void chdir_homedir( void )
{
struct passwd *pw = getpwuid( geteuid() );
if ( pw == NULL ) {
@@ -787,21 +787,21 @@ void chdir_homedir( void )
}
}
bool motd_hushed( void )
static bool motd_hushed( void )
{
/* must be in home directory already */
struct stat buf;
return (0 == lstat( ".hushlogin", &buf ));
}
bool device_exists( const char *ut_line )
static bool device_exists( const char *ut_line )
{
string device_name = string( "/dev/" ) + string( ut_line );
struct stat buf;
return (0 == lstat( device_name.c_str(), &buf ));
}
void warn_unattached( const string & ignore_entry )
static void warn_unattached( const string & ignore_entry )
{
#ifdef HAVE_UTMPX_H
/* get username */