Skip to content

Commit

Permalink
Merge pull request #428 from libtom/pr/fix-gcc-warnings1
Browse files Browse the repository at this point in the history
fix -Wmissing-declarations -Wmissing-prototypes -Wmissing-noreturn
  • Loading branch information
karel-m authored Jul 9, 2018
2 parents b5009d7 + ba8fa04 commit c9376c2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 44 deletions.
2 changes: 1 addition & 1 deletion demos/ltcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <tomcrypt.h>

int usage(char *name)
static int NORETURN usage(char *name)
{
int x;

Expand Down
60 changes: 30 additions & 30 deletions demos/tv_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
#include "tomcrypt_private.h"

void hash_gen(void)
static void hash_gen(void)
{
unsigned char md[MAXBLOCKSIZE], *buf;
unsigned long outlen, x, y, z;
Expand Down Expand Up @@ -49,7 +49,7 @@ void hash_gen(void)
fclose(out);
}

void cipher_gen(void)
static void cipher_gen(void)
{
unsigned char *key, pt[MAXBLOCKSIZE];
unsigned long x, y, z, w;
Expand Down Expand Up @@ -124,7 +124,7 @@ void cipher_gen(void)
fclose(out);
}

void hmac_gen(void)
static void hmac_gen(void)
{
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], *input;
int x, y, z, err;
Expand Down Expand Up @@ -176,9 +176,9 @@ void hmac_gen(void)
fclose(out);
}

void omac_gen(void)
{
#ifdef LTC_OMAC
static void omac_gen(void)
{
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
int err, x, y, z, kl;
FILE *out;
Expand Down Expand Up @@ -234,12 +234,12 @@ void omac_gen(void)
fprintf(out, "\n");
}
fclose(out);
#endif
}
#endif

void pmac_gen(void)
{
#ifdef LTC_PMAC
static void pmac_gen(void)
{
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
int err, x, y, z, kl;
FILE *out;
Expand Down Expand Up @@ -295,12 +295,12 @@ void pmac_gen(void)
fprintf(out, "\n");
}
fclose(out);
#endif
}
#endif

void eax_gen(void)
{
#ifdef LTC_EAX_MODE
static void eax_gen(void)
{
int err, kl, x, y1, z;
FILE *out;
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2], header[MAXBLOCKSIZE*2],
Expand Down Expand Up @@ -361,12 +361,12 @@ void eax_gen(void)
fprintf(out, "\n");
}
fclose(out);
#endif
}
#endif

void ocb_gen(void)
{
#ifdef LTC_OCB_MODE
static void ocb_gen(void)
{
int err, kl, x, y1, z;
FILE *out;
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
Expand Down Expand Up @@ -430,12 +430,12 @@ void ocb_gen(void)
fprintf(out, "\n");
}
fclose(out);
#endif
}
#endif

void ocb3_gen(void)
{
#ifdef LTC_OCB3_MODE
static void ocb3_gen(void)
{
int err, kl, x, y1, z, noncelen;
FILE *out;
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
Expand Down Expand Up @@ -500,12 +500,12 @@ void ocb3_gen(void)
fprintf(out, "\n");
}
fclose(out);
#endif
}
#endif

void ccm_gen(void)
{
#ifdef LTC_CCM_MODE
static void ccm_gen(void)
{
int err, kl, x, y1, z;
FILE *out;
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
Expand Down Expand Up @@ -569,12 +569,12 @@ void ccm_gen(void)
fprintf(out, "\n");
}
fclose(out);
#endif
}
#endif

void gcm_gen(void)
{
#ifdef LTC_GCM_MODE
static void gcm_gen(void)
{
int err, kl, x, y1, z;
FILE *out;
unsigned char key[MAXBLOCKSIZE], plaintext[MAXBLOCKSIZE*2], tag[MAXBLOCKSIZE];
Expand Down Expand Up @@ -632,10 +632,10 @@ void gcm_gen(void)
fprintf(out, "\n");
}
fclose(out);
#endif
}
#endif

void base64_gen(void)
static void base64_gen(void)
{
FILE *out;
unsigned char src[32], ch;
Expand All @@ -655,11 +655,11 @@ void base64_gen(void)
fclose(out);
}

void math_gen(void)
static void math_gen(void)
{
}

void ecc_gen(void)
static void ecc_gen(void)
{
FILE *out;
unsigned char str[512];
Expand Down Expand Up @@ -701,9 +701,9 @@ void ecc_gen(void)
fclose(out);
}

