Browse Source

Merge pull request #428 from libtom/pr/fix-gcc-warnings1

fix -Wmissing-declarations -Wmissing-prototypes -Wmissing-noreturn
karel-m 7 years ago
parent
commit
c9376c29ba
5 changed files with 46 additions and 44 deletions
  1. 1 1
      demos/ltcrypt.c
  2. 30 30
      demos/tv_gen.c
  3. 1 1
      tests/der_test.c
  4. 4 4
      tests/ecc_test.c
  5. 10 8
      tests/no_prng.c

+ 1 - 1
demos/ltcrypt.c

@@ -18,7 +18,7 @@
 
 #include <tomcrypt.h>
 
-int usage(char *name)
+static int NORETURN usage(char *name)
 {
    int x;
 

+ 30 - 30
demos/tv_gen.c

@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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],
@@ -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],
@@ -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],
@@ -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],
@@ -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];
@@ -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;
@@ -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];
@@ -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;
@@ -765,8 +765,8 @@ void lrw_gen(void)
        lrw_done(&lrw);
    }
    fclose(out);
-#endif
 }
+#endif
 
 int main(void)
 {

+ 1 - 1
tests/der_test.c

@@ -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) {

+ 4 - 4
tests/ecc_test.c

@@ -209,7 +209,7 @@ done:
    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;
@@ -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
@@ -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) {
@@ -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];

+ 10 - 8
tests/no_prng.c

@@ -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
@@ -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);
@@ -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);
@@ -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);
 
@@ -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);
@@ -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;
@@ -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);
@@ -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);
@@ -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;
 }