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
+3 -3
View File
@@ -56,7 +56,7 @@ bool verbose = false;
#define NONCE_FMT "%016"PRIx64
std::string random_payload( void ) {
static std::string random_payload( void ) {
const size_t len = prng.uint32() % MESSAGE_SIZE_MAX;
char *buf = new char[len];
prng.fill( buf, len );
@@ -66,7 +66,7 @@ std::string random_payload( void ) {
return payload;
}
void test_bad_decrypt( Session &decryption_session ) {
static void test_bad_decrypt( Session &decryption_session ) {
std::string bad_ct = random_payload();
bool got_exn = false;
@@ -87,7 +87,7 @@ void test_bad_decrypt( Session &decryption_session ) {
}
/* Generate a single key and initial nonce, then perform some encryptions. */
void test_one_session( void ) {
static void test_one_session( void ) {
Base64Key key;
Session encryption_session( key );
Session decryption_session( key );
+16 -16
View File
@@ -55,26 +55,26 @@ using Crypto::AlignedBuffer;
bool verbose = false;
bool equal( const AlignedBuffer &a, const AlignedBuffer &b ) {
static bool equal( const AlignedBuffer &a, const AlignedBuffer &b ) {
return ( a.len() == b.len() )
&& !memcmp( a.data(), b.data(), a.len() );
}
AlignedBuffer *get_ctx( const AlignedBuffer &key ) {
static AlignedBuffer *get_ctx( const AlignedBuffer &key ) {
AlignedBuffer *ctx_buf = new AlignedBuffer( ae_ctx_sizeof() );
fatal_assert( ctx_buf );
fatal_assert( AE_SUCCESS == ae_init( (ae_ctx *)ctx_buf->data(), key.data(), key.len(), NONCE_LEN, TAG_LEN ) );
return ctx_buf;
}
void scrap_ctx( AlignedBuffer *ctx_buf ) {
static void scrap_ctx( AlignedBuffer *ctx_buf ) {
fatal_assert( AE_SUCCESS == ae_clear( (ae_ctx *)ctx_buf->data() ) );
delete ctx_buf;
}
void test_encrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
const AlignedBuffer &plaintext, const AlignedBuffer &assoc,
const AlignedBuffer &expected_ciphertext ) {
static void test_encrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
const AlignedBuffer &plaintext, const AlignedBuffer &assoc,
const AlignedBuffer &expected_ciphertext ) {
AlignedBuffer *ctx_buf = get_ctx( key );
ae_ctx *ctx = (ae_ctx *)ctx_buf->data();
@@ -97,10 +97,10 @@ void test_encrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
scrap_ctx( ctx_buf );
}
void test_decrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
const AlignedBuffer &ciphertext, const AlignedBuffer &assoc,
const AlignedBuffer &expected_plaintext,
bool valid ) {
static void test_decrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
const AlignedBuffer &ciphertext, const AlignedBuffer &assoc,
const AlignedBuffer &expected_plaintext,
bool valid ) {
AlignedBuffer *ctx_buf = get_ctx( key );
ae_ctx *ctx = (ae_ctx *)ctx_buf->data();
@@ -129,10 +129,10 @@ void test_decrypt( const AlignedBuffer &key, const AlignedBuffer &nonce,
scrap_ctx( ctx_buf );
}
void test_vector( const char *key_p, const char *nonce_p,
size_t assoc_len, const char *assoc_p,
size_t plaintext_len, const char *plaintext_p,
size_t ciphertext_len, const char *ciphertext_p ) {
static void test_vector( const char *key_p, const char *nonce_p,
size_t assoc_len, const char *assoc_p,
size_t plaintext_len, const char *plaintext_p,
size_t ciphertext_len, const char *ciphertext_p ) {
AlignedBuffer key ( KEY_LEN, key_p );
AlignedBuffer nonce ( NONCE_LEN, nonce_p );
@@ -172,7 +172,7 @@ void test_vector( const char *key_p, const char *nonce_p,
#define TEST_VECTOR( _key, _nonce, _assoc, _pt, _ct ) \
test_vector( _key, _nonce, sizeof(_assoc)-1, _assoc, sizeof(_pt)-1, _pt, sizeof(_ct)-1, _ct )
void test_all_vectors( void ) {
static void test_all_vectors( void ) {
/* Test vectors from http://tools.ietf.org/html/draft-krovetz-ocb-03#appendix-A */
const char ietf_key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F";
@@ -463,7 +463,7 @@ void test_all_vectors( void ) {
/* http://tools.ietf.org/html/draft-krovetz-ocb-03#appendix-A
also specifies an iterative test algorithm, which we implement here. */
void test_iterative( void ) {
static void test_iterative( void ) {
/* Key is always all zeros */
AlignedBuffer key( KEY_LEN );
memset( key.data(), 0, KEY_LEN );