void lrw_gen(void)
{
#ifdef LTC_LRW_MODE
static void lrw_gen(void)
{
FILE *out;
unsigned char tweak[16], key[16], iv[16], buf[1024];
int x, y, err;
Expand Down Expand Up @@ -765,8 +765,8 @@ void lrw_gen(void)
lrw_done(&lrw);
}
fclose(out);
#endif
}
#endif

int main(void)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/der_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ static void der_Xcode_test(void)
}

#ifdef LTC_TEST_READDIR
int _der_decode_sequence_flexi(const void *in, unsigned long inlen, void* ctx)
static int _der_decode_sequence_flexi(const void *in, unsigned long inlen, void* ctx)
{
ltc_asn1_list** list = ctx;
if (der_decode_sequence_flexi(in, &inlen, list) == CRYPT_OK) {
Expand Down
8 changes: 4 additions & 4 deletions tests/ecc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static int _ecc_test_mp(void)
return err;
}

int _ecc_old_api(void)
static int _ecc_old_api(void)
{
unsigned char buf[4][4096], ch;
unsigned long x, y, z, s;
Expand Down Expand Up @@ -350,7 +350,7 @@ int _ecc_old_api(void)
return CRYPT_OK;
}

int _ecc_new_api(void)
static int _ecc_new_api(void)
{
const char* names[] = {
#ifdef LTC_ECC_SECP112R1
Expand Down Expand Up @@ -517,7 +517,7 @@ int _ecc_new_api(void)
return CRYPT_OK;
}

int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
static int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
{
if (should_type != is->type) return CRYPT_ERROR;
if (should_type == PK_PRIVATE) {
Expand All @@ -536,7 +536,7 @@ int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is
return CRYPT_OK;
}

int _ecc_import_export(void) {
static int _ecc_import_export(void) {
const ltc_ecc_curve *cu;
ecc_key key, pri, pub;
unsigned char out[300];
Expand Down
18 changes: 10 additions & 8 deletions tests/no_prng.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* The library is free for all purposes without any express
* guarantee it works.
*/

#include "tomcrypt.h"
#include "tomcrypt_test.h"

/**
@file no_prng.c
Expand All @@ -29,7 +31,7 @@ typedef struct
@param prng [out] The PRNG state to initialize
@return CRYPT_OK if successful
*/
int no_prng_start(prng_state *prng)
static int no_prng_start(prng_state *prng)
{
no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
LTC_ARGCHK(no_prng != NULL);
Expand All @@ -47,7 +49,7 @@ int no_prng_start(prng_state *prng)
@param prng PRNG state to update
@return CRYPT_OK if successful
*/
int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng)
static int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng)
{
no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
LTC_ARGCHK(no_prng != NULL);
Expand All @@ -68,7 +70,7 @@ int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state
@param prng The PRNG to make active
@return CRYPT_OK if successful
*/
int no_prng_ready(prng_state *prng)
static int no_prng_ready(prng_state *prng)
{
LTC_ARGCHK(prng != NULL);

Expand All @@ -82,7 +84,7 @@ int no_prng_ready(prng_state *prng)
@param prng The active PRNG to read from
@return Number of octets read
*/
unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state *prng)
static unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state *prng)
{
no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
LTC_ARGCHK(no_prng != NULL);
Expand All @@ -101,7 +103,7 @@ unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state
@param prng The PRNG to terminate
@return CRYPT_OK if successful
*/
int no_prng_done(prng_state *prng)
static int no_prng_done(prng_state *prng)
{
LTC_UNUSED_PARAM(prng);
return CRYPT_OK;
Expand All @@ -114,7 +116,7 @@ int no_prng_done(prng_state *prng)
@param prng The PRNG to export
@return CRYPT_OK if successful
*/
int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
static int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
{
LTC_UNUSED_PARAM(out);
LTC_UNUSED_PARAM(outlen);
Expand All @@ -129,7 +131,7 @@ int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
@param prng The PRNG to import
@return CRYPT_OK if successful
*/
int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
static int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
{
LTC_UNUSED_PARAM(in);
LTC_UNUSED_PARAM(inlen);
Expand All @@ -141,7 +143,7 @@ int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prn
PRNG self-test
@return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled
*/
int no_prng_test(void)
static int no_prng_test(void)
{
return CRYPT_OK;
}
Expand Down

0 comments on commit c9376c2

Please sign in to comment